diff --git a/app/integration_test/search_test.dart b/app/integration_test/search_test.dart index 5d364d55..a1397622 100644 --- a/app/integration_test/search_test.dart +++ b/app/integration_test/search_test.dart @@ -1,5 +1,4 @@ import 'package:app/common/module.dart'; -import 'package:app/common/widgets/drug_list/drug_items/drug_cards.dart'; import 'package:app/search/module.dart'; import 'package:bloc_test/bloc_test.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; diff --git a/app/lib/common/widgets/drug_list/builder.dart b/app/lib/common/widgets/drug_list/builder.dart index 081109ca..a0193f21 100644 --- a/app/lib/common/widgets/drug_list/builder.dart +++ b/app/lib/common/widgets/drug_list/builder.dart @@ -1,5 +1,4 @@ import '../../module.dart'; -import 'drug_items/drug_cards.dart'; List buildDrugList( BuildContext context, diff --git a/app/lib/common/widgets/drug_search/builder.dart b/app/lib/common/widgets/drug_search/builder.dart index 35a2b263..16df703c 100644 --- a/app/lib/common/widgets/drug_search/builder.dart +++ b/app/lib/common/widgets/drug_search/builder.dart @@ -4,7 +4,6 @@ import 'package:provider/provider.dart'; import '../../../../common/module.dart'; import '../../../drug/widgets/tooltip_icon.dart'; -import 'filter_menu.dart'; class DrugSearch extends HookWidget { DrugSearch({ @@ -53,7 +52,7 @@ class DrugSearch extends HookWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ ..._buildSearchBarItems(context, searchController), - if (showFilter) FilterMenu(cubit, state), + if (showFilter) FilterButton(), ], ), ), diff --git a/app/lib/common/widgets/drug_search/filter_menu.dart b/app/lib/common/widgets/drug_search/filter_menu.dart index bc735b17..5347c97d 100644 --- a/app/lib/common/widgets/drug_search/filter_menu.dart +++ b/app/lib/common/widgets/drug_search/filter_menu.dart @@ -1,5 +1,16 @@ import '../../module.dart'; +class FilterButton extends StatelessWidget { + @override + Widget build(BuildContext context) { + return IconButton( + icon: Icon(Icons.filter_list), + color: PharMeTheme.iconColor, + onPressed: Scaffold.of(context).openDrawer, + ); + } +} + class FilterMenuItem { FilterMenuItem({ required bool initialValue, @@ -20,32 +31,30 @@ class FilterMenuItem { } class FilterMenu extends HookWidget { - const FilterMenu(this.cubit, this.state); + const FilterMenu(this.cubit); final DrugListCubit cubit; - final DrugListState state; @override Widget build(BuildContext context) { - return PopupMenuButton( - icon: Icon(Icons.filter_list), - color: PharMeTheme.onSurfaceColor, - elevation: 0, - itemBuilder: (context) => _menuItems.map( - (item) => PopupMenuItem(child: StatefulBuilder( - builder: (context, setState) { - return item.build( - context, - value: item.value, - statefulOnChange: ([_]) { - final newValue = !item.value; - setState(() => item.value = newValue); - item.updateSearch(newValue); - }, - ); - }), - ), - ).toList(), + return SafeArea( + child: Column( + children: _menuItems.map( + (item) => PopupMenuItem(child: StatefulBuilder( + builder: (context, setState) { + return item.build( + context, + value: item.value, + statefulOnChange: ([_]) { + final newValue = !item.value; + setState(() => item.value = newValue); + item.updateSearch(newValue); + }, + ); + }), + ), + ).toList(), + ), ); } diff --git a/app/lib/common/widgets/module.dart b/app/lib/common/widgets/module.dart index e3e93aa9..a166e872 100644 --- a/app/lib/common/widgets/module.dart +++ b/app/lib/common/widgets/module.dart @@ -6,7 +6,9 @@ export 'dialog_content_text.dart'; export 'dialog_wrapper.dart'; export 'drug_list/builder.dart'; export 'drug_list/cubit.dart'; +export 'drug_list/drug_items/drug_cards.dart'; export 'drug_search/builder.dart'; +export 'drug_search/filter_menu.dart'; export 'error_handler.dart'; export 'full_width_button.dart'; export 'headings.dart'; diff --git a/app/lib/common/widgets/page_scaffold.dart b/app/lib/common/widgets/page_scaffold.dart index 4313d21b..8406c308 100644 --- a/app/lib/common/widgets/page_scaffold.dart +++ b/app/lib/common/widgets/page_scaffold.dart @@ -70,6 +70,7 @@ Scaffold unscrollablePageScaffold({ String? title, String? barBottom, List? actions, + Widget? drawer, Key? key, }) { final appBar = title == null @@ -79,6 +80,7 @@ Scaffold unscrollablePageScaffold({ foregroundColor: PharMeTheme.appBarTheme.foregroundColor, elevation: PharMeTheme.appBarTheme.elevation, leadingWidth: PharMeTheme.appBarTheme.leadingWidth, + automaticallyImplyLeading: false, centerTitle: PharMeTheme.appBarTheme.centerTitle, title: buildTitle(title), actions: actions, @@ -94,5 +96,6 @@ Scaffold unscrollablePageScaffold({ child: body, ), ), + drawer: drawer, ); } diff --git a/app/lib/search/pages/search.dart b/app/lib/search/pages/search.dart index 566e00f3..8062996e 100644 --- a/app/lib/search/pages/search.dart +++ b/app/lib/search/pages/search.dart @@ -1,5 +1,4 @@ import '../../../common/module.dart'; -import '../../common/widgets/drug_list/drug_items/drug_cards.dart'; @RoutePage() class SearchPage extends HookWidget { @@ -27,6 +26,7 @@ class SearchPage extends HookWidget { cubit: cubit, showDrugInteractionIndicator: true, ), + drawer: FilterMenu(cubit), ), ); }