diff --git a/mobile/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart b/mobile/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart index 7195648dbe..b844249c3e 100644 --- a/mobile/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart +++ b/mobile/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart @@ -14,7 +14,6 @@ import "package:photos/ui/viewer/gallery/component/group/group_header_widget.dar import "package:photos/ui/viewer/gallery/component/group/type.dart"; import 'package:photos/ui/viewer/gallery/gallery.dart'; import "package:photos/ui/viewer/gallery/state/gallery_context_state.dart"; -import "package:photos/ui/viewer/gallery/swipe_to_select_helper.dart"; class LazyGroupGallery extends StatefulWidget { final List files; @@ -234,41 +233,21 @@ class _LazyGroupGalleryState extends State { ), ], ), - widget.selectedFiles != null - ? SwipeToSelectHelper( + _shouldRender! + ? GroupGallery( + photoGridSize: widget.photoGridSize, files: _filesInGroup, - selectedFiles: widget.selectedFiles!, - child: _shouldRender! - ? GroupGallery( - photoGridSize: widget.photoGridSize, - files: _filesInGroup, - tag: widget.tag, - asyncLoader: widget.asyncLoader, - selectedFiles: widget.selectedFiles, - limitSelectionToOne: widget.limitSelectionToOne, - ) - // todo: perf eval should we have separate PlaceHolder for Groups - // instead of creating a large cached view - : PlaceHolderGridViewWidget( - _filesInGroup.length, - widget.photoGridSize, - ), + tag: widget.tag, + asyncLoader: widget.asyncLoader, + selectedFiles: widget.selectedFiles, + limitSelectionToOne: widget.limitSelectionToOne, ) - : _shouldRender! - ? GroupGallery( - photoGridSize: widget.photoGridSize, - files: _filesInGroup, - tag: widget.tag, - asyncLoader: widget.asyncLoader, - selectedFiles: widget.selectedFiles, - limitSelectionToOne: widget.limitSelectionToOne, - ) - // todo: perf eval should we have separate PlaceHolder for Groups - // instead of creating a large cached view - : PlaceHolderGridViewWidget( - _filesInGroup.length, - widget.photoGridSize, - ), + // todo: perf eval should we have separate PlaceHolder for Groups + // instead of creating a large cached view + : PlaceHolderGridViewWidget( + _filesInGroup.length, + widget.photoGridSize, + ), ], ); } diff --git a/mobile/lib/ui/viewer/gallery/gallery.dart b/mobile/lib/ui/viewer/gallery/gallery.dart index 3155617060..130e2fdbd2 100644 --- a/mobile/lib/ui/viewer/gallery/gallery.dart +++ b/mobile/lib/ui/viewer/gallery/gallery.dart @@ -17,6 +17,7 @@ import "package:photos/ui/viewer/gallery/component/multiple_groups_gallery_view. import 'package:photos/ui/viewer/gallery/empty_state.dart'; import "package:photos/ui/viewer/gallery/state/gallery_context_state.dart"; import "package:photos/ui/viewer/gallery/state/selection_state.dart"; +import "package:photos/ui/viewer/gallery/swipe_to_select_helper.dart"; import "package:photos/utils/debouncer.dart"; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; @@ -258,27 +259,31 @@ class GalleryState extends State { sortOrderAsc: _sortOrderAsc, inSelectionMode: widget.inSelectionMode, type: widget.groupType, - child: MultipleGroupsGalleryView( - itemScroller: _itemScroller, - groupedFiles: currentGroupedFiles, - disableScroll: widget.disableScroll, - emptyState: widget.emptyState, - asyncLoader: widget.asyncLoader, - removalEventTypes: widget.removalEventTypes, - tagPrefix: widget.tagPrefix, - scrollBottomSafeArea: widget.scrollBottomSafeArea, - limitSelectionToOne: widget.limitSelectionToOne, - enableFileGrouping: - widget.enableFileGrouping && widget.groupType.showGroupHeader(), - logTag: _logTag, - logger: _logger, - reloadEvent: widget.reloadEvent, - header: widget.header, - footer: widget.footer, + child: SwipeToSelectHelper( + files: currentGroupedFiles.expand((element) => element).toList(), selectedFiles: widget.selectedFiles, - showSelectAllByDefault: - widget.showSelectAllByDefault && widget.groupType.showGroupHeader(), - isScrollablePositionedList: widget.isScrollablePositionedList, + child: MultipleGroupsGalleryView( + itemScroller: _itemScroller, + groupedFiles: currentGroupedFiles, + disableScroll: widget.disableScroll, + emptyState: widget.emptyState, + asyncLoader: widget.asyncLoader, + removalEventTypes: widget.removalEventTypes, + tagPrefix: widget.tagPrefix, + scrollBottomSafeArea: widget.scrollBottomSafeArea, + limitSelectionToOne: widget.limitSelectionToOne, + enableFileGrouping: + widget.enableFileGrouping && widget.groupType.showGroupHeader(), + logTag: _logTag, + logger: _logger, + reloadEvent: widget.reloadEvent, + header: widget.header, + footer: widget.footer, + selectedFiles: widget.selectedFiles, + showSelectAllByDefault: widget.showSelectAllByDefault && + widget.groupType.showGroupHeader(), + isScrollablePositionedList: widget.isScrollablePositionedList, + ), ), ); } diff --git a/mobile/lib/ui/viewer/gallery/swipe_to_select_helper.dart b/mobile/lib/ui/viewer/gallery/swipe_to_select_helper.dart index 28a56709c2..5e3d24fe2a 100644 --- a/mobile/lib/ui/viewer/gallery/swipe_to_select_helper.dart +++ b/mobile/lib/ui/viewer/gallery/swipe_to_select_helper.dart @@ -8,7 +8,7 @@ import "package:photos/ui/viewer/gallery/component/group/lazy_group_gallery.dart class SwipeToSelectHelper extends StatefulWidget { final List files; - final SelectedFiles selectedFiles; + final SelectedFiles? selectedFiles; final Widget child; const SwipeToSelectHelper({ required this.files, @@ -26,24 +26,26 @@ class _SwipeToSelectHelperState extends State { @override Widget build(BuildContext context) { - return LastSelectedFileByDragging( - filesInGroup: widget.files, - child: Builder( - builder: (context) { - return SelectionGesturesEventProvider( - selectedFiles: widget.selectedFiles, - files: widget.files, - child: GroupGalleryGlobalKey( - globalKey: _groupGalleryGlobalKey, - child: SizedBox( - key: _groupGalleryGlobalKey, - child: widget.child, - ), + return widget.selectedFiles == null + ? widget.child + : LastSelectedFileByDragging( + filesInGroup: widget.files, + child: Builder( + builder: (context) { + return SelectionGesturesEventProvider( + selectedFiles: widget.selectedFiles!, + files: widget.files, + child: GroupGalleryGlobalKey( + globalKey: _groupGalleryGlobalKey, + child: SizedBox( + key: _groupGalleryGlobalKey, + child: widget.child, + ), + ), + ); + }, ), ); - }, - ), - ); } }