diff --git a/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid.dart b/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid.dart index d0f82990b8..a6a08aadda 100644 --- a/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid.dart +++ b/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid.dart @@ -224,13 +224,28 @@ class ImmichAssetGridState extends State { } } + + Future onWillPop() async { + if (widget.selectionActive && _selectedAssets.isNotEmpty) { + _deselectAll(); + return false; + } + + return true; + } + + + @override Widget build(BuildContext context) { - return Stack( - children: [ - _buildAssetGrid(), - if (widget.selectionActive) _buildMultiSelectIndicator(), - ], + return WillPopScope( + onWillPop: onWillPop, + child: Stack( + children: [ + _buildAssetGrid(), + if (widget.selectionActive) _buildMultiSelectIndicator(), + ], + ), ); } } diff --git a/mobile/lib/modules/home/views/home_page.dart b/mobile/lib/modules/home/views/home_page.dart index 5b1ac7cd14..d032a61651 100644 --- a/mobile/lib/modules/home/views/home_page.dart +++ b/mobile/lib/modules/home/views/home_page.dart @@ -200,46 +200,34 @@ class HomePage extends HookConsumerWidget { ); } - Future onWillPop() async { - if (multiselectEnabled.state) { - selectionEnabledHook.value = false; - return false; - } - - return true; - } - - return WillPopScope( - onWillPop: onWillPop, - child: SafeArea( - bottom: !multiselectEnabled.state, - top: true, - child: Stack( - children: [ - ref.watch(assetProvider).renderList == null || - ref.watch(assetProvider).allAssets.isEmpty - ? buildLoadingIndicator() - : ImmichAssetGrid( - renderList: ref.watch(assetProvider).renderList!, - allAssets: ref.watch(assetProvider).allAssets, - assetsPerRow: appSettingService - .getSetting(AppSettingsEnum.tilesPerRow), - showStorageIndicator: appSettingService - .getSetting(AppSettingsEnum.storageIndicator), - listener: selectionListener, - selectionActive: selectionEnabledHook.value, - ), - if (selectionEnabledHook.value) - ControlBottomAppBar( - onShare: onShareAssets, - onDelete: onDelete, - onAddToAlbum: onAddToAlbum, - albums: albums, - sharedAlbums: sharedAlbums, - onCreateNewAlbum: onCreateNewAlbum, - ), - ], - ), + return SafeArea( + bottom: !multiselectEnabled.state, + top: true, + child: Stack( + children: [ + ref.watch(assetProvider).renderList == null || + ref.watch(assetProvider).allAssets.isEmpty + ? buildLoadingIndicator() + : ImmichAssetGrid( + renderList: ref.watch(assetProvider).renderList!, + allAssets: ref.watch(assetProvider).allAssets, + assetsPerRow: appSettingService + .getSetting(AppSettingsEnum.tilesPerRow), + showStorageIndicator: appSettingService + .getSetting(AppSettingsEnum.storageIndicator), + listener: selectionListener, + selectionActive: selectionEnabledHook.value, + ), + if (selectionEnabledHook.value) + ControlBottomAppBar( + onShare: onShareAssets, + onDelete: onDelete, + onAddToAlbum: onAddToAlbum, + albums: albums, + sharedAlbums: sharedAlbums, + onCreateNewAlbum: onCreateNewAlbum, + ), + ], ), ); }