Browse Source

Always break into sub-galleries with a number that's divisible by the photo-grid-size

vishnukvmd 2 years ago
parent
commit
d3672375f9
2 changed files with 5 additions and 8 deletions
  1. 1 2
      lib/core/constants.dart
  2. 4 6
      lib/ui/huge_listview/lazy_loading_gallery.dart

+ 1 - 2
lib/core/constants.dart

@@ -18,8 +18,7 @@ const int batchSize = 1000;
 const photoGridSizeDefault = 4;
 const photoGridSizeMin = 2;
 const photoGridSizeMax = 6;
-const subGalleryLimitDefault = 80;
-const subGalleryLimitMin = 40;
+const subGalleryMultiplier = 10;
 
 // used to identify which ente file are available in app cache
 // todo: 6Jun22: delete old media identifier after 3 months

+ 4 - 6
lib/ui/huge_listview/lazy_loading_gallery.dart

@@ -32,7 +32,7 @@ class LazyLoadingGallery extends StatefulWidget {
   final String tag;
   final String? logTag;
   final Stream<int> currentIndexStream;
-  final int? photoGirdSize;
+  final int photoGirdSize;
 
   LazyLoadingGallery(
     this.files,
@@ -190,7 +190,7 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
             getDayWidget(
               context,
               _files[0].creationTime!,
-              widget.photoGirdSize!,
+              widget.photoGirdSize,
             ),
             ValueListenableBuilder(
               valueListenable: _showSelectAllButton,
@@ -234,7 +234,7 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
             ? _getGallery()
             : PlaceHolderWidget(
                 _files.length,
-                widget.photoGirdSize!,
+                widget.photoGirdSize,
               ),
       ],
     );
@@ -242,9 +242,7 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
 
   Widget _getGallery() {
     final List<Widget> childGalleries = [];
-    final subGalleryItemLimit = widget.photoGirdSize! < photoGridSizeDefault
-        ? subGalleryLimitMin
-        : subGalleryLimitDefault;
+    final subGalleryItemLimit = widget.photoGirdSize * subGalleryMultiplier;
     for (int index = 0; index < _files.length; index += subGalleryItemLimit) {
       childGalleries.add(
         LazyLoadingGridView(