1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

fix(mobile): back button while multiselecting showing the last selected image (#1521)

This commit is contained in:
martyfuhry 2023-02-02 13:20:26 -05:00 committed by GitHub
parent 29c79ad1d8
commit 5d6559e839
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 45 deletions

View File

@ -224,13 +224,28 @@ class ImmichAssetGridState extends State<ImmichAssetGrid> {
} }
} }
Future<bool> onWillPop() async {
if (widget.selectionActive && _selectedAssets.isNotEmpty) {
_deselectAll();
return false;
}
return true;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Stack( return WillPopScope(
children: [ onWillPop: onWillPop,
_buildAssetGrid(), child: Stack(
if (widget.selectionActive) _buildMultiSelectIndicator(), children: [
], _buildAssetGrid(),
if (widget.selectionActive) _buildMultiSelectIndicator(),
],
),
); );
} }
} }

View File

@ -200,46 +200,34 @@ class HomePage extends HookConsumerWidget {
); );
} }
Future<bool> onWillPop() async { return SafeArea(
if (multiselectEnabled.state) { bottom: !multiselectEnabled.state,
selectionEnabledHook.value = false; top: true,
return false; child: Stack(
} children: [
ref.watch(assetProvider).renderList == null ||
return true; ref.watch(assetProvider).allAssets.isEmpty
} ? buildLoadingIndicator()
: ImmichAssetGrid(
return WillPopScope( renderList: ref.watch(assetProvider).renderList!,
onWillPop: onWillPop, allAssets: ref.watch(assetProvider).allAssets,
child: SafeArea( assetsPerRow: appSettingService
bottom: !multiselectEnabled.state, .getSetting(AppSettingsEnum.tilesPerRow),
top: true, showStorageIndicator: appSettingService
child: Stack( .getSetting(AppSettingsEnum.storageIndicator),
children: [ listener: selectionListener,
ref.watch(assetProvider).renderList == null || selectionActive: selectionEnabledHook.value,
ref.watch(assetProvider).allAssets.isEmpty ),
? buildLoadingIndicator() if (selectionEnabledHook.value)
: ImmichAssetGrid( ControlBottomAppBar(
renderList: ref.watch(assetProvider).renderList!, onShare: onShareAssets,
allAssets: ref.watch(assetProvider).allAssets, onDelete: onDelete,
assetsPerRow: appSettingService onAddToAlbum: onAddToAlbum,
.getSetting(AppSettingsEnum.tilesPerRow), albums: albums,
showStorageIndicator: appSettingService sharedAlbums: sharedAlbums,
.getSetting(AppSettingsEnum.storageIndicator), onCreateNewAlbum: onCreateNewAlbum,
listener: selectionListener, ),
selectionActive: selectionEnabledHook.value, ],
),
if (selectionEnabledHook.value)
ControlBottomAppBar(
onShare: onShareAssets,
onDelete: onDelete,
onAddToAlbum: onAddToAlbum,
albums: albums,
sharedAlbums: sharedAlbums,
onCreateNewAlbum: onCreateNewAlbum,
),
],
),
), ),
); );
} }