Skip to content

Commit

Permalink
fix: openfoodfacts#1314 switch to scanner from empty list (openfoodfa…
Browse files Browse the repository at this point in the history
…cts#2347)

* fix: openfoodfacts#1314 switch to scanner from empty list

* fix: openfoodfacts#1314 switch to scanner
even it is not first route of current tab
  • Loading branch information
cli1005 authored Jun 23, 2022
1 parent 97d36bc commit 2790dfb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 22 deletions.
12 changes: 12 additions & 0 deletions packages/smooth_app/lib/pages/page_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ class PageManagerState extends State<PageManager> {
}
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
final InheritedDataManagerState inheritedDataManager =
InheritedDataManager.of(context);
if (inheritedDataManager.showSearchCard &&
_currentPage != BottomNavigationTab.Scan) {
_currentPage = BottomNavigationTab.Scan;
_selectTab(_currentPage, 1);
}
}

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context);
Expand Down
50 changes: 28 additions & 22 deletions packages/smooth_app/lib/pages/product/common/product_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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 'package:smooth_app/pages/product_list_user_dialog_helper.dart';
import 'package:smooth_app/pages/scan/inherited_data_manager.dart';

class ProductListPage extends StatefulWidget {
const ProductListPage(this.productList);
Expand Down Expand Up @@ -158,29 +159,34 @@ class _ProductListPageState extends State<ProductListPage>
),
),
body: products.isEmpty
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SvgPicture.asset(
'assets/misc/empty-list.svg',
height: MediaQuery.of(context).size.height * .4,
),
Text(
appLocalizations.product_list_empty_title,
style: themeData.textTheme.headlineLarge
?.apply(color: colorScheme.onBackground),
),
Padding(
padding: const EdgeInsets.all(VERY_LARGE_SPACE),
child: Text(
appLocalizations.product_list_empty_message,
textAlign: TextAlign.center,
style: themeData.textTheme.bodyText2?.apply(
color: colorScheme.onBackground,
),
? GestureDetector(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SvgPicture.asset(
'assets/misc/empty-list.svg',
height: MediaQuery.of(context).size.height * .4,
),
)
],
Text(
appLocalizations.product_list_empty_title,
style: themeData.textTheme.headlineLarge
?.apply(color: colorScheme.onBackground),
),
Padding(
padding: const EdgeInsets.all(VERY_LARGE_SPACE),
child: Text(
appLocalizations.product_list_empty_message,
textAlign: TextAlign.center,
style: themeData.textTheme.bodyText2?.apply(
color: colorScheme.onBackground,
),
),
)
],
),
onTap: () {
InheritedDataManager.of(context).resetShowSearchCard(true);
},
)
: RefreshIndicator(
//if it is in selectmode then refresh indicator is not shown
Expand Down

0 comments on commit 2790dfb

Please sign in to comment.