Skip to content

Commit

Permalink
fix(mobile): back button while multiselecting showing the last select…
Browse files Browse the repository at this point in the history
…ed image (#1521)
  • Loading branch information
martyfuhry committed Feb 2, 2023
1 parent 29c79ad commit 5d6559e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 45 deletions.
25 changes: 20 additions & 5 deletions mobile/lib/modules/home/ui/asset_grid/immich_asset_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,28 @@ class ImmichAssetGridState extends State<ImmichAssetGrid> {
}
}


Future<bool> 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(),
],
),
);
}
}
Expand Down
68 changes: 28 additions & 40 deletions mobile/lib/modules/home/views/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,46 +200,34 @@ class HomePage extends HookConsumerWidget {
);
}

Future<bool> 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,
),
],
),
);
}
Expand Down

1 comment on commit 5d6559e

@vercel
Copy link

@vercel vercel bot commented on 5d6559e Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deployment failed with the following error:

Resource is limited - try again in 21 minutes (more than 100, code: "api-deployments-free-per-day").

Please sign in to comment.