mirror of
https://github.com/immich-app/immich.git
synced 2024-11-24 08:52:28 +02:00
Hide bottom app bar when multiselect enabled
This commit is contained in:
parent
03866b4c31
commit
293e713af6
@ -0,0 +1,5 @@
|
|||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
|
||||||
|
final multiselectProvider = StateProvider((ref) {
|
||||||
|
return false;
|
||||||
|
});
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.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/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/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/control_bottom_app_bar.dart';
|
||||||
import 'package:immich_mobile/modules/home/ui/immich_sliver_appbar.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) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final appSettingService = ref.watch(appSettingsServiceProvider);
|
final appSettingService = ref.watch(appSettingsServiceProvider);
|
||||||
var renderList = ref.watch(renderListProvider);
|
var renderList = ref.watch(renderListProvider);
|
||||||
|
final multiselectEnabled = ref.watch(multiselectProvider.notifier);
|
||||||
final multiselectEnabled = useState(false);
|
|
||||||
final selection = useState(<AssetResponseDto>{});
|
final selection = useState(<AssetResponseDto>{});
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
@ -41,29 +41,31 @@ class HomePage extends HookConsumerWidget {
|
|||||||
|
|
||||||
Widget buildBody() {
|
Widget buildBody() {
|
||||||
void selectionListener(
|
void selectionListener(
|
||||||
bool multiselect, Set<AssetResponseDto> selectedAssets) {
|
bool multiselect,
|
||||||
multiselectEnabled.value = multiselect;
|
Set<AssetResponseDto> selectedAssets,
|
||||||
|
) {
|
||||||
|
multiselectEnabled.state = multiselect;
|
||||||
selection.value = selectedAssets;
|
selection.value = selectedAssets;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onShareAssets() {
|
void onShareAssets() {
|
||||||
ref.watch(shareServiceProvider).shareAssets(selection.value.toList());
|
ref.watch(shareServiceProvider).shareAssets(selection.value.toList());
|
||||||
multiselectEnabled.value = false;
|
multiselectEnabled.state = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onDelete() {
|
void onDelete() {
|
||||||
ref.watch(assetProvider.notifier).deleteAssets(selection.value);
|
ref.watch(assetProvider.notifier).deleteAssets(selection.value);
|
||||||
multiselectEnabled.value = false;
|
multiselectEnabled.state = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
bottom: !multiselectEnabled.value,
|
bottom: !multiselectEnabled.state,
|
||||||
top: !multiselectEnabled.value,
|
top: !multiselectEnabled.state,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
CustomScrollView(
|
CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
multiselectEnabled.value
|
multiselectEnabled.state
|
||||||
? const SliverToBoxAdapter(
|
? const SliverToBoxAdapter(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 70,
|
height: 70,
|
||||||
@ -84,10 +86,10 @@ class HomePage extends HookConsumerWidget {
|
|||||||
showStorageIndicator: appSettingService
|
showStorageIndicator: appSettingService
|
||||||
.getSetting(AppSettingsEnum.storageIndicator),
|
.getSetting(AppSettingsEnum.storageIndicator),
|
||||||
listener: selectionListener,
|
listener: selectionListener,
|
||||||
selectionActive: multiselectEnabled.value,
|
selectionActive: multiselectEnabled.state,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (multiselectEnabled.value) ...[
|
if (multiselectEnabled.state) ...[
|
||||||
ControlBottomAppBar(
|
ControlBottomAppBar(
|
||||||
onShare: onShareAssets,
|
onShare: onShareAssets,
|
||||||
onDelete: onDelete,
|
onDelete: onDelete,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.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';
|
import 'package:immich_mobile/routing/router.dart';
|
||||||
|
|
||||||
class TabControllerPage extends ConsumerWidget {
|
class TabControllerPage extends ConsumerWidget {
|
||||||
@ -10,6 +10,7 @@ class TabControllerPage extends ConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final multiselectEnabled = ref.watch(multiselectProvider);
|
||||||
|
|
||||||
return AutoTabsRouter(
|
return AutoTabsRouter(
|
||||||
routes: [
|
routes: [
|
||||||
@ -30,7 +31,7 @@ class TabControllerPage extends ConsumerWidget {
|
|||||||
opacity: animation,
|
opacity: animation,
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
bottomNavigationBar: false
|
bottomNavigationBar: multiselectEnabled
|
||||||
? null
|
? null
|
||||||
: BottomNavigationBar(
|
: BottomNavigationBar(
|
||||||
selectedLabelStyle: const TextStyle(
|
selectedLabelStyle: const TextStyle(
|
||||||
|
Loading…
Reference in New Issue
Block a user