From a9453903e8629eb11ee6479f378a9a3a68c54f8e Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 2 Jul 2019 09:52:09 -0300 Subject: [PATCH] Show an image if there is no data yet --- lib/pages/home_page.dart | 52 ++++++++++++++++++++++++++-------------- pubspec.yaml | 5 ++-- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 0c1e058..820b899 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -117,12 +117,28 @@ class _HomePageState extends State { stream: _query, builder: (BuildContext context, AsyncSnapshot data) { if (data.hasData) { - return MonthWidget( - days: daysInMonth(currentPage + 1), - documents: data.data.documents, - graphType: currentType, - month: currentPage, - ); + if (data.data.documents.length > 0) { + return MonthWidget( + days: daysInMonth(currentPage + 1), + documents: data.data.documents, + graphType: currentType, + month: currentPage, + ); + } else { + return Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset('assets/no_data.png'), + SizedBox(height: 80), + Text( + "Add an expense to begin", + style: Theme.of(context).textTheme.caption, + ) + ], + ), + ); + } } return Center( @@ -183,18 +199,18 @@ class _HomePageState extends State { }, controller: _controller, children: [ - _pageItem("Enero", 0), - _pageItem("Febrero", 1), - _pageItem("Marzo", 2), - _pageItem("Abril", 3), - _pageItem("Mayo", 4), - _pageItem("Junio", 5), - _pageItem("Julio", 6), - _pageItem("Agosto", 7), - _pageItem("Septiembre", 8), - _pageItem("Octubre", 9), - _pageItem("Noviembre", 10), - _pageItem("Diciembre", 11), + _pageItem("January", 0), + _pageItem("February", 1), + _pageItem("March", 2), + _pageItem("April", 3), + _pageItem("May", 4), + _pageItem("June", 5), + _pageItem("July", 6), + _pageItem("August", 7), + _pageItem("September", 8), + _pageItem("October", 9), + _pageItem("November", 10), + _pageItem("December", 11), ], ), ); diff --git a/pubspec.yaml b/pubspec.yaml index 5aea7a1..db3c584 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,9 +49,8 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg + assets: + - assets/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.io/assets-and-images/#resolution-aware.