Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Create new inheirted widget to store all files in gallery and throw exception/assert to make sure it's never used incorrectly

ashilknc7a4cbc3656f
diff --git a/mobile/lib/ui/home/home_gallery_widget.dart b/mobile/lib/ui/home/home_gallery_widget.dart
index 7de93e71e7..aaac05504e 100644
--- a/mobile/lib/ui/home/home_gallery_widget.dart
+++ b/mobile/lib/ui/home/home_gallery_widget.dart
@@ -13,6 +13,7 @@ import 'package:photos/services/collections_service.dart';
import "package:photos/services/filter/db_filters.dart";
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class HomeGalleryWidget extends StatelessWidget {
@@ -21,11 +22,11 @@ class HomeGalleryWidget extends StatelessWidget {
final SelectedFiles selectedFiles;
const HomeGalleryWidget({
- Key? key,
+ super.key,
this.header,
this.footer,
required this.selectedFiles,
- }) : super(key: key);
+ });
@override
Widget build(BuildContext context) {
@@ -85,14 +86,16 @@ class HomeGalleryWidget extends StatelessWidget {
reloadDebounceTime: const Duration(seconds: 2),
reloadDebounceExecutionInterval: const Duration(seconds: 5),
);
- return SelectionState(
- selectedFiles: selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- gallery,
- FileSelectionOverlayBar(GalleryType.homepage, selectedFiles),
- ],
+ return GalleryFilesState(
+ child: SelectionState(
+ selectedFiles: selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ gallery,
+ FileSelectionOverlayBar(GalleryType.homepage, selectedFiles),
+ ],
+ ),
),
);
}
diff --git a/mobile/lib/ui/map/map_pull_up_gallery.dart b/mobile/lib/ui/map/map_pull_up_gallery.dart
index 22f1071888..b547d984dd 100644
--- a/mobile/lib/ui/map/map_pull_up_gallery.dart
+++ b/mobile/lib/ui/map/map_pull_up_gallery.dart
@@ -15,6 +15,7 @@ import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/common/loading_widget.dart";
import "package:photos/ui/viewer/actions/file_selection_overlay_bar.dart";
import "package:photos/ui/viewer/gallery/gallery.dart";
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class MapPullUpGallery extends StatefulWidget {
@@ -29,8 +30,8 @@ class MapPullUpGallery extends StatefulWidget {
this.visibleImages,
this.bottomSheetDraggableAreaHeight,
this.bottomUnsafeArea, {
- Key? key,
- }) : super(key: key);
+ super.key,
+ });
@override
State<MapPullUpGallery> createState() => _MapPullUpGalleryState();
@@ -49,40 +50,42 @@ class _MapPullUpGalleryState extends State<MapPullUpGallery> {
Widget? cachedScrollableContent;
return DeferredPointerHandler(
- child: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- clipBehavior: Clip.none,
- children: [
- DraggableScrollableSheet(
- expand: false,
- initialChildSize: initialChildSize,
- minChildSize: initialChildSize,
- maxChildSize: 0.8,
- snap: true,
- snapSizes: const [0.5],
- builder: (context, scrollController) {
- //Must use cached widget here to avoid rebuilds when DraggableScrollableSheet
- //is snapped to it's initialChildSize
- cachedScrollableContent ??=
- cacheScrollableContent(scrollController, context, logger);
- return cachedScrollableContent!;
- },
- ),
- DeferPointer(
- //This is to make the FileSelectionOverlayBar respect SafeArea
- child: MediaQuery(
- data: MediaQueryData.fromView(View.of(context)),
- child: FileSelectionOverlayBar(
- GalleryType.searchResults,
- _selectedFiles,
- backgroundColor:
- getEnteColorScheme(context).backgroundElevated2,
+ child: GalleryFilesState(
+ child: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ clipBehavior: Clip.none,
+ children: [
+ DraggableScrollableSheet(
+ expand: false,
+ initialChildSize: initialChildSize,
+ minChildSize: initialChildSize,
+ maxChildSize: 0.8,
+ snap: true,
+ snapSizes: const [0.5],
+ builder: (context, scrollController) {
+ //Must use cached widget here to avoid rebuilds when DraggableScrollableSheet
+ //is snapped to it's initialChildSize
+ cachedScrollableContent ??=
+ cacheScrollableContent(scrollController, context, logger);
+ return cachedScrollableContent!;
+ },
+ ),
+ DeferPointer(
+ //This is to make the FileSelectionOverlayBar respect SafeArea
+ child: MediaQuery(
+ data: MediaQueryData.fromView(View.of(context)),
+ child: FileSelectionOverlayBar(
+ GalleryType.searchResults,
+ _selectedFiles,
+ backgroundColor:
+ getEnteColorScheme(context).backgroundElevated2,
+ ),
),
),
- ),
- ],
+ ],
+ ),
),
),
);
diff --git a/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart
index fbc998110a..a6b98b4e7f 100644
--- a/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart
+++ b/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart
@@ -6,6 +6,7 @@ import 'package:photos/models/selected_files.dart';
import "package:photos/theme/effects.dart";
import "package:photos/theme/ente_theme.dart";
import 'package:photos/ui/components/bottom_action_bar/bottom_action_bar_widget.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class FileSelectionOverlayBar extends StatefulWidget {
@@ -23,8 +24,8 @@ class FileSelectionOverlayBar extends StatefulWidget {
this.backgroundColor,
this.person,
this.clusterID,
- Key? key,
- }) : super(key: key);
+ super.key,
+ });
@override
State<FileSelectionOverlayBar> createState() =>
@@ -136,6 +137,7 @@ class _SelectAllButtonState extends State<SelectAllButton> {
@override
Widget build(BuildContext context) {
final selectionState = SelectionState.of(context);
+ final allGalleryFiles = GalleryFilesState.of(context).galleryFiles;
assert(
selectionState != null,
"SelectionState not found in context, SelectionState should be an ancestor of FileSelectionOverlayBar",
@@ -147,8 +149,9 @@ class _SelectAllButtonState extends State<SelectAllButton> {
if (_allSelected) {
selectionState.selectedFiles.clearAll();
} else {
- selectionState.selectedFiles
- .selectAll(selectionState.allGalleryFiles!.toSet());
+ selectionState.selectedFiles.selectAll(
+ allGalleryFiles.toSet(),
+ );
}
_allSelected = !_allSelected;
});
@@ -181,7 +184,7 @@ class _SelectAllButtonState extends State<SelectAllButton> {
listenable: selectionState!.selectedFiles,
builder: (context, _) {
if (selectionState.selectedFiles.files.length ==
- selectionState.allGalleryFiles?.length) {
+ allGalleryFiles.length) {
_allSelected = true;
} else {
_allSelected = false;
diff --git a/mobile/lib/ui/viewer/gallery/archive_page.dart b/mobile/lib/ui/viewer/gallery/archive_page.dart
index 4f0a9502f6..d036485d3b 100644
--- a/mobile/lib/ui/viewer/gallery/archive_page.dart
+++ b/mobile/lib/ui/viewer/gallery/archive_page.dart
@@ -15,6 +15,7 @@ import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import "package:photos/ui/viewer/gallery/empty_state.dart";
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class ArchivePage extends StatelessWidget {
@@ -27,8 +28,8 @@ class ArchivePage extends StatelessWidget {
this.tagPrefix = "archived_page",
this.appBarType = GalleryType.archive,
this.overlayType = GalleryType.archive,
- Key? key,
- }) : super(key: key);
+ super.key,
+ });
@override
Widget build(BuildContext context) {
@@ -78,26 +79,28 @@ class ArchivePage extends StatelessWidget {
CollectionsService.instance.getArchivedCollection,
),
);
- return Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: GalleryAppBarWidget(
- appBarType,
- S.of(context).archive,
- _selectedFiles,
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: GalleryAppBarWidget(
+ appBarType,
+ S.of(context).archive,
+ _selectedFiles,
+ ),
),
- ),
- body: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- gallery,
- FileSelectionOverlayBar(
- overlayType,
- _selectedFiles,
- ),
- ],
+ body: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ gallery,
+ FileSelectionOverlayBar(
+ overlayType,
+ _selectedFiles,
+ ),
+ ],
+ ),
),
),
);
diff --git a/mobile/lib/ui/viewer/gallery/collection_page.dart b/mobile/lib/ui/viewer/gallery/collection_page.dart
index 5683c14b8a..fdfa8494f3 100644
--- a/mobile/lib/ui/viewer/gallery/collection_page.dart
+++ b/mobile/lib/ui/viewer/gallery/collection_page.dart
@@ -17,6 +17,7 @@ import "package:photos/ui/viewer/gallery/empty_album_state.dart";
import 'package:photos/ui/viewer/gallery/empty_state.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class CollectionPage extends StatelessWidget {
@@ -30,8 +31,8 @@ class CollectionPage extends StatelessWidget {
this.tagPrefix = "collection",
this.hasVerifiedLock = false,
this.isFromCollectPhotos = false,
- Key? key,
- }) : super(key: key);
+ super.key,
+ });
final _selectedFiles = SelectedFiles();
@@ -98,35 +99,37 @@ class CollectionPage extends StatelessWidget {
? const SizedBox(height: 20)
: const SizedBox(height: 212),
);
- return Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: GalleryAppBarWidget(
- galleryType,
- c.collection.displayName,
- _selectedFiles,
- collection: c.collection,
- isFromCollectPhotos: isFromCollectPhotos,
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: GalleryAppBarWidget(
+ galleryType,
+ c.collection.displayName,
+ _selectedFiles,
+ collection: c.collection,
+ isFromCollectPhotos: isFromCollectPhotos,
+ ),
),
- ),
- bottomNavigationBar: isFromCollectPhotos
- ? CollectPhotosBottomButtons(
- c.collection,
- selectedFiles: _selectedFiles,
- )
- : const SizedBox.shrink(),
- body: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- gallery,
- FileSelectionOverlayBar(
- galleryType,
- _selectedFiles,
- collection: c.collection,
- ),
- ],
+ bottomNavigationBar: isFromCollectPhotos
+ ? CollectPhotosBottomButtons(
+ c.collection,
+ selectedFiles: _selectedFiles,
+ )
+ : const SizedBox.shrink(),
+ body: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ gallery,
+ FileSelectionOverlayBar(
+ galleryType,
+ _selectedFiles,
+ collection: c.collection,
+ ),
+ ],
+ ),
),
),
);
diff --git a/mobile/lib/ui/viewer/gallery/device_folder_page.dart b/mobile/lib/ui/viewer/gallery/device_folder_page.dart
index b1a604ed02..0fbe5785db 100644
--- a/mobile/lib/ui/viewer/gallery/device_folder_page.dart
+++ b/mobile/lib/ui/viewer/gallery/device_folder_page.dart
@@ -22,13 +22,14 @@ import 'package:photos/ui/components/toggle_switch_widget.dart';
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class DeviceFolderPage extends StatelessWidget {
final DeviceCollection deviceCollection;
final _selectedFiles = SelectedFiles();
- DeviceFolderPage(this.deviceCollection, {Key? key}) : super(key: key);
+ DeviceFolderPage(this.deviceCollection, {super.key});
@override
Widget build(Object context) {
@@ -57,27 +58,29 @@ class DeviceFolderPage extends StatelessWidget {
: const SizedBox.shrink(),
initialFiles: [deviceCollection.thumbnail!],
);
- return Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: GalleryAppBarWidget(
- GalleryType.localFolder,
- deviceCollection.name,
- _selectedFiles,
- deviceCollection: deviceCollection,
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: GalleryAppBarWidget(
+ GalleryType.localFolder,
+ deviceCollection.name,
+ _selectedFiles,
+ deviceCollection: deviceCollection,
+ ),
),
- ),
- body: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- gallery,
- FileSelectionOverlayBar(
- GalleryType.localFolder,
- _selectedFiles,
- ),
- ],
+ body: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ gallery,
+ FileSelectionOverlayBar(
+ GalleryType.localFolder,
+ _selectedFiles,
+ ),
+ ],
+ ),
),
),
);
diff --git a/mobile/lib/ui/viewer/gallery/gallery.dart b/mobile/lib/ui/viewer/gallery/gallery.dart
index 4438a60f13..db2f1d2906 100644
--- a/mobile/lib/ui/viewer/gallery/gallery.dart
+++ b/mobile/lib/ui/viewer/gallery/gallery.dart
@@ -16,7 +16,7 @@ import "package:photos/ui/viewer/gallery/component/group/type.dart";
import "package:photos/ui/viewer/gallery/component/multiple_groups_gallery_view.dart";
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/state/gallery_files_inherited_widget.dart";
import "package:photos/utils/debouncer.dart";
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
@@ -88,8 +88,8 @@ class Gallery extends StatefulWidget {
this.isScrollablePositionedList = true,
this.reloadDebounceTime = const Duration(milliseconds: 500),
this.reloadDebounceExecutionInterval = const Duration(seconds: 2),
- Key? key,
- }) : super(key: key);
+ super.key,
+ });
@override
State<Gallery> createState() {
@@ -252,7 +252,7 @@ class GalleryState extends State<Gallery> {
@override
Widget build(BuildContext context) {
_logger.finest("Building Gallery ${widget.tagPrefix}");
- SelectionState.of(context)?.allGalleryFiles = _allFiles;
+ GalleryFilesState.of(context).setGalleryFiles = _allFiles;
if (!_hasLoadedFiles) {
return widget.loadingWidget;
}
diff --git a/mobile/lib/ui/viewer/gallery/hidden_page.dart b/mobile/lib/ui/viewer/gallery/hidden_page.dart
index 1517b07460..c9226c5cc2 100644
--- a/mobile/lib/ui/viewer/gallery/hidden_page.dart
+++ b/mobile/lib/ui/viewer/gallery/hidden_page.dart
@@ -19,6 +19,7 @@ import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import 'package:photos/ui/viewer/gallery/empty_hidden_widget.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class HiddenPage extends StatefulWidget {
@@ -30,8 +31,8 @@ class HiddenPage extends StatefulWidget {
this.tagPrefix = "hidden_page",
this.appBarType = GalleryType.hiddenSection,
this.overlayType = GalleryType.hiddenSection,
- Key? key,
- }) : super(key: key);
+ super.key,
+ });
@override
State<HiddenPage> createState() => _HiddenPageState();
@@ -131,26 +132,28 @@ class _HiddenPageState extends State<HiddenPage> {
hasVerifiedLock: true,
),
);
- return Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: GalleryAppBarWidget(
- widget.appBarType,
- S.of(context).hidden,
- _selectedFiles,
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: GalleryAppBarWidget(
+ widget.appBarType,
+ S.of(context).hidden,
+ _selectedFiles,
+ ),
),
- ),
- body: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- gallery,
- FileSelectionOverlayBar(
- widget.overlayType,
- _selectedFiles,
- ),
- ],
+ body: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ gallery,
+ FileSelectionOverlayBar(
+ widget.overlayType,
+ _selectedFiles,
+ ),
+ ],
+ ),
),
),
);
diff --git a/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart b/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart
index 573893b177..571b84424e 100644
--- a/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart
+++ b/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart
@@ -23,6 +23,7 @@ import "package:photos/ui/components/buttons/button_widget.dart";
import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/components/title_bar_title_widget.dart";
import "package:photos/ui/viewer/gallery/gallery.dart";
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/utils/dialog_util.dart";
import "package:photos/utils/photo_manager_util.dart";
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
@@ -279,36 +280,38 @@ class _DelayedGalleryState extends State<DelayedGallery> {
@override
Widget build(BuildContext context) {
if (_showGallery) {
- return Gallery(
- inSelectionMode: true,
- asyncLoader: (
- creationStartTime,
- creationEndTime, {
- limit,
- asc,
- }) {
- return FilesDB.instance.getAllPendingOrUploadedFiles(
+ return GalleryFilesState(
+ child: Gallery(
+ inSelectionMode: true,
+ asyncLoader: (
creationStartTime,
- creationEndTime,
- Configuration.instance.getUserID()!,
- limit: limit,
- asc: asc,
- filterOptions: DBFilterOptions(
- hideIgnoredForUpload: true,
- dedupeUploadID: true,
- ignoredCollectionIDs: widget.hiddenCollectionIDs,
+ creationEndTime, {
+ limit,
+ asc,
+ }) {
+ return FilesDB.instance.getAllPendingOrUploadedFiles(
+ creationStartTime,
+ creationEndTime,
+ Configuration.instance.getUserID()!,
+ limit: limit,
+ asc: asc,
+ filterOptions: DBFilterOptions(
+ hideIgnoredForUpload: true,
+ dedupeUploadID: true,
+ ignoredCollectionIDs: widget.hiddenCollectionIDs,
+ ),
+ applyOwnerCheck: true,
+ );
+ },
+ tagPrefix: "pick_add_photos_gallery",
+ selectedFiles: widget.selectedFiles,
+ showSelectAllByDefault: true,
+ sortAsyncFn: () => false,
+ ).animate().fadeIn(
+ duration: const Duration(milliseconds: 175),
+ curve: Curves.easeOutCirc,
),
- applyOwnerCheck: true,
- );
- },
- tagPrefix: "pick_add_photos_gallery",
- selectedFiles: widget.selectedFiles,
- showSelectAllByDefault: true,
- sortAsyncFn: () => false,
- ).animate().fadeIn(
- duration: const Duration(milliseconds: 175),
- curve: Curves.easeOutCirc,
- );
+ );
} else {
return const EnteLoadingWidget();
}
diff --git a/mobile/lib/ui/viewer/gallery/hooks/pick_cover_photo.dart b/mobile/lib/ui/viewer/gallery/hooks/pick_cover_photo.dart
index af9a3ab72e..57581f886f 100644
--- a/mobile/lib/ui/viewer/gallery/hooks/pick_cover_photo.dart
+++ b/mobile/lib/ui/viewer/gallery/hooks/pick_cover_photo.dart
@@ -17,6 +17,7 @@ import "package:photos/ui/components/buttons/button_widget.dart";
import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/components/title_bar_title_widget.dart";
import "package:photos/ui/viewer/gallery/gallery.dart";
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
Future<int?> showPickCoverPhotoSheet(
BuildContext context,
@@ -81,43 +82,46 @@ class PickCoverPhotoWidget extends StatelessWidget {
showCloseButton: true,
),
Expanded(
- child: Gallery(
- asyncLoader: (
- creationStartTime,
- creationEndTime, {
- limit,
- asc,
- }) async {
- final FileLoadResult result =
- await FilesDB.instance.getFilesInCollection(
- collection.id,
+ child: GalleryFilesState(
+ child: Gallery(
+ asyncLoader: (
creationStartTime,
- creationEndTime,
- limit: limit,
- asc: asc,
- );
- // hide ignored files from home page UI
- final ignoredIDs = await IgnoredFilesService
- .instance.idToIgnoreReasonMap;
- result.files.removeWhere(
- (f) =>
- f.uploadedFileID == null &&
- IgnoredFilesService.instance
- .shouldSkipUpload(ignoredIDs, f),
- );
- return result;
- },
- reloadEvent:
- Bus.instance.on<CollectionUpdatedEvent>().where(
- (event) =>
- event.collectionID == collection.id,
- ),
- tagPrefix: "pick_center_point_gallery",
- selectedFiles: selectedFiles,
- limitSelectionToOne: true,
- showSelectAllByDefault: false,
- sortAsyncFn: () =>
- collection.pubMagicMetadata.asc ?? false,
+ creationEndTime, {
+ limit,
+ asc,
+ }) async {
+ final FileLoadResult result =
+ await FilesDB.instance.getFilesInCollection(
+ collection.id,
+ creationStartTime,
+ creationEndTime,
+ limit: limit,
+ asc: asc,
+ );
+ // hide ignored files from home page UI
+ final ignoredIDs = await IgnoredFilesService
+ .instance.idToIgnoreReasonMap;
+ result.files.removeWhere(
+ (f) =>
+ f.uploadedFileID == null &&
+ IgnoredFilesService.instance
+ .shouldSkipUpload(ignoredIDs, f),
+ );
+ return result;
+ },
+ reloadEvent: Bus.instance
+ .on<CollectionUpdatedEvent>()
+ .where(
+ (event) =>
+ event.collectionID == collection.id,
+ ),
+ tagPrefix: "pick_center_point_gallery",
+ selectedFiles: selectedFiles,
+ limitSelectionToOne: true,
+ showSelectAllByDefault: false,
+ sortAsyncFn: () =>
+ collection.pubMagicMetadata.asc ?? false,
+ ),
),
),
],
diff --git a/mobile/lib/ui/viewer/gallery/large_files_page.dart b/mobile/lib/ui/viewer/gallery/large_files_page.dart
index 8668dfccae..057adb222b 100644
--- a/mobile/lib/ui/viewer/gallery/large_files_page.dart
+++ b/mobile/lib/ui/viewer/gallery/large_files_page.dart
@@ -13,6 +13,7 @@ import "package:photos/services/search_service.dart";
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
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_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class LargeFilesPagePage extends StatelessWidget {
@@ -26,8 +27,8 @@ class LargeFilesPagePage extends StatelessWidget {
this.tagPrefix = "Uncategorized_page",
this.appBarType = GalleryType.homepage,
this.overlayType = GalleryType.homepage,
- Key? key,
- }) : super(key: key);
+ super.key,
+ });
@override
Widget build(BuildContext context) {
@@ -68,34 +69,36 @@ class LargeFilesPagePage extends StatelessWidget {
initialFiles: null,
albumName: S.of(context).viewLargeFiles,
);
- return Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: AppBar(
- elevation: 0,
- centerTitle: false,
- title: Text(
- S.of(context).viewLargeFiles,
- style: Theme.of(context)
- .textTheme
- .headlineSmall!
- .copyWith(fontSize: 16),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: AppBar(
+ elevation: 0,
+ centerTitle: false,
+ title: Text(
+ S.of(context).viewLargeFiles,
+ style: Theme.of(context)
+ .textTheme
+ .headlineSmall!
+ .copyWith(fontSize: 16),
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ ),
),
),
- ),
- body: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- gallery,
- FileSelectionOverlayBar(
- overlayType,
- _selectedFiles,
- ),
- ],
+ body: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ gallery,
+ FileSelectionOverlayBar(
+ overlayType,
+ _selectedFiles,
+ ),
+ ],
+ ),
),
),
);
diff --git a/mobile/lib/ui/viewer/gallery/state/gallery_files_inherited_widget.dart b/mobile/lib/ui/viewer/gallery/state/gallery_files_inherited_widget.dart
new file mode 100644
index 0000000000..27ae8943b7
--- /dev/null
+++ b/mobile/lib/ui/viewer/gallery/state/gallery_files_inherited_widget.dart
@@ -0,0 +1,45 @@
+import "package:flutter/material.dart";
+import "package:photos/models/file/file.dart";
+
+// ignore: must_be_immutable
+class GalleryFilesState extends InheritedWidget {
+ GalleryFilesState({
+ super.key,
+ required super.child,
+ });
+
+ ///Should be assigned later in gallery when files are loaded.
+ ///Note: EnteFiles in this list should be references of the same EnteFiles
+ ///that are grouped in gallery, so that when files are added/deleted,
+ ///both lists are in sync.
+ List<EnteFile>? _galleryFiles;
+
+ set setGalleryFiles(List<EnteFile> galleryFiles) {
+ _galleryFiles = galleryFiles;
+ }
+
+ List<EnteFile> get galleryFiles {
+ if (_galleryFiles == null) {
+ throw Exception(
+ "Gallery files not set yet. Should be set in the gallery widget",
+ );
+ }
+ return _galleryFiles!;
+ }
+
+ static GalleryFilesState? maybeOf(BuildContext context) {
+ return context.dependOnInheritedWidgetOfExactType<GalleryFilesState>();
+ }
+
+ static GalleryFilesState of(BuildContext context) {
+ final GalleryFilesState? result = maybeOf(context);
+ assert(
+ result != null,
+ 'No GalleryFiles found in context. GalleryFilesState should be an ancestor of the GalleryWidget, preferably over the Scaffold of Gallery.',
+ );
+ return result!;
+ }
+
+ @override
+ bool updateShouldNotify(GalleryFilesState oldWidget) => false;
+}
diff --git a/mobile/lib/ui/viewer/gallery/state/selection_state.dart b/mobile/lib/ui/viewer/gallery/state/selection_state.dart
index ef97c884b1..82615f7557 100644
--- a/mobile/lib/ui/viewer/gallery/state/selection_state.dart
+++ b/mobile/lib/ui/viewer/gallery/state/selection_state.dart
@@ -1,6 +1,5 @@
import "package:flutter/material.dart";
import "package:logging/logging.dart";
-import "package:photos/models/file/file.dart";
import "package:photos/models/selected_files.dart";
///This is an inherited widget that needs to be wrapped around Gallery and
@@ -9,17 +8,11 @@ import "package:photos/models/selected_files.dart";
class SelectionState extends InheritedWidget {
final SelectedFiles selectedFiles;
- ///Should be assigned later in gallery when files are loaded.
- ///Note: EnteFiles in this list should be references of the same EnteFiles
- ///that are grouped in gallery, so that when files are added/deleted,
- ///both lists are in sync.
- List<EnteFile>? allGalleryFiles;
-
- SelectionState({
- Key? key,
+ const SelectionState({
+ super.key,
required this.selectedFiles,
- required Widget child,
- }) : super(key: key, child: child);
+ required super.child,
+ });
static SelectionState? maybeOf(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<SelectionState>();
diff --git a/mobile/lib/ui/viewer/gallery/trash_page.dart b/mobile/lib/ui/viewer/gallery/trash_page.dart
index d247245b36..4c5570f2ef 100644
--- a/mobile/lib/ui/viewer/gallery/trash_page.dart
+++ b/mobile/lib/ui/viewer/gallery/trash_page.dart
@@ -13,6 +13,7 @@ import 'package:photos/ui/common/bottom_shadow.dart';
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
import 'package:photos/utils/delete_file_util.dart';
@@ -25,8 +26,8 @@ class TrashPage extends StatelessWidget {
this.tagPrefix = "trash_page",
this.appBarType = GalleryType.trash,
this.overlayType = GalleryType.trash,
- Key? key,
- }) : super(key: key);
+ super.key,
+ });
@override
Widget build(BuildContext context) {
@@ -57,43 +58,45 @@ class TrashPage extends StatelessWidget {
initialFiles: null,
);
- return Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: GalleryAppBarWidget(
- appBarType,
- S.of(context).trash,
- _selectedFiles,
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: GalleryAppBarWidget(
+ appBarType,
+ S.of(context).trash,
+ _selectedFiles,
+ ),
),
- ),
- body: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- gallery,
- const BottomShadowWidget(
- offsetDy: 20,
- ),
- AnimatedContainer(
- duration: const Duration(milliseconds: 300),
- curve: Curves.easeInOut,
- height: filesAreSelected ? 0 : 80,
- child: AnimatedOpacity(
- duration: const Duration(milliseconds: 100),
- opacity: filesAreSelected ? 0.0 : 1.0,
- curve: Curves.easeIn,
- child: IgnorePointer(
- ignoring: filesAreSelected,
- child: const SafeArea(
- minimum: EdgeInsets.only(bottom: 6),
- child: BottomButtonsWidget(),
+ body: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ gallery,
+ const BottomShadowWidget(
+ offsetDy: 20,
+ ),
+ AnimatedContainer(
+ duration: const Duration(milliseconds: 300),
+ curve: Curves.easeInOut,
+ height: filesAreSelected ? 0 : 80,
+ child: AnimatedOpacity(
+ duration: const Duration(milliseconds: 100),
+ opacity: filesAreSelected ? 0.0 : 1.0,
+ curve: Curves.easeIn,
+ child: IgnorePointer(
+ ignoring: filesAreSelected,
+ child: const SafeArea(
+ minimum: EdgeInsets.only(bottom: 6),
+ child: BottomButtonsWidget(),
+ ),
),
),
),
- ),
- FileSelectionOverlayBar(GalleryType.trash, _selectedFiles),
- ],
+ FileSelectionOverlayBar(GalleryType.trash, _selectedFiles),
+ ],
+ ),
),
),
);
diff --git a/mobile/lib/ui/viewer/gallery/uncategorized_page.dart b/mobile/lib/ui/viewer/gallery/uncategorized_page.dart
index 7d49d2f3e5..b2faeab9f8 100644
--- a/mobile/lib/ui/viewer/gallery/uncategorized_page.dart
+++ b/mobile/lib/ui/viewer/gallery/uncategorized_page.dart
@@ -13,6 +13,7 @@ import 'package:photos/services/ignored_files_service.dart';
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class UnCategorizedPage extends StatelessWidget {
@@ -27,8 +28,8 @@ class UnCategorizedPage extends StatelessWidget {
this.tagPrefix = "Uncategorized_page",
this.appBarType = GalleryType.uncategorized,
this.overlayType = GalleryType.uncategorized,
- Key? key,
- }) : super(key: key);
+ super.key,
+ });
@override
Widget build(BuildContext context) {
@@ -73,27 +74,29 @@ class UnCategorizedPage extends StatelessWidget {
initialFiles: null,
albumName: S.of(context).uncategorized,
);
- return Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: GalleryAppBarWidget(
- appBarType,
- S.of(context).uncategorized,
- _selectedFiles,
- collection: collection,
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: GalleryAppBarWidget(
+ appBarType,
+ S.of(context).uncategorized,
+ _selectedFiles,
+ collection: collection,
+ ),
),
- ),
- body: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- gallery,
- FileSelectionOverlayBar(
- overlayType,
- _selectedFiles,
- ),
- ],
+ body: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ gallery,
+ FileSelectionOverlayBar(
+ overlayType,
+ _selectedFiles,
+ ),
+ ],
+ ),
),
),
);
diff --git a/mobile/lib/ui/viewer/location/dynamic_location_gallery_widget.dart b/mobile/lib/ui/viewer/location/dynamic_location_gallery_widget.dart
index 97ae881fda..0c7f9c1650 100644
--- a/mobile/lib/ui/viewer/location/dynamic_location_gallery_widget.dart
+++ b/mobile/lib/ui/viewer/location/dynamic_location_gallery_widget.dart
@@ -12,6 +12,7 @@ import "package:photos/services/filter/db_filters.dart";
import "package:photos/services/location_service.dart";
import 'package:photos/states/location_state.dart';
import "package:photos/ui/viewer/gallery/gallery.dart";
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
///This gallery will get rebuilt with the updated radius when
///InheritedLocationTagData notifies a change in radius.
@@ -100,20 +101,22 @@ class _DynamicLocationGalleryWidgetState
),
constrains.maxWidth,
),
- child: Gallery(
- loadingWidget: const SizedBox.shrink(),
- disableScroll: true,
- asyncLoader: (
- creationStartTime,
- creationEndTime, {
- limit,
- asc,
- }) async {
- return snapshot.data as FileLoadResult;
- },
- tagPrefix: widget.tagPrefix,
- enableFileGrouping: false,
- showSelectAllByDefault: false,
+ child: GalleryFilesState(
+ child: Gallery(
+ loadingWidget: const SizedBox.shrink(),
+ disableScroll: true,
+ asyncLoader: (
+ creationStartTime,
+ creationEndTime, {
+ limit,
+ asc,
+ }) async {
+ return snapshot.data as FileLoadResult;
+ },
+ tagPrefix: widget.tagPrefix,
+ enableFileGrouping: false,
+ showSelectAllByDefault: false,
+ ),
),
);
},
diff --git a/mobile/lib/ui/viewer/location/location_screen.dart b/mobile/lib/ui/viewer/location/location_screen.dart
index dda1d5022a..6755aa9223 100644
--- a/mobile/lib/ui/viewer/location/location_screen.dart
+++ b/mobile/lib/ui/viewer/location/location_screen.dart
@@ -25,6 +25,7 @@ import "package:photos/ui/components/title_bar_title_widget.dart";
import "package:photos/ui/components/title_bar_widget.dart";
import "package:photos/ui/viewer/actions/file_selection_overlay_bar.dart";
import "package:photos/ui/viewer/gallery/gallery.dart";
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
import "package:photos/ui/viewer/location/edit_location_sheet.dart";
import "package:photos/utils/dialog_util.dart";
@@ -37,26 +38,28 @@ class LocationScreen extends StatelessWidget {
Widget build(BuildContext context) {
final heightOfStatusBar = MediaQuery.of(context).viewPadding.top;
const heightOfAppBar = 48.0;
- return Scaffold(
- appBar: const PreferredSize(
- preferredSize: Size(double.infinity, heightOfAppBar),
- child: TitleBarWidget(
- isSliver: false,
- isFlexibleSpaceDisabled: true,
- actionIcons: [LocationScreenPopUpMenu()],
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: const PreferredSize(
+ preferredSize: Size(double.infinity, heightOfAppBar),
+ child: TitleBarWidget(
+ isSliver: false,
+ isFlexibleSpaceDisabled: true,
+ actionIcons: [LocationScreenPopUpMenu()],
+ ),
),
- ),
- body: Column(
- children: <Widget>[
- SizedBox(
- height: MediaQuery.of(context).size.height -
- (heightOfAppBar + heightOfStatusBar),
- width: double.infinity,
- child: LocationGalleryWidget(
- tagPrefix: tagPrefix,
+ body: Column(
+ children: <Widget>[
+ SizedBox(
+ height: MediaQuery.of(context).size.height -
+ (heightOfAppBar + heightOfStatusBar),
+ width: double.infinity,
+ child: LocationGalleryWidget(
+ tagPrefix: tagPrefix,
+ ),
),
- ),
- ],
+ ],
+ ),
),
);
}
diff --git a/mobile/lib/ui/viewer/location/pick_center_point_widget.dart b/mobile/lib/ui/viewer/location/pick_center_point_widget.dart
index de95aff093..aeb5638353 100644
--- a/mobile/lib/ui/viewer/location/pick_center_point_widget.dart
+++ b/mobile/lib/ui/viewer/location/pick_center_point_widget.dart
@@ -20,6 +20,7 @@ import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/components/notification_widget.dart";
import "package:photos/ui/components/title_bar_title_widget.dart";
import "package:photos/ui/viewer/gallery/gallery.dart";
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
Future<Location?> showPickCenterPointSheet(
BuildContext context, {
@@ -83,40 +84,42 @@ class PickCenterPointWidget extends StatelessWidget {
caption: locationTagName ?? "New location",
),
Expanded(
- child: Gallery(
- asyncLoader: (
- creationStartTime,
- creationEndTime, {
- limit,
- asc,
- }) async {
- final collectionsToHide = CollectionsService
- .instance
- .archivedOrHiddenCollectionIds();
- FileLoadResult result;
- result = await FilesDB.instance
- .fetchAllUploadedAndSharedFilesWithLocation(
- galleryLoadStartTime,
- galleryLoadEndTime,
- limit: null,
- asc: false,
- filterOptions: DBFilterOptions(
- ignoredCollectionIDs: collectionsToHide,
- hideIgnoredForUpload: true,
+ child: GalleryFilesState(
+ child: Gallery(
+ asyncLoader: (
+ creationStartTime,
+ creationEndTime, {
+ limit,
+ asc,
+ }) async {
+ final collectionsToHide = CollectionsService
+ .instance
+ .archivedOrHiddenCollectionIds();
+ FileLoadResult result;
+ result = await FilesDB.instance
+ .fetchAllUploadedAndSharedFilesWithLocation(
+ galleryLoadStartTime,
+ galleryLoadEndTime,
+ limit: null,
+ asc: false,
+ filterOptions: DBFilterOptions(
+ ignoredCollectionIDs: collectionsToHide,
+ hideIgnoredForUpload: true,
+ ),
+ );
+ return result;
+ },
+ reloadEvent:
+ Bus.instance.on<LocalPhotosUpdatedEvent>(),
+ tagPrefix: "pick_center_point_gallery",
+ selectedFiles: selectedFiles,
+ limitSelectionToOne: true,
+ showSelectAllByDefault: false,
+ header: const Padding(
+ padding: EdgeInsets.all(10),
+ child: NotificationTipWidget(
+ "You can also add a location centered on a photo from the photo's info screen",
),
- );
- return result;
- },
- reloadEvent:
- Bus.instance.on<LocalPhotosUpdatedEvent>(),
- tagPrefix: "pick_center_point_gallery",
- selectedFiles: selectedFiles,
- limitSelectionToOne: true,
- showSelectAllByDefault: false,
- header: const Padding(
- padding: EdgeInsets.all(10),
- child: NotificationTipWidget(
- "You can also add a location centered on a photo from the photo's info screen",
),
),
),
diff --git a/mobile/lib/ui/viewer/people/cluster_page.dart b/mobile/lib/ui/viewer/people/cluster_page.dart
index af41a200be..34e42bfaac 100644
--- a/mobile/lib/ui/viewer/people/cluster_page.dart
+++ b/mobile/lib/ui/viewer/people/cluster_page.dart
@@ -15,6 +15,7 @@ import 'package:photos/models/selected_files.dart';
import "package:photos/services/machine_learning/face_ml/feedback/cluster_feedback.dart";
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
import "package:photos/ui/viewer/people/add_person_action_sheet.dart";
import "package:photos/ui/viewer/people/cluster_app_bar.dart";
@@ -45,8 +46,8 @@ class ClusterPage extends StatefulWidget {
this.personID,
this.appendTitle = "",
this.showNamingBanner = true,
- Key? key,
- }) : super(key: key);
+ super.key,
+ });
@override
State<ClusterPage> createState() => _ClusterPageState();
@@ -138,79 +139,85 @@ class _ClusterPageState extends State<ClusterPage> {
enableFileGrouping: widget.enableGrouping,
initialFiles: [widget.searchResult.first],
);
- return Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: ClusterAppBar(
- SearchResultPage.appBarType,
- "${files.length} memories${widget.appendTitle}",
- _selectedFiles,
- widget.clusterID,
- key: ValueKey(files.length),
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: ClusterAppBar(
+ SearchResultPage.appBarType,
+ "${files.length} memories${widget.appendTitle}",
+ _selectedFiles,
+ widget.clusterID,
+ key: ValueKey(files.length),
+ ),
),
- ),
- body: Column(
- children: [
- Expanded(
- child: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- gallery,
- FileSelectionOverlayBar(
- ClusterPage.overlayType,
- _selectedFiles,
- clusterID: widget.clusterID,
- ),
- ],
+ body: Column(
+ children: [
+ Expanded(
+ child: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ gallery,
+ FileSelectionOverlayBar(
+ ClusterPage.overlayType,
+ _selectedFiles,
+ clusterID: widget.clusterID,
+ ),
+ ],
+ ),
),
),
- ),
- showNamingBanner
- ? SafeArea(
- child: Dismissible(
- key: const Key("namingBanner"),
- direction: DismissDirection.horizontal,
- onDismissed: (direction) {
- setState(() {
- userDismissedNamingBanner = true;
- });
- },
- child: PeopleBanner(
- type: PeopleBannerType.addName,
- faceWidget: PersonFaceWidget(
- files.first,
- clusterID: widget.clusterID,
- ),
- actionIcon: Icons.add_outlined,
- text: S.of(context).addAName,
- subText: S.of(context).findPeopleByName,
- onTap: () async {
- if (widget.personID == null) {
- final result = await showAssignPersonAction(
- context,
- clusterID: widget.clusterID,
- );
- if (result != null &&
- result is (PersonEntity, EnteFile)) {
- Navigator.pop(context);
- // ignore: unawaited_futures
- routeToPage(context, PeoplePage(person: result.$1));
- } else if (result != null && result is PersonEntity) {
- Navigator.pop(context);
- // ignore: unawaited_futures
- routeToPage(context, PeoplePage(person: result));
- }
- } else {
- showShortToast(context, "No personID or clusterID");
- }
+ showNamingBanner
+ ? SafeArea(
+ child: Dismissible(
+ key: const Key("namingBanner"),
+ direction: DismissDirection.horizontal,
+ onDismissed: (direction) {
+ setState(() {
+ userDismissedNamingBanner = true;
+ });
},
+ child: PeopleBanner(
+ type: PeopleBannerType.addName,
+ faceWidget: PersonFaceWidget(
+ files.first,
+ clusterID: widget.clusterID,
+ ),
+ actionIcon: Icons.add_outlined,
+ text: S.of(context).addAName,
+ subText: S.of(context).findPeopleByName,
+ onTap: () async {
+ if (widget.personID == null) {
+ final result = await showAssignPersonAction(
+ context,
+ clusterID: widget.clusterID,
+ );
+ if (result != null &&
+ result is (PersonEntity, EnteFile)) {
+ Navigator.pop(context);
+ // ignore: unawaited_futures
+ routeToPage(
+ context,
+ PeoplePage(person: result.$1),
+ );
+ } else if (result != null &&
+ result is PersonEntity) {
+ Navigator.pop(context);
+ // ignore: unawaited_futures
+ routeToPage(context, PeoplePage(person: result));
+ }
+ } else {
+ showShortToast(context, "No personID or clusterID");
+ }
+ },
+ ),
),
- ),
- )
- : const SizedBox.shrink(),
- ],
+ )
+ : const SizedBox.shrink(),
+ ],
+ ),
),
);
}
diff --git a/mobile/lib/ui/viewer/people/people_page.dart b/mobile/lib/ui/viewer/people/people_page.dart
index 74a7e7f6bb..fd2cce4895 100644
--- a/mobile/lib/ui/viewer/people/people_page.dart
+++ b/mobile/lib/ui/viewer/people/people_page.dart
@@ -17,6 +17,7 @@ import "package:photos/services/machine_learning/face_ml/feedback/cluster_feedba
import "package:photos/services/search_service.dart";
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
import "package:photos/ui/viewer/people/people_app_bar.dart";
import "package:photos/ui/viewer/people/people_banner.dart";
@@ -110,110 +111,113 @@ class _PeoplePageState extends State<PeoplePage> {
@override
Widget build(BuildContext context) {
_logger.info("Building for ${widget.person.data.name}");
- return Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: PeopleAppBar(
- GalleryType.peopleTag,
- widget.person.data.name,
- _selectedFiles,
- widget.person,
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: PeopleAppBar(
+ GalleryType.peopleTag,
+ widget.person.data.name,
+ _selectedFiles,
+ widget.person,
+ ),
),
- ),
- body: FutureBuilder<List<EnteFile>>(
- future: filesFuture,
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- final personFiles = snapshot.data as List<EnteFile>;
- return Column(
- children: [
- Expanded(
- child: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- Gallery(
- asyncLoader: (
- creationStartTime,
- creationEndTime, {
- limit,
- asc,
- }) async {
- final result = await loadPersonFiles();
- return Future.value(
- FileLoadResult(
- result,
- false,
- ),
- );
- },
- reloadEvent:
- Bus.instance.on<LocalPhotosUpdatedEvent>(),
- forceReloadEvents: [
- Bus.instance.on<PeopleChangedEvent>(),
- ],
- removalEventTypes: const {
- EventType.deletedFromRemote,
- EventType.deletedFromEverywhere,
- EventType.hide,
- },
- tagPrefix: widget.tagPrefix + widget.tagPrefix,
- selectedFiles: _selectedFiles,
- initialFiles:
- personFiles.isNotEmpty ? [personFiles.first] : [],
- ),
- FileSelectionOverlayBar(
- PeoplePage.overlayType,
- _selectedFiles,
- person: widget.person,
- ),
- ],
+ body: FutureBuilder<List<EnteFile>>(
+ future: filesFuture,
+ builder: (context, snapshot) {
+ if (snapshot.hasData) {
+ final personFiles = snapshot.data as List<EnteFile>;
+ return Column(
+ children: [
+ Expanded(
+ child: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ Gallery(
+ asyncLoader: (
+ creationStartTime,
+ creationEndTime, {
+ limit,
+ asc,
+ }) async {
+ final result = await loadPersonFiles();
+ return Future.value(
+ FileLoadResult(
+ result,
+ false,
+ ),
+ );
+ },
+ reloadEvent:
+ Bus.instance.on<LocalPhotosUpdatedEvent>(),
+ forceReloadEvents: [
+ Bus.instance.on<PeopleChangedEvent>(),
+ ],
+ removalEventTypes: const {
+ EventType.deletedFromRemote,
+ EventType.deletedFromEverywhere,
+ EventType.hide,
+ },
+ tagPrefix: widget.tagPrefix + widget.tagPrefix,
+ selectedFiles: _selectedFiles,
+ initialFiles: personFiles.isNotEmpty
+ ? [personFiles.first]
+ : [],
+ ),
+ FileSelectionOverlayBar(
+ PeoplePage.overlayType,
+ _selectedFiles,
+ person: widget.person,
+ ),
+ ],
+ ),
),
),
- ),
- showSuggestionBanner
- ? Dismissible(
- key: const Key("suggestionBanner"),
- direction: DismissDirection.horizontal,
- onDismissed: (direction) {
- setState(() {
- userDismissedSuggestionBanner = true;
- });
- },
- child: PeopleBanner(
- type: PeopleBannerType.suggestion,
- startIcon: Icons.face_retouching_natural,
- actionIcon: Icons.search_outlined,
- text: "Review suggestions",
- subText: "Improve the results",
- onTap: () async {
- unawaited(
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) =>
- PersonReviewClusterSuggestion(
- widget.person,
+ showSuggestionBanner
+ ? Dismissible(
+ key: const Key("suggestionBanner"),
+ direction: DismissDirection.horizontal,
+ onDismissed: (direction) {
+ setState(() {
+ userDismissedSuggestionBanner = true;
+ });
+ },
+ child: PeopleBanner(
+ type: PeopleBannerType.suggestion,
+ startIcon: Icons.face_retouching_natural,
+ actionIcon: Icons.search_outlined,
+ text: "Review suggestions",
+ subText: "Improve the results",
+ onTap: () async {
+ unawaited(
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (context) =>
+ PersonReviewClusterSuggestion(
+ widget.person,
+ ),
),
),
- ),
- );
- },
- ),
- )
- : const SizedBox.shrink(),
- ],
- );
- } else if (snapshot.hasError) {
- log("Error: ${snapshot.error} ${snapshot.stackTrace}}");
- //Need to show an error on the UI here
- return const SizedBox.shrink();
- } else {
- return const Center(
- child: CircularProgressIndicator(),
- );
- }
- },
+ );
+ },
+ ),
+ )
+ : const SizedBox.shrink(),
+ ],
+ );
+ } else if (snapshot.hasError) {
+ log("Error: ${snapshot.error} ${snapshot.stackTrace}}");
+ //Need to show an error on the UI here
+ return const SizedBox.shrink();
+ } else {
+ return const Center(
+ child: CircularProgressIndicator(),
+ );
+ }
+ },
+ ),
),
);
}
diff --git a/mobile/lib/ui/viewer/search/result/magic_result_screen.dart b/mobile/lib/ui/viewer/search/result/magic_result_screen.dart
index e17aeee895..c8c4e3697d 100644
--- a/mobile/lib/ui/viewer/search/result/magic_result_screen.dart
+++ b/mobile/lib/ui/viewer/search/result/magic_result_screen.dart
@@ -13,6 +13,7 @@ import 'package:photos/models/selected_files.dart';
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class MagicResultScreen extends StatefulWidget {
@@ -155,31 +156,33 @@ class _MagicResultScreenState extends State<MagicResultScreen> {
enableFileGrouping: _enableGrouping,
initialFiles: [files.first],
);
- return Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: GalleryAppBarWidget(
- MagicResultScreen.appBarType,
- widget.name,
- _selectedFiles,
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: GalleryAppBarWidget(
+ MagicResultScreen.appBarType,
+ widget.name,
+ _selectedFiles,
+ ),
),
- ),
- body: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- AnimatedSwitcher(
- duration: const Duration(milliseconds: 250),
- switchInCurve: Curves.easeInOutQuad,
- switchOutCurve: Curves.easeInOutQuad,
- child: gallery,
- ),
- FileSelectionOverlayBar(
- MagicResultScreen.overlayType,
- _selectedFiles,
- ),
- ],
+ body: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ AnimatedSwitcher(
+ duration: const Duration(milliseconds: 250),
+ switchInCurve: Curves.easeInOutQuad,
+ switchOutCurve: Curves.easeInOutQuad,
+ child: gallery,
+ ),
+ FileSelectionOverlayBar(
+ MagicResultScreen.overlayType,
+ _selectedFiles,
+ ),
+ ],
+ ),
),
),
);
diff --git a/mobile/lib/ui/viewer/search/result/search_result_page.dart b/mobile/lib/ui/viewer/search/result/search_result_page.dart
index 218f069860..ee0ed6ad45 100644
--- a/mobile/lib/ui/viewer/search/result/search_result_page.dart
+++ b/mobile/lib/ui/viewer/search/result/search_result_page.dart
@@ -12,6 +12,7 @@ import 'package:photos/models/selected_files.dart';
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class SearchResultPage extends StatefulWidget {
@@ -26,8 +27,8 @@ class SearchResultPage extends StatefulWidget {
this.searchResult, {
this.enableGrouping = true,
this.tagPrefix = "",
- Key? key,
- }) : super(key: key);
+ super.key,
+ });
@override
State<SearchResultPage> createState() => _SearchResultPageState();
@@ -91,26 +92,28 @@ class _SearchResultPageState extends State<SearchResultPage> {
enableFileGrouping: widget.enableGrouping,
initialFiles: [widget.searchResult.resultFiles().first],
);
- return Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: GalleryAppBarWidget(
- SearchResultPage.appBarType,
- widget.searchResult.name(),
- _selectedFiles,
+ return GalleryFilesState(
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: GalleryAppBarWidget(
+ SearchResultPage.appBarType,
+ widget.searchResult.name(),
+ _selectedFiles,
+ ),
),
- ),
- body: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- gallery,
- FileSelectionOverlayBar(
- SearchResultPage.overlayType,
- _selectedFiles,
- ),
- ],
+ body: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ gallery,
+ FileSelectionOverlayBar(
+ SearchResultPage.overlayType,
+ _selectedFiles,
+ ),
+ ],
+ ),
),
),
);