From db111e7e26cf43b549fbddd5d648741b7d590b6a Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 15 Mar 2022 12:40:12 +0530 Subject: [PATCH 1/3] fixed #1126 More appealing empty history screen --- .../product/common/product_list_page.dart | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/packages/smooth_app/lib/pages/product/common/product_list_page.dart b/packages/smooth_app/lib/pages/product/common/product_list_page.dart index 4112788465b..8f7473dfd9a 100644 --- a/packages/smooth_app/lib/pages/product/common/product_list_page.dart +++ b/packages/smooth_app/lib/pages/product/common/product_list_page.dart @@ -122,10 +122,42 @@ class _ProductListPageState extends State { ), ), body: products.isEmpty - ? Center( - child: Text(appLocalizations.no_prodcut_in_list, - style: Theme.of(context).textTheme.subtitle1), + ? Column( + children: [ + Container( + height: MediaQuery.of(context).size.height * 0.3, + child: LayoutBuilder(builder: (context, constraint) { + return Icon( + Icons.find_in_page_rounded, + color: Colors.blue, + size: constraint.biggest.height, + semanticLabel: 'History not available', + ); + }), + ), + Text( + 'Start scanning!', + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 36.0, + ), + ), + Padding( + padding: EdgeInsets.all(20.0), + child: Text( + 'Product you scan in will appear here and you can check detailed information about them', + style: TextStyle( + color: Colors.black, + ), + ), + ) + ], ) + // ? Center( + // child: Text(appLocalizations.no_prodcut_in_list, + // style: Theme.of(context).textTheme.subtitle1), + // ) : ListView.builder( itemCount: products.length, itemBuilder: (BuildContext context, int index) { From 3639959f3e2ecf4b3ac044130a586ae9d09a7a0b Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 15 Mar 2022 16:11:15 +0530 Subject: [PATCH 2/3] fix #1126 --- .../product/common/product_list_page.dart | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/packages/smooth_app/lib/pages/product/common/product_list_page.dart b/packages/smooth_app/lib/pages/product/common/product_list_page.dart index 8f7473dfd9a..75eba0fda86 100644 --- a/packages/smooth_app/lib/pages/product/common/product_list_page.dart +++ b/packages/smooth_app/lib/pages/product/common/product_list_page.dart @@ -13,6 +13,8 @@ import 'package:smooth_app/pages/personalized_ranking_page.dart'; import 'package:smooth_app/pages/product/common/product_list_item_simple.dart'; import 'package:smooth_app/pages/product/common/product_query_page_helper.dart'; +import '../../../generic_lib/design_constants.dart'; + class ProductListPage extends StatefulWidget { const ProductListPage(this.productList); @@ -32,6 +34,7 @@ class _ProductListPageState extends State { Widget build(BuildContext context) { final LocalDatabase localDatabase = context.watch(); final DaoProductList daoProductList = DaoProductList(localDatabase); + final ThemeData themeData = Theme.of(context); final ColorScheme colorScheme = Theme.of(context).colorScheme; final AppLocalizations appLocalizations = AppLocalizations.of(context)!; if (first) { @@ -123,41 +126,33 @@ class _ProductListPageState extends State { ), body: products.isEmpty ? Column( - children: [ - Container( - height: MediaQuery.of(context).size.height * 0.3, - child: LayoutBuilder(builder: (context, constraint) { - return Icon( - Icons.find_in_page_rounded, - color: Colors.blue, - size: constraint.biggest.height, - semanticLabel: 'History not available', - ); - }), + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + height: MediaQuery.of(context).size.height * 0.30, + child: Icon( + Icons.find_in_page_rounded, + color: colorScheme.primary, + size: VERY_LARGE_SPACE * 10, + semanticLabel: 'History not available', + ), ), Text( - 'Start scanning!', - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 36.0, - ), + 'Start scanning !', // TODO: localization + style: themeData.textTheme.headlineLarge + ?.apply(color: colorScheme.onBackground), ), Padding( - padding: EdgeInsets.all(20.0), + padding: EdgeInsets.all(VERY_LARGE_SPACE), child: Text( - 'Product you scan in will appear here and you can check detailed information about them', + 'Product you scan in will appear here and you can check detailed information about them', // TODO: localization style: TextStyle( - color: Colors.black, + color: colorScheme.onBackground, ), ), ) ], ) - // ? Center( - // child: Text(appLocalizations.no_prodcut_in_list, - // style: Theme.of(context).textTheme.subtitle1), - // ) : ListView.builder( itemCount: products.length, itemBuilder: (BuildContext context, int index) { From fe8fe0e764b5a2eaadaca49f28497b62d874bff2 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 16 Mar 2022 12:10:24 +0530 Subject: [PATCH 3/3] fix #1126 --- .../product/common/product_list_page.dart | 69 +++++++++---------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/packages/smooth_app/lib/pages/product/common/product_list_page.dart b/packages/smooth_app/lib/pages/product/common/product_list_page.dart index 75eba0fda86..2b6b83430f0 100644 --- a/packages/smooth_app/lib/pages/product/common/product_list_page.dart +++ b/packages/smooth_app/lib/pages/product/common/product_list_page.dart @@ -8,13 +8,12 @@ import 'package:smooth_app/database/dao_product.dart'; import 'package:smooth_app/database/dao_product_list.dart'; import 'package:smooth_app/database/local_database.dart'; import 'package:smooth_app/database/product_query.dart'; +import 'package:smooth_app/generic_lib/design_constants.dart'; import 'package:smooth_app/generic_lib/loading_dialog.dart'; import 'package:smooth_app/pages/personalized_ranking_page.dart'; import 'package:smooth_app/pages/product/common/product_list_item_simple.dart'; import 'package:smooth_app/pages/product/common/product_query_page_helper.dart'; -import '../../../generic_lib/design_constants.dart'; - class ProductListPage extends StatefulWidget { const ProductListPage(this.productList); @@ -59,36 +58,37 @@ class _ProductListPageState extends State { backgroundColor: Colors.white, // TODO(monsieurtanuki): night mode foregroundColor: Colors.black, title: Row( - mainAxisAlignment: _selectionMode && _selectedBarcodes.isEmpty - ? MainAxisAlignment.end // just the cancel button, at the end - : MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - if (_selectionMode && _selectedBarcodes.isNotEmpty) + if (_selectionMode) ElevatedButton( child: Text( appLocalizations.plural_compare_x_products( _selectedBarcodes.length, ), ), - onPressed: () async { - final List list = []; - for (final Product product in products) { - if (_selectedBarcodes.contains(product.barcode)) { - list.add(product); - } - } - await Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => - PersonalizedRankingPage.fromItems( - products: list, - title: 'Your ranking', - ), - ), - ); - setState(() => _selectionMode = false); - }, + onPressed: _selectedBarcodes.length >= + 2 // compare button is enabled only if 2 or more products have been selected + ? () async { + final List list = []; + for (final Product product in products) { + if (_selectedBarcodes.contains(product.barcode)) { + list.add(product); + } + } + await Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + PersonalizedRankingPage.fromItems( + products: list, + title: 'Your ranking', // TODO(X): Translate + ), + ), + ); + setState(() => _selectionMode = false); + } + : null, ), if (_selectionMode) ElevatedButton( @@ -128,24 +128,21 @@ class _ProductListPageState extends State { ? Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - height: MediaQuery.of(context).size.height * 0.30, - child: Icon( - Icons.find_in_page_rounded, - color: colorScheme.primary, - size: VERY_LARGE_SPACE * 10, - semanticLabel: 'History not available', - ), + Icon( + Icons.find_in_page_rounded, + color: colorScheme.primary, + size: VERY_LARGE_SPACE * 10, + semanticLabel: 'History not available', ), Text( - 'Start scanning !', // TODO: localization + 'Start scanning !', // TODO(bhattabhi013): localization style: themeData.textTheme.headlineLarge ?.apply(color: colorScheme.onBackground), ), Padding( - padding: EdgeInsets.all(VERY_LARGE_SPACE), + padding: const EdgeInsets.all(VERY_LARGE_SPACE), child: Text( - 'Product you scan in will appear here and you can check detailed information about them', // TODO: localization + 'Product you scan in will appear here and you can check detailed information about them', // TODO(bhattabhi013): localization style: TextStyle( color: colorScheme.onBackground, ),