From 293e713af66aa0db52abe9daa82edff2ee23adc6 Mon Sep 17 00:00:00 2001 From: Alex Tran Date: Fri, 14 Oct 2022 15:37:15 -0500 Subject: [PATCH] Hide bottom app bar when multiselect enabled --- .../home/providers/multiselect.provider.dart | 5 ++++ mobile/lib/modules/home/views/home_page.dart | 24 ++++++++++--------- .../lib/shared/views/tab_controller_page.dart | 5 ++-- 3 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 mobile/lib/modules/home/providers/multiselect.provider.dart diff --git a/mobile/lib/modules/home/providers/multiselect.provider.dart b/mobile/lib/modules/home/providers/multiselect.provider.dart new file mode 100644 index 0000000000..22210e88c9 --- /dev/null +++ b/mobile/lib/modules/home/providers/multiselect.provider.dart @@ -0,0 +1,5 @@ +import 'package:hooks_riverpod/hooks_riverpod.dart'; + +final multiselectProvider = StateProvider((ref) { + return false; +}); diff --git a/mobile/lib/modules/home/views/home_page.dart b/mobile/lib/modules/home/views/home_page.dart index d3926f93ab..82045c6879 100644 --- a/mobile/lib/modules/home/views/home_page.dart +++ b/mobile/lib/modules/home/views/home_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/modules/home/providers/home_page_render_list_provider.dart'; +import 'package:immich_mobile/modules/home/providers/multiselect.provider.dart'; import 'package:immich_mobile/modules/home/ui/asset_grid/immich_asset_grid.dart'; import 'package:immich_mobile/modules/home/ui/control_bottom_app_bar.dart'; import 'package:immich_mobile/modules/home/ui/immich_sliver_appbar.dart'; @@ -21,8 +22,7 @@ class HomePage extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final appSettingService = ref.watch(appSettingsServiceProvider); var renderList = ref.watch(renderListProvider); - - final multiselectEnabled = useState(false); + final multiselectEnabled = ref.watch(multiselectProvider.notifier); final selection = useState({}); useEffect( @@ -41,29 +41,31 @@ class HomePage extends HookConsumerWidget { Widget buildBody() { void selectionListener( - bool multiselect, Set selectedAssets) { - multiselectEnabled.value = multiselect; + bool multiselect, + Set selectedAssets, + ) { + multiselectEnabled.state = multiselect; selection.value = selectedAssets; } void onShareAssets() { ref.watch(shareServiceProvider).shareAssets(selection.value.toList()); - multiselectEnabled.value = false; + multiselectEnabled.state = false; } void onDelete() { ref.watch(assetProvider.notifier).deleteAssets(selection.value); - multiselectEnabled.value = false; + multiselectEnabled.state = false; } return SafeArea( - bottom: !multiselectEnabled.value, - top: !multiselectEnabled.value, + bottom: !multiselectEnabled.state, + top: !multiselectEnabled.state, child: Stack( children: [ CustomScrollView( slivers: [ - multiselectEnabled.value + multiselectEnabled.state ? const SliverToBoxAdapter( child: SizedBox( height: 70, @@ -84,10 +86,10 @@ class HomePage extends HookConsumerWidget { showStorageIndicator: appSettingService .getSetting(AppSettingsEnum.storageIndicator), listener: selectionListener, - selectionActive: multiselectEnabled.value, + selectionActive: multiselectEnabled.state, ), ), - if (multiselectEnabled.value) ...[ + if (multiselectEnabled.state) ...[ ControlBottomAppBar( onShare: onShareAssets, onDelete: onDelete, diff --git a/mobile/lib/shared/views/tab_controller_page.dart b/mobile/lib/shared/views/tab_controller_page.dart index 7fe3c2f2fa..0b0634ae0e 100644 --- a/mobile/lib/shared/views/tab_controller_page.dart +++ b/mobile/lib/shared/views/tab_controller_page.dart @@ -1,8 +1,8 @@ import 'package:auto_route/auto_route.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:immich_mobile/modules/home/providers/multiselect.provider.dart'; import 'package:immich_mobile/routing/router.dart'; class TabControllerPage extends ConsumerWidget { @@ -10,6 +10,7 @@ class TabControllerPage extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + final multiselectEnabled = ref.watch(multiselectProvider); return AutoTabsRouter( routes: [ @@ -30,7 +31,7 @@ class TabControllerPage extends ConsumerWidget { opacity: animation, child: child, ), - bottomNavigationBar: false + bottomNavigationBar: multiselectEnabled ? null : BottomNavigationBar( selectedLabelStyle: const TextStyle(