Sfoglia il codice sorgente

Show select all by default (#1203)

Ashil 2 anni fa
parent
commit
c26be31cba

+ 4 - 3
lib/ui/viewer/gallery/collection_page.dart

@@ -41,7 +41,7 @@ class CollectionPage extends StatelessWidget {
       return const EmptyState();
       return const EmptyState();
     }
     }
 
 
-    final appBarTypeValue = _getGalleryType(c.collection);
+    final galleryType = _getGalleryType(c.collection);
     final List<File>? initialFiles =
     final List<File>? initialFiles =
         c.thumbnail != null ? [c.thumbnail!] : null;
         c.thumbnail != null ? [c.thumbnail!] : null;
     final gallery = Gallery(
     final gallery = Gallery(
@@ -83,12 +83,13 @@ class CollectionPage extends StatelessWidget {
       initialFiles: initialFiles,
       initialFiles: initialFiles,
       albumName: c.collection.displayName,
       albumName: c.collection.displayName,
       sortAsyncFn: () => c.collection.pubMagicMetadata.asc ?? false,
       sortAsyncFn: () => c.collection.pubMagicMetadata.asc ?? false,
+      showSelectAllByDefault: galleryType != GalleryType.sharedCollection,
     );
     );
     return Scaffold(
     return Scaffold(
       appBar: PreferredSize(
       appBar: PreferredSize(
         preferredSize: const Size.fromHeight(50.0),
         preferredSize: const Size.fromHeight(50.0),
         child: GalleryAppBarWidget(
         child: GalleryAppBarWidget(
-          appBarTypeValue,
+          galleryType,
           c.collection.displayName,
           c.collection.displayName,
           _selectedFiles,
           _selectedFiles,
           collection: c.collection,
           collection: c.collection,
@@ -99,7 +100,7 @@ class CollectionPage extends StatelessWidget {
         children: [
         children: [
           gallery,
           gallery,
           FileSelectionOverlayBar(
           FileSelectionOverlayBar(
-            appBarTypeValue,
+            galleryType,
             _selectedFiles,
             _selectedFiles,
             collection: c.collection,
             collection: c.collection,
           )
           )

+ 7 - 4
lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart

@@ -27,6 +27,7 @@ class LazyGroupGallery extends StatefulWidget {
   final int photoGridSize;
   final int photoGridSize;
   final bool enableFileGrouping;
   final bool enableFileGrouping;
   final bool limitSelectionToOne;
   final bool limitSelectionToOne;
+  final bool showSelectAllByDefault;
   LazyGroupGallery(
   LazyGroupGallery(
     this.files,
     this.files,
     this.index,
     this.index,
@@ -36,7 +37,8 @@ class LazyGroupGallery extends StatefulWidget {
     this.selectedFiles,
     this.selectedFiles,
     this.tag,
     this.tag,
     this.currentIndexStream,
     this.currentIndexStream,
-    this.enableFileGrouping, {
+    this.enableFileGrouping,
+    this.showSelectAllByDefault, {
     this.logTag = "",
     this.logTag = "",
     this.photoGridSize = photoGridSizeDefault,
     this.photoGridSize = photoGridSizeDefault,
     this.limitSelectionToOne = false,
     this.limitSelectionToOne = false,
@@ -57,14 +59,15 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
   late StreamSubscription<int> _currentIndexSubscription;
   late StreamSubscription<int> _currentIndexSubscription;
   bool? _shouldRender;
   bool? _shouldRender;
   final ValueNotifier<bool> _toggleSelectAllFromDay = ValueNotifier(false);
   final ValueNotifier<bool> _toggleSelectAllFromDay = ValueNotifier(false);
-  final ValueNotifier<bool> _showSelectAllButton = ValueNotifier(false);
+  late final ValueNotifier<bool> _showSelectAllButton;
   final ValueNotifier<bool> _areAllFromDaySelected = ValueNotifier(false);
   final ValueNotifier<bool> _areAllFromDaySelected = ValueNotifier(false);
 
 
   @override
   @override
   void initState() {
   void initState() {
     //this is for removing the 'select all from day' icon on unselecting all files with 'cancel'
     //this is for removing the 'select all from day' icon on unselecting all files with 'cancel'
-    widget.selectedFiles?.addListener(_selectedFilesListener);
     super.initState();
     super.initState();
+    widget.selectedFiles?.addListener(_selectedFilesListener);
+    _showSelectAllButton = ValueNotifier(widget.showSelectAllByDefault);
     _init();
     _init();
   }
   }
 
 
@@ -223,7 +226,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
   }
   }
 
 
   void _selectedFilesListener() {
   void _selectedFilesListener() {
-    if (widget.selectedFiles!.files.isEmpty) {
+    if (widget.selectedFiles!.files.isEmpty && !widget.showSelectAllByDefault) {
       _showSelectAllButton.value = false;
       _showSelectAllButton.value = false;
     } else {
     } else {
       _showSelectAllButton.value = true;
       _showSelectAllButton.value = true;

+ 3 - 0
lib/ui/viewer/gallery/component/multiple_groups_gallery_view.dart

@@ -39,6 +39,7 @@ class MultipleGroupsGalleryView extends StatelessWidget {
   final bool enableFileGrouping;
   final bool enableFileGrouping;
   final String logTag;
   final String logTag;
   final Logger logger;
   final Logger logger;
+  final bool showSelectAllByDefault;
 
 
   const MultipleGroupsGalleryView({
   const MultipleGroupsGalleryView({
     required this.hugeListViewKey,
     required this.hugeListViewKey,
@@ -58,6 +59,7 @@ class MultipleGroupsGalleryView extends StatelessWidget {
     required this.enableFileGrouping,
     required this.enableFileGrouping,
     required this.logTag,
     required this.logTag,
     required this.logger,
     required this.logger,
+    required this.showSelectAllByDefault,
     super.key,
     super.key,
   });
   });
 
 
@@ -106,6 +108,7 @@ class MultipleGroupsGalleryView extends StatelessWidget {
               .where((event) => event.tag == tagPrefix)
               .where((event) => event.tag == tagPrefix)
               .map((event) => event.index),
               .map((event) => event.index),
           enableFileGrouping,
           enableFileGrouping,
+          showSelectAllByDefault,
           logTag: logTag,
           logTag: logTag,
           photoGridSize: LocalSettings.instance.getPhotoGridSize(),
           photoGridSize: LocalSettings.instance.getPhotoGridSize(),
           limitSelectionToOne: limitSelectionToOne,
           limitSelectionToOne: limitSelectionToOne,

+ 3 - 0
lib/ui/viewer/gallery/gallery.dart

@@ -45,6 +45,7 @@ class Gallery extends StatefulWidget {
   final Widget loadingWidget;
   final Widget loadingWidget;
   final bool disableScroll;
   final bool disableScroll;
   final bool limitSelectionToOne;
   final bool limitSelectionToOne;
+  final bool showSelectAllByDefault;
 
 
   // add a Function variable to get sort value in bool
   // add a Function variable to get sort value in bool
   final SortAscFn? sortAsyncFn;
   final SortAscFn? sortAsyncFn;
@@ -67,6 +68,7 @@ class Gallery extends StatefulWidget {
     this.disableScroll = false,
     this.disableScroll = false,
     this.limitSelectionToOne = false,
     this.limitSelectionToOne = false,
     this.sortAsyncFn,
     this.sortAsyncFn,
+    this.showSelectAllByDefault = true,
     Key? key,
     Key? key,
   }) : super(key: key);
   }) : super(key: key);
 
 
@@ -239,6 +241,7 @@ class _GalleryState extends State<Gallery> {
         header: widget.header,
         header: widget.header,
         footer: widget.footer,
         footer: widget.footer,
         selectedFiles: widget.selectedFiles,
         selectedFiles: widget.selectedFiles,
+        showSelectAllByDefault: widget.showSelectAllByDefault,
       ),
       ),
     );
     );
   }
   }