[photos][mob] Deselect albums with back navigation in albums list (#6183)

## Description

This is very similar to #6182. However instead of the album selection in
the second home tab, it applies to the full albums list.

## Tests
This commit is contained in:
Aman Raj Singh Mourya
2025-06-09 11:39:26 +05:30
committed by GitHub

View File

@@ -109,9 +109,23 @@ class _CollectionsFlexiGridViewWidgetState
@override
Widget build(BuildContext context) {
return widget.albumViewType == AlbumViewType.grid
? _buildGridView(context, const ValueKey("grid_view"))
: _buildListView(context, const ValueKey("list_view"));
return PopScope(
canPop: !isAnyAlbumSelected,
onPopInvokedWithResult: (didPop, _) {
if (didPop) {
return;
}
if (isAnyAlbumSelected) {
widget.selectedAlbums!.clearAll();
setState(() {
isAnyAlbumSelected = false;
});
}
},
child: widget.albumViewType == AlbumViewType.grid
? _buildGridView(context, const ValueKey("grid_view"))
: _buildListView(context, const ValueKey("list_view")),
);
}
Widget _buildGridView(BuildContext context, Key key) {