Просмотр исходного кода

Expand the range of photo grid size

vishnukvmd 2 лет назад
Родитель
Сommit
fcb9924bfe

+ 3 - 1
lib/core/constants.dart

@@ -15,7 +15,9 @@ const int jan011981Time = 347155200000000;
 const int galleryLoadStartTime = -8000000000000000; // Wednesday, March 6, 1748
 const int galleryLoadEndTime = 9223372036854775807; // 2^63 -1
 const int batchSize = 1000;
-const defaultPhotoGridSize = 4;
+const photoGridSizeDefault = 4;
+const photoGridSizeMin = 2;
+const photoGridSizeMax = 6;
 
 // used to identify which ente file are available in app cache
 // todo: 6Jun22: delete old media identifier after 3 months

+ 11 - 9
lib/ui/advanced_settings_screen.dart

@@ -1,5 +1,6 @@
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
+import 'package:photos/core/constants.dart';
 import 'package:photos/core/event_bus.dart';
 import 'package:photos/events/force_reload_home_gallery_event.dart';
 import 'package:photos/theme/ente_theme.dart';
@@ -99,15 +100,16 @@ class _AdvancedSettingsScreenState extends State<AdvancedSettingsScreen> {
   Future<void> _showPhotoGridSizePicker() async {
     final textTheme = getEnteTextTheme(context);
     final List<Text> options = [];
-    options.add(
-      Text("2", style: textTheme.body),
-    );
-    options.add(
-      Text("3", style: textTheme.body),
-    );
-    options.add(
-      Text("4", style: textTheme.body),
-    );
+    for (int gridSize = photoGridSizeMin;
+        gridSize <= photoGridSizeMax;
+        gridSize++) {
+      options.add(
+        Text(
+          gridSize.toString(),
+          style: textTheme.body,
+        ),
+      );
+    }
     return showCupertinoModalPopup(
       context: context,
       builder: (context) {

+ 1 - 1
lib/ui/huge_listview/lazy_loading_gallery.dart

@@ -434,7 +434,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
                   shouldShowLivePhotoOverlay: true,
                   key: Key(widget.tag + file.tag),
                   thumbnailSize: LocalSettings.instance.getPhotoGridSize() <
-                          defaultPhotoGridSize
+                          photoGridSizeDefault
                       ? thumbnailLargeSize
                       : thumbnailSmallSize,
                 ),

+ 1 - 1
lib/utils/local_settings.dart

@@ -32,7 +32,7 @@ class LocalSettings {
     if (_prefs.containsKey(kPhotoGridSize)) {
       return _prefs.getInt(kPhotoGridSize)!;
     } else {
-      return defaultPhotoGridSize;
+      return photoGridSizeDefault;
     }
   }