Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] feat: add album view type settings

Aman Raj Singh Mourya9207b0c7b884
diff --git a/mobile/lib/ui/collections/collection_list_page.dart b/mobile/lib/ui/collections/collection_list_page.dart
index 7d3b1430a1..7bc00c6f13 100644
--- a/mobile/lib/ui/collections/collection_list_page.dart
+++ b/mobile/lib/ui/collections/collection_list_page.dart
@@ -44,6 +44,7 @@ class _CollectionListPageState extends State<CollectionListPage> {
_collectionUpdatesSubscription;
List<Collection>? collections;
AlbumSortKey? sortKey;
+ AlbumViewType? albumViewType;
@override
void initState() {
@@ -54,6 +55,7 @@ class _CollectionListPageState extends State<CollectionListPage> {
unawaited(refreshCollections());
});
sortKey = localSettings.albumSortKey();
+ albumViewType = localSettings.albumViewType();
}
@override
@@ -91,6 +93,10 @@ class _CollectionListPageState extends State<CollectionListPage> {
collections,
displayLimitCount: displayLimitCount,
tag: widget.tag,
+ enableSelectionMode:
+ widget.sectionType == UISectionType.homeCollections,
+ albumViewType: albumViewType ?? AlbumViewType.grid,
+ shouldShowCreateAlbum: true,
),
],
),
@@ -127,6 +133,21 @@ class _CollectionListPageState extends State<CollectionListPage> {
),
child: Row(
children: [
+ IconButtonWidget(
+ icon: albumViewType == AlbumViewType.grid
+ ? Icons.view_list_outlined
+ : Icons.grid_view_outlined,
+ iconButtonType: IconButtonType.secondary,
+ onTap: () async {
+ setState(() {
+ albumViewType = albumViewType == AlbumViewType.grid
+ ? AlbumViewType.list
+ : AlbumViewType.grid;
+ });
+ await localSettings.setAlbumViewType(albumViewType!);
+ },
+ ),
+ const SizedBox(width: 8),
GestureDetector(
onTapDown: (TapDownDetails details) async {
final int? selectedValue = await showMenu<int>(
diff --git a/mobile/lib/utils/local_settings.dart b/mobile/lib/utils/local_settings.dart
index 9fcd9e9adc..3b67adf279 100644
--- a/mobile/lib/utils/local_settings.dart
+++ b/mobile/lib/utils/local_settings.dart
@@ -8,6 +8,11 @@ enum AlbumSortKey {
lastUpdated,
}
+enum AlbumViewType {
+ grid,
+ list,
+}
+
class LocalSettings {
static const kCollectionSortPref = "collection_sort_pref";
static const kPhotoGridSize = "photo_grid_size";
@@ -22,6 +27,7 @@ class LocalSettings {
"has_configured_links_in_app_permission";
static const _hideSharedItemsFromHomeGalleryTag =
"hide_shared_items_from_home_gallery";
+ static const kCollectionViewType = "collection_view_type";
final SharedPreferences _prefs;
@@ -35,6 +41,15 @@ class LocalSettings {
return _prefs.setInt(kCollectionSortPref, key.index);
}
+ Future<void> setAlbumViewType(AlbumViewType viewType) async {
+ await _prefs.setInt(kCollectionViewType, viewType.index);
+ }
+
+ AlbumViewType albumViewType() {
+ final index = _prefs.getInt(kCollectionViewType) ?? 0;
+ return AlbumViewType.values[index];
+ }
+
int getPhotoGridSize() {
if (_prefs.containsKey(kPhotoGridSize)) {
return _prefs.getInt(kPhotoGridSize)!;