π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Support limitSelectionToOne and showSelect all on new gallery
ashilkn3fdb906834c2
diff --git a/mobile/apps/photos/lib/models/gallery/gallery_sections.dart b/mobile/apps/photos/lib/models/gallery/gallery_sections.dartindex 34d8fa79c6..9ea2135e2c 100644--- a/mobile/apps/photos/lib/models/gallery/gallery_sections.dart+++ b/mobile/apps/photos/lib/models/gallery/gallery_sections.dart@@ -23,7 +23,7 @@ class GalleryGroups {final SelectedFiles? selectedFiles;final bool limitSelectionToOne;final String tagPrefix;- final bool showSelectAllByDefault;+ final bool showSelectAll;final _logger = Logger("GalleryGroups");//TODO: Add support for sort order@@ -40,7 +40,7 @@ class GalleryGroups {/// Should be GroupGallery.spacing if GroupType.showGroupHeader() is false.required this.groupHeaderExtent,- required this.showSelectAllByDefault,+ required this.showSelectAll,this.limitSelectionToOne = false,}) {init();@@ -135,7 +135,7 @@ class GalleryGroups {gridSize: crossAxisCount,filesInGroup: groupIDToFilesMap[groupID]!,selectedFiles: selectedFiles,- showSelectAllByDefault: showSelectAllByDefault,+ showSelectAll: showSelectAll && !limitSelectionToOne,);} else {return const SizedBox(height: spacing);diff --git a/mobile/apps/photos/lib/ui/map/map_pull_up_gallery.dart b/mobile/apps/photos/lib/ui/map/map_pull_up_gallery.dartindex 6cb6ea04b0..56bb05c53b 100644--- a/mobile/apps/photos/lib/ui/map/map_pull_up_gallery.dart+++ b/mobile/apps/photos/lib/ui/map/map_pull_up_gallery.dart@@ -183,7 +183,7 @@ class _MapPullUpGalleryState extends State<MapPullUpGallery> {EventType.deletedFromEverywhere,},tagPrefix: "map_gallery",- showSelectAllByDefault: true,+ showSelectAll: true,selectedFiles: _selectedFiles,isScrollablePositionedList: false,),diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dartindex aff40ef777..ebcf5de96d 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart@@ -93,7 +93,7 @@ class CollectionPage extends StatelessWidget {initialFiles: initialFiles,albumName: c.collection.displayName,sortAsyncFn: () => c.collection.pubMagicMetadata.asc ?? false,- showSelectAllByDefault: galleryType != GalleryType.sharedCollection,+ showSelectAll: galleryType != GalleryType.sharedCollection,emptyState: galleryType == GalleryType.ownedCollection? EmptyAlbumState(c.collection,diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/component/group/group_header_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/component/group/group_header_widget.dartindex 15574d6cf6..e08f724962 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/component/group/group_header_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/component/group/group_header_widget.dart@@ -11,7 +11,7 @@ class GroupHeaderWidget extends StatefulWidget {final double? height;final List<EnteFile> filesInGroup;final SelectedFiles? selectedFiles;- final bool showSelectAllByDefault;+ final bool showSelectAll;const GroupHeaderWidget({super.key,@@ -19,7 +19,7 @@ class GroupHeaderWidget extends StatefulWidget {required this.gridSize,required this.filesInGroup,required this.selectedFiles,- required this.showSelectAllByDefault,+ required this.showSelectAll,this.height,});@@ -28,7 +28,6 @@ class GroupHeaderWidget extends StatefulWidget {}class _GroupHeaderWidgetState extends State<GroupHeaderWidget> {- late final ValueNotifier<bool> _showSelectAllButtonNotifier;late final ValueNotifier<bool> _areAllFromGroupSelectedNotifier;@override@@ -38,13 +37,11 @@ class _GroupHeaderWidgetState extends State<GroupHeaderWidget> {ValueNotifier(_areAllFromGroupSelected());widget.selectedFiles?.addListener(_selectedFilesListener);- _showSelectAllButtonNotifier = ValueNotifier(widget.showSelectAllByDefault);}@overridevoid dispose() {_areAllFromGroupSelectedNotifier.dispose();- _showSelectAllButtonNotifier.dispose();widget.selectedFiles?.removeListener(_selectedFilesListener);super.dispose();}@@ -82,37 +79,31 @@ class _GroupHeaderWidgetState extends State<GroupHeaderWidget> {),),Expanded(child: Container()),- ValueListenableBuilder(- valueListenable: _showSelectAllButtonNotifier,- builder: (context, value, _) {- return !value- ? const SizedBox.shrink()- : GestureDetector(- behavior: HitTestBehavior.translucent,- child: ValueListenableBuilder(- valueListenable: _areAllFromGroupSelectedNotifier,- builder: (context, dynamic value, _) {- return value- ? const Icon(- Icons.check_circle,- size: 18,- )- : Icon(- Icons.check_circle_outlined,- color:- getEnteColorScheme(context).strokeMuted,- size: 18,- );- },- ),- onTap: () {- widget.selectedFiles?.toggleGroupSelection(- widget.filesInGroup.toSet(),- );- },+ !widget.showSelectAll+ ? const SizedBox.shrink()+ : GestureDetector(+ behavior: HitTestBehavior.translucent,+ child: ValueListenableBuilder(+ valueListenable: _areAllFromGroupSelectedNotifier,+ builder: (context, dynamic value, _) {+ return value+ ? const Icon(+ Icons.check_circle,+ size: 18,+ )+ : Icon(+ Icons.check_circle_outlined,+ color: getEnteColorScheme(context).strokeMuted,+ size: 18,+ );+ },+ ),+ onTap: () {+ widget.selectedFiles?.toggleGroupSelection(+ widget.filesInGroup.toSet(),);- },- ),+ },+ ),],),),@@ -123,13 +114,6 @@ class _GroupHeaderWidgetState extends State<GroupHeaderWidget> {if (widget.selectedFiles == null) return;_areAllFromGroupSelectedNotifier.value =widget.selectedFiles!.files.containsAll(widget.filesInGroup.toSet());-- //Can remove this if we decide to show select all by default for all galleries- if (widget.selectedFiles!.files.isEmpty && !widget.showSelectAllByDefault) {- _showSelectAllButtonNotifier.value = false;- } else {- _showSelectAllButtonNotifier.value = true;- }}bool _areAllFromGroupSelected() {diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dartindex 1550c680fa..25ccdfc54e 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart@@ -67,7 +67,7 @@ class Gallery extends StatefulWidget {/// make selection possible without long pressing. If a gallery has selected/// files, it's not necessary that this will be true.final bool inSelectionMode;- final bool showSelectAllByDefault;+ final bool showSelectAll;final bool isScrollablePositionedList;// add a Function variable to get sort value in bool@@ -93,7 +93,7 @@ class Gallery extends StatefulWidget {this.limitSelectionToOne = false,this.inSelectionMode = false,this.sortAsyncFn,- this.showSelectAllByDefault = true,+ this.showSelectAll = true,this.isScrollablePositionedList = true,this.reloadDebounceTime = const Duration(milliseconds: 500),this.reloadDebounceExecutionInterval = const Duration(seconds: 2),@@ -137,6 +137,11 @@ class GalleryState extends State<Gallery> {"Gallery_${widget.tagPrefix}${kDebugMode ? "_" + widget.albumName! : ""}_x";_logger = Logger(_logTag);_logger.info("init Gallery");++ if (widget.limitSelectionToOne) {+ assert(widget.showSelectAll == false);+ }+_setGroupType();_debouncer = Debouncer(widget.reloadDebounceTime,@@ -222,7 +227,7 @@ class GalleryState extends State<Gallery> {gridSize: localSettings.getPhotoGridSize(),filesInGroup: const [],selectedFiles: null,- showSelectAllByDefault: false,+ showSelectAll: false,),context,).then((size) {@@ -452,7 +457,8 @@ class GalleryState extends State<Gallery> {selectedFiles: widget.selectedFiles,tagPrefix: widget.tagPrefix,groupHeaderExtent: groupHeaderExtent!,- showSelectAllByDefault: widget.showSelectAllByDefault,+ showSelectAll: widget.showSelectAll,+ limitSelectionToOne: widget.limitSelectionToOne,);GalleryFilesState.of(context).setGalleryFiles = _allGalleryFiles;if (!_hasLoadedFiles) {@@ -551,8 +557,8 @@ class GalleryState extends State<Gallery> {galleryGroups: galleryGroups,headerHeightNotifier: _headerHeightNotifier,selectedFiles: widget.selectedFiles,- showSelectAllByDefault:- widget.showSelectAllByDefault,+ showSelectAll: widget.showSelectAll &&+ !widget.limitSelectionToOne,scrollbarInUseNotifier: scrollBarInUseNotifier,): const SizedBox.shrink(),@@ -630,7 +636,7 @@ class PinnedGroupHeader extends StatefulWidget {final GalleryGroups galleryGroups;final ValueNotifier<double?> headerHeightNotifier;final SelectedFiles? selectedFiles;- final bool showSelectAllByDefault;+ final bool showSelectAll;final ValueNotifier<bool> scrollbarInUseNotifier;const PinnedGroupHeader({@@ -638,7 +644,7 @@ class PinnedGroupHeader extends StatefulWidget {required this.galleryGroups,required this.headerHeightNotifier,required this.selectedFiles,- required this.showSelectAllByDefault,+ required this.showSelectAll,required this.scrollbarInUseNotifier,super.key,});@@ -810,7 +816,7 @@ class _PinnedGroupHeaderState extends State<PinnedGroupHeader> {filesInGroup: widget.galleryGroups.groupIDToFilesMap[currentGroupId!]!,selectedFiles: widget.selectedFiles,- showSelectAllByDefault: widget.showSelectAllByDefault,+ showSelectAll: widget.showSelectAll,),),),diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/add_photos_sheet.dartindex 865c16378a..245530dfbc 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart@@ -309,7 +309,7 @@ class _DelayedGalleryState extends State<DelayedGallery> {},tagPrefix: "pick_add_photos_gallery",selectedFiles: widget.selectedFiles,- showSelectAllByDefault: true,+ showSelectAll: true,sortAsyncFn: () => false,).animate().fadeIn(duration: const Duration(milliseconds: 175),diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_cover_photo.dart b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_cover_photo.dartindex 4a0b116ff7..6fe52a232c 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_cover_photo.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_cover_photo.dart@@ -118,7 +118,7 @@ class PickCoverPhotoWidget extends StatelessWidget {tagPrefix: "pick_center_point_gallery",selectedFiles: selectedFiles,limitSelectionToOne: true,- showSelectAllByDefault: false,+ showSelectAll: false,sortAsyncFn: () =>collection.pubMagicMetadata.asc ?? false,),diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_person_avatar.dart b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_person_avatar.dartindex 1adecdee72..c432fad5b9 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_person_avatar.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_person_avatar.dart@@ -119,7 +119,7 @@ class PickPersonCoverPhotoWidget extends StatelessWidget {tagPrefix: "pick_center_point_gallery",selectedFiles: selectedFiles,limitSelectionToOne: true,- showSelectAllByDefault: false,+ showSelectAll: false,),),),diff --git a/mobile/apps/photos/lib/ui/viewer/location/dynamic_location_gallery_widget.dart b/mobile/apps/photos/lib/ui/viewer/location/dynamic_location_gallery_widget.dartindex 0c7f9c1650..26042f0e79 100644--- a/mobile/apps/photos/lib/ui/viewer/location/dynamic_location_gallery_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/location/dynamic_location_gallery_widget.dart@@ -115,7 +115,7 @@ class _DynamicLocationGalleryWidgetState},tagPrefix: widget.tagPrefix,enableFileGrouping: false,- showSelectAllByDefault: false,+ showSelectAll: false,),),);diff --git a/mobile/apps/photos/lib/ui/viewer/location/pick_center_point_widget.dart b/mobile/apps/photos/lib/ui/viewer/location/pick_center_point_widget.dartindex 637476166a..6e4243abe0 100644--- a/mobile/apps/photos/lib/ui/viewer/location/pick_center_point_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/location/pick_center_point_widget.dart@@ -115,7 +115,7 @@ class PickCenterPointWidget extends StatelessWidget {tagPrefix: "pick_center_point_gallery",selectedFiles: selectedFiles,limitSelectionToOne: true,- showSelectAllByDefault: false,+ showSelectAll: false,header: const Padding(padding: EdgeInsets.all(10),child: NotificationTipWidget(