Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Extend album covers and transitions to Discover

r4khul99c4e04e0d8c
diff --git a/mobile/apps/photos/lib/services/magic_cache_service.dart b/mobile/apps/photos/lib/services/magic_cache_service.dart
index fa20011414..c10d7e1291 100644
--- a/mobile/apps/photos/lib/services/magic_cache_service.dart
+++ b/mobile/apps/photos/lib/services/magic_cache_service.dart
@@ -219,6 +219,7 @@ GenericSearchResult? toGenericSearchResult(
matchedUploadedIDs: filesToUploadedFileIDs(enteFilesInMagicCache),
),
),
+ useFadeTransition: true,
);
},
hierarchicalSearchFilter: MagicFilter(
diff --git a/mobile/apps/photos/lib/services/search_service.dart b/mobile/apps/photos/lib/services/search_service.dart
index 2865117423..dcf48a9054 100644
--- a/mobile/apps/photos/lib/services/search_service.dart
+++ b/mobile/apps/photos/lib/services/search_service.dart
@@ -1835,6 +1835,7 @@ class SearchService {
matchedUploadedIDs: filesToUploadedFileIDs(files),
),
),
+ useFadeTransition: true,
);
},
hierarchicalSearchFilter: MagicFilter(
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index 2e9de20558..cacbe76e4f 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -81,10 +81,16 @@ class GalleryAppBarWidget extends StatefulWidget {
String? coverHeroTag,
Key? coverAppBarKey,
List<EnteFile>? files,
+ MagicSortType magicSortType = MagicSortType.mostRelevant,
PreferredSizeWidget? bottom,
bool showOverflowMenu = true,
}) {
- assert(cover == null || collection != null || deviceCollection != null);
+ assert(
+ cover == null ||
+ collection != null ||
+ deviceCollection != null ||
+ files != null,
+ );
return GalleryAppBarConfig(
extendBodyForCollapse: cover != null && bottom == null,
sliverBuilder: (_) => GalleryAppBarWidget._(
@@ -100,6 +106,7 @@ class GalleryAppBarWidget extends StatefulWidget {
coverHeroTag: coverHeroTag,
coverAppBarKey: coverAppBarKey,
files: files,
+ magicSortType: magicSortType,
bottom: bottom,
showOverflowMenu: showOverflowMenu,
),
@@ -179,6 +186,7 @@ class GalleryAppBarWidget extends StatefulWidget {
final String? coverHeroTag;
final Key? coverAppBarKey;
final List<EnteFile>? files;
+ final MagicSortType magicSortType;
final PreferredSizeWidget? bottom;
final bool showOverflowMenu;
@@ -195,6 +203,7 @@ class GalleryAppBarWidget extends StatefulWidget {
this.coverHeroTag,
this.coverAppBarKey,
this.files,
+ required this.magicSortType,
this.bottom,
required this.showOverflowMenu,
});
@@ -225,8 +234,6 @@ enum AlbumPopupAction {
removeLink,
cleanUncategorized,
downloadAlbum,
- sortByMostRecent,
- sortByMostRelevant,
editLocation,
deleteLocation,
galleryGuestView,
@@ -587,6 +594,33 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
}
final strings = context.strings;
+ if (galleryType == GalleryType.magic) {
+ actions.add(
+ IconButtonComponent(
+ tooltip: strings.sort,
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedFilterHorizontal,
+ color: foregroundColor,
+ ),
+ variant: iconButtonVariant,
+ size: onCover ? kMinInteractiveDimension : 36,
+ iconSize: onCover ? IconSizes.medium : IconSizes.small,
+ shouldSurfaceExecutionStates: false,
+ onTap: () async {
+ final sortType = await showMagicSortSheet(
+ context,
+ sortType: widget.magicSortType,
+ );
+ if (mounted &&
+ sortType != null &&
+ sortType != widget.magicSortType) {
+ Bus.instance.fire(MagicSortChangeEvent(sortType));
+ }
+ },
+ ),
+ );
+ }
+
if (!Configuration.instance.hasConfiguredAccount()) {
if (!onCover &&
widget.showOverflowMenu &&
@@ -612,36 +646,6 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
return actions;
}
- if (galleryType == GalleryType.magic) {
- actions.add(
- galleryAppBarPopupMenuAction<AlbumPopupAction>(
- tooltip: strings.sort,
- icon: const HugeIcon(icon: HugeIcons.strokeRoundedFilterHorizontal),
- optionsBuilder: () {
- return [
- EntePopupMenuOption(
- value: AlbumPopupAction.sortByMostRecent,
- label: strings.mostRecent,
- ),
- EntePopupMenuOption(
- value: AlbumPopupAction.sortByMostRelevant,
- label: strings.mostRelevant,
- ),
- ];
- },
- onSelected: (AlbumPopupAction value) {
- if (value == AlbumPopupAction.sortByMostRecent) {
- Bus.instance.fire(MagicSortChangeEvent(MagicSortType.mostRecent));
- } else if (value == AlbumPopupAction.sortByMostRelevant) {
- Bus.instance.fire(
- MagicSortChangeEvent(MagicSortType.mostRelevant),
- );
- }
- },
- ),
- );
- }
-
final int userId = Configuration.instance.getUserID()!;
isQuickLink = widget.collection?.isQuickLinkCollection() ?? false;
if (galleryType.canAddFiles(widget.collection, userId)) {
@@ -1226,7 +1230,10 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
await showAlbumSlideshow(
context,
files: galleryFiles,
- title: widget.deviceCollection?.name ?? widget.collection!.displayName,
+ title:
+ widget.deviceCollection?.name ??
+ widget.collection?.displayName ??
+ _appBarTitle,
includeBackupExcludedFiles: widget.deviceCollection != null,
);
}
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dart b/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dart
index fc21cf361d..51edf9dd08 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dart
@@ -51,23 +51,27 @@ class MagicResultScreen extends StatefulWidget {
class _MagicResultScreenState extends State<MagicResultScreen> {
final _selectedFiles = SelectedFiles();
+ final _coverAppBarKey = GlobalKey();
late final List<EnteFile> files;
+ late final String? _coverHeroTag;
late final StreamSubscription<LocalPhotosUpdatedEvent> _filesUpdatedEvent;
late final StreamSubscription<MagicSortChangeEvent> _magicSortChangeEvent;
late final Logger _logger = Logger("_MagicResultScreenState");
late Map<int, int> fileIDToRelevantPos;
Map<String, int> _localIdToIntId = const {};
+ Future<void>? _localIdsLoaded;
bool _enableGrouping = false;
late final SearchFilterDataProvider _searchFilterDataProvider;
@override
void initState() {
super.initState();
- files = widget.files;
+ files = List.of(widget.files);
+ _coverHeroTag = files.isEmpty ? null : widget.heroTag + files.first.tag;
_enableGrouping = widget.enableGrouping;
fileIDToRelevantPos = getFileIDToRelevantPos();
if (isLocalGalleryMode) {
- _loadLocalIntIds();
+ _localIdsLoaded = _loadLocalIntIds();
}
_filesUpdatedEvent = Bus.instance.on<LocalPhotosUpdatedEvent>().listen((
event,
@@ -76,8 +80,10 @@ class _MagicResultScreenState extends State<MagicResultScreen> {
event.type == EventType.deletedFromEverywhere ||
event.type == EventType.deletedFromRemote ||
event.type == EventType.hide) {
- for (var updatedFile in event.updatedFiles) {
- files.remove(updatedFile);
+ if (event.updatedFiles.isNotEmpty) {
+ final updatedFiles = event.updatedFiles.toSet();
+ files.removeWhere(updatedFiles.contains);
+ widget.files.removeWhere(updatedFiles.contains);
}
setState(() {});
}
@@ -85,7 +91,9 @@ class _MagicResultScreenState extends State<MagicResultScreen> {
_magicSortChangeEvent = Bus.instance.on<MagicSortChangeEvent>().listen((
event,
- ) {
+ ) async {
+ await _localIdsLoaded;
+ if (!mounted) return;
if (event.sortType == MagicSortType.mostRelevant) {
if (_enableGrouping) {
if (fileIDToRelevantPos.isNotEmpty) {
@@ -180,6 +188,13 @@ class _MagicResultScreenState extends State<MagicResultScreen> {
MagicResultScreen.appBarType,
widget.name,
_selectedFiles,
+ coverAppBarKey: _coverAppBarKey,
+ cover: files.firstOrNull,
+ coverHeroTag: _coverHeroTag,
+ files: files,
+ magicSortType: _enableGrouping
+ ? MagicSortType.mostRecent
+ : MagicSortType.mostRelevant,
);
final gallery = Gallery(
key: ValueKey(_enableGrouping),
@@ -202,7 +217,7 @@ class _MagicResultScreenState extends State<MagicResultScreen> {
EventType.deletedFromEverywhere,
EventType.hide,
},
- tagPrefix: widget.heroTag,
+ tagPrefix: "${widget.heroTag}_files",
selectedFiles: _selectedFiles,
enableFileGrouping: _enableGrouping,
initialFiles: files.isNotEmpty ? [files.first] : const [],
@@ -226,16 +241,11 @@ class _MagicResultScreenState extends State<MagicResultScreen> {
builder: (context, value, _) {
return value
? HierarchicalSearchGallery(
- tagPrefix: widget.heroTag,
+ tagPrefix: "${widget.heroTag}_files",
selectedFiles: _selectedFiles,
appBar: appBar,
)
- : AnimatedSwitcher(
- duration: const Duration(milliseconds: 250),
- switchInCurve: Curves.easeInOutQuad,
- switchOutCurve: Curves.easeInOutQuad,
- child: gallery,
- );
+ : gallery;
},
);
},
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/search_section_all_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/search_section_all_page.dart
index 6cec58f9fb..4c0e255b99 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/search_section_all_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/search_section_all_page.dart
@@ -252,6 +252,7 @@ class _SearchSectionAllPageState extends State<SearchSectionAllPage> {
result.getHierarchicalSearchFilter()
as MagicFilter,
),
+ useFadeTransition: true,
);
},
);
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/search_thumbnail_widget.dart b/mobile/apps/photos/lib/ui/viewer/search/result/search_thumbnail_widget.dart
index b843c18742..8279ba638d 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/search_thumbnail_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/search_thumbnail_widget.dart
@@ -29,6 +29,10 @@ class SearchThumbnailWidget extends StatelessWidget {
Widget build(BuildContext context) {
return Hero(
tag: tagPrefix + (file?.tag ?? ""),
+ createRectTween: searchResult?.type() == ResultType.magic
+ ? (begin, end) => RectTween(begin: begin, end: end)
+ : null,
+ transitionOnUserGestures: searchResult?.type() == ResultType.magic,
child: SizedBox(
height: size,
width: size,
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart
index 043fd8e0c8..754fc6ba0f 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart
@@ -127,23 +127,26 @@ class MagicRecommendation extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- ClipSmoothRect(
- radius: SmoothBorderRadius(
- cornerRadius: _cornerRadius,
- cornerSmoothing: _cornerSmoothing,
- ),
- child: SizedBox(
- width: _thumbnailSize,
- height: _thumbnailSize,
- child: magicSearchResult.previewThumbnail() != null
- ? Hero(
- tag: heroTag,
- child: ThumbnailWidget(
+ Hero(
+ tag: heroTag,
+ createRectTween: (begin, end) =>
+ RectTween(begin: begin, end: end),
+ transitionOnUserGestures: true,
+ child: ClipSmoothRect(
+ radius: SmoothBorderRadius(
+ cornerRadius: _cornerRadius,
+ cornerSmoothing: _cornerSmoothing,
+ ),
+ child: SizedBox(
+ width: _thumbnailSize,
+ height: _thumbnailSize,
+ child: magicSearchResult.previewThumbnail() != null
+ ? ThumbnailWidget(
magicSearchResult.previewThumbnail()!,
shouldShowSyncStatus: false,
- ),
- )
- : const NoThumbnailWidget(),
+ )
+ : const NoThumbnailWidget(),
+ ),
),
),
const SizedBox(height: 8),