π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] Animate album covers from their thumbnails
r4khul7d0f58662bde
diff --git a/mobile/apps/photos/changes/album-cover-redesign.md b/mobile/apps/photos/changes/album-cover-redesign.mdindex 2f61bf8cc4..95cc53da47 100644--- a/mobile/apps/photos/changes/album-cover-redesign.md+++ b/mobile/apps/photos/changes/album-cover-redesign.md@@ -1 +1 @@-- Refreshed the album page with a full cover, quick slideshow and map buttons, and a simpler options sheet.+- Refreshed the album page with a full cover, smooth thumbnail transitions, quick slideshow and map buttons, and a simpler options sheet.diff --git a/mobile/apps/photos/lib/models/search/search_types.dart b/mobile/apps/photos/lib/models/search/search_types.dartindex a01dec9e3b..5a1e957562 100644--- a/mobile/apps/photos/lib/models/search/search_types.dart+++ b/mobile/apps/photos/lib/models/search/search_types.dart@@ -225,6 +225,7 @@ extension SectionTypeExtensions on SectionType {await routeToPage(context,CollectionPage(CollectionWithThumbnail(c, null)),+ forceCustomPageRoute: true,);} catch (e, s) {Logger(diff --git a/mobile/apps/photos/lib/services/album_home_widget_service.dart b/mobile/apps/photos/lib/services/album_home_widget_service.dartindex dbf8cfcac0..d9cf9635a2 100644--- a/mobile/apps/photos/lib/services/album_home_widget_service.dart+++ b/mobile/apps/photos/lib/services/album_home_widget_service.dart@@ -215,6 +215,7 @@ class AlbumHomeWidgetService {AppNavigationService.instance.pushPage(CollectionPage(CollectionWithThumbnail(collection, thumbnail)),+ forceCustomPageRoute: true,).ignore();final getAllFilesCollection = await FilesDB.instance.getAllFilesCollection(diff --git a/mobile/apps/photos/lib/ui/collections/album/row_item.dart b/mobile/apps/photos/lib/ui/collections/album/row_item.dartindex 46b8b13d02..15e27b96a8 100644--- a/mobile/apps/photos/lib/ui/collections/album/row_item.dart+++ b/mobile/apps/photos/lib/ui/collections/album/row_item.dart@@ -125,14 +125,6 @@ class AlbumRowItemWidget extends StatelessWidget {);return Hero(tag: heroTag,- flightShuttleBuilder:- (- flightContext,- animation,- flightDirection,- fromHeroContext,- toHeroContext,- ) => (toHeroContext.widget as Hero).child,transitionOnUserGestures: true,child: ClipSmoothRect(radius: SmoothBorderRadius(@@ -351,6 +343,7 @@ class AlbumRowItemWidget extends StatelessWidget {tagPrefix: tagPrefix,hasVerifiedLock: hasVerifiedLock,),+ forceCustomPageRoute: true,);},onLongPress: () {diff --git a/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart b/mobile/apps/photos/lib/ui/collections/album/vertical_list.dartindex 6d31068a2c..2bd3f85f2c 100644--- a/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart+++ b/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart@@ -476,6 +476,7 @@ class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {CollectionWithThumbnail(collection, null),hasVerifiedLock: hasVerifiedLock,),+ forceCustomPageRoute: true,);}diff --git a/mobile/apps/photos/lib/ui/collections/flex_grid_view.dart b/mobile/apps/photos/lib/ui/collections/flex_grid_view.dartindex ac3cb679e1..399b29c7dc 100644--- a/mobile/apps/photos/lib/ui/collections/flex_grid_view.dart+++ b/mobile/apps/photos/lib/ui/collections/flex_grid_view.dart@@ -182,6 +182,7 @@ class _CollectionsFlexiGridViewWidgetStateCollectionWithThumbnail(c, thumbnail),hasVerifiedLock: hasVerifiedLock,),+ forceCustomPageRoute: true,);}@@ -198,6 +199,7 @@ class _CollectionsFlexiGridViewWidgetStateawait routeToPage(context,CollectionPage(CollectionWithThumbnail(result, null)),+ forceCustomPageRoute: true,);} else {await showGenericErrorDialog(context: context, error: result);diff --git a/mobile/apps/photos/lib/ui/rituals/ritual_page.dart b/mobile/apps/photos/lib/ui/rituals/ritual_page.dartindex 51cdc49fba..31efa2993b 100644--- a/mobile/apps/photos/lib/ui/rituals/ritual_page.dart+++ b/mobile/apps/photos/lib/ui/rituals/ritual_page.dart@@ -1247,6 +1247,7 @@ Future<void> _openRitualAlbum(BuildContext context, Ritual ritual) async {CollectionWithThumbnail(collection, thumbnail),hasVerifiedLock: collection.isHidden(),),+ forceCustomPageRoute: true,);}@@ -1278,6 +1279,7 @@ Future<void> _openRitualAlbumAndFile(CollectionWithThumbnail(collection, thumbnail),hasVerifiedLock: collection.isHidden(),),+ forceCustomPageRoute: true,).ignore();final files = await FilesDB.instance.getAllFilesCollection(collection.id);diff --git a/mobile/apps/photos/lib/ui/tabs/home_widget.dart b/mobile/apps/photos/lib/ui/tabs/home_widget.dartindex 4e377e2f5e..d01ff13e05 100644--- a/mobile/apps/photos/lib/ui/tabs/home_widget.dart+++ b/mobile/apps/photos/lib/ui/tabs/home_widget.dart@@ -403,6 +403,7 @@ class _HomeWidgetState extends State<HomeWidget> {await routeToPage(context,CollectionPage(CollectionWithThumbnail(collection, null)),+ forceCustomPageRoute: true,);return;}@@ -1315,6 +1316,7 @@ class _HomeWidgetState extends State<HomeWidget> {// ignore: unawaited_futuresAppNavigationService.instance.pushPage(CollectionPage(CollectionWithThumbnail(collection, thumbnail)),+ forceCustomPageRoute: true,);}}diff --git a/mobile/apps/photos/lib/ui/tabs/shared/all_links_page.dart b/mobile/apps/photos/lib/ui/tabs/shared/all_links_page.dartindex eeaf3f5953..889254dabd 100644--- a/mobile/apps/photos/lib/ui/tabs/shared/all_links_page.dart+++ b/mobile/apps/photos/lib/ui/tabs/shared/all_links_page.dart@@ -59,6 +59,7 @@ class _AllLinksPageState extends State<AllLinksPage> {CollectionWithThumbnail(c, thumbnail),tagPrefix: _quickLinkHeroTagPrefix,),+ forceCustomPageRoute: true,),);}diff --git a/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart b/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dartindex 4bbc111c96..411faebe55 100644--- a/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart@@ -41,6 +41,7 @@ class ThumbnailWidget extends StatefulWidget {final Duration? serverLoadDeferDuration;final int thumbnailSize;final bool useRequestedThumbnailSizeForLocalCache;+ final bool useCachedThumbnailAsPlaceholder;final bool shouldShowOwnerAvatar;final AvatarType ownerAvatarType;final bool shouldShowFavoriteIcon;@@ -63,6 +64,7 @@ class ThumbnailWidget extends StatefulWidget {this.serverLoadDeferDuration,this.thumbnailSize = thumbnailSmallSize,this.useRequestedThumbnailSizeForLocalCache = false,+ this.useCachedThumbnailAsPlaceholder = false,this.shouldShowFavoriteIcon = true,this.placeholderColor,this.shouldShowVideoDuration = false,@@ -181,7 +183,11 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {}Widget? image;if (_imageProvider != null) {- image = Image(image: _imageProvider!, fit: widget.fit);+ image = Image(+ image: _imageProvider!,+ fit: widget.fit,+ gaplessPlayback: widget.useCachedThumbnailAsPlaceholder,+ );}if (widget.rawThumbnail) {return image ?? ThumbnailPlaceHolder(color: widget.placeholderColor);@@ -308,6 +314,22 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {_cacheAndRender(imageProvider);return;}+ if (widget.useCachedThumbnailAsPlaceholder &&+ _localCacheThumbnailSize != thumbnailSmallSize) {+ final preview = ThumbnailInMemoryLruCache.get(+ widget.file,+ thumbnailSmallSize,+ );+ if (preview != null) {+ _imageProvider = Image.memory(+ preview,+ cacheWidth: optimizedImageWidth == null ? null : thumbnailSmallSize,+ cacheHeight: optimizedImageHeight == null+ ? null+ : thumbnailSmallSize,+ ).image;+ }+ }if (widget.diskLoadDeferDuration != null) {Future.delayed(widget.diskLoadDeferDuration!, () {if (mounted) {diff --git a/mobile/apps/photos/lib/ui/viewer/file_details/albums_item_widget.dart b/mobile/apps/photos/lib/ui/viewer/file_details/albums_item_widget.dartindex 3c5fc73882..fa6cfb5d2c 100644--- a/mobile/apps/photos/lib/ui/viewer/file_details/albums_item_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/file_details/albums_item_widget.dart@@ -111,6 +111,7 @@ class _AlbumsItemWidgetState extends State<AlbumsItemWidget> {CollectionWithThumbnail(c, null),fileToJumpTo: widget.file,),+ forceCustomPageRoute: true,);},onRemove: _canRemoveFrom(c)diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dartindex 581c3a6f9d..61be1bbeb7 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart@@ -55,6 +55,7 @@ class CollectionPage extends StatefulWidget {class _CollectionPageState extends State<CollectionPage> {final _logger = Logger("CollectionPage");final _selectedFiles = SelectedFiles();+ final _coverAppBarKey = GlobalKey();late final _searchFilterDataProvider = SearchFilterDataProvider(initialGalleryFilter: AlbumFilter(collectionID: widget.c.collection.id,@@ -66,6 +67,7 @@ class _CollectionPageState extends State<CollectionPage> {_collectionUpdatedSubscription;EnteFile? _cover;EnteFile? _defaultCover;+ late final String? _coverHeroTag;int _coverLoadGeneration = 0;int _galleryLoadGeneration = 0;@@ -77,6 +79,7 @@ class _CollectionPageState extends State<CollectionPage> {widget.c.thumbnail ??CollectionsService.instance.getCoverCache(collection);_defaultCover = _cover;+ _coverHeroTag = _cover == null ? null : widget.tagPrefix + _cover!.tag;if (collection.hasCover) {unawaited(_loadCover());}@@ -134,6 +137,8 @@ class _CollectionPageState extends State<CollectionPage> {_selectedFiles,collection: c.collection,cover: _cover,+ coverHeroTag: _coverHeroTag,+ coverAppBarKey: _coverAppBarKey,);final gallery = Gallery(appBar: appBar,@@ -177,7 +182,7 @@ class _CollectionPageState extends State<CollectionPage> {EventType.deletedFromEverywhere,EventType.hide,},- tagPrefix: tagPrefix,+ tagPrefix: "${tagPrefix}_files",selectedFiles: _selectedFiles,initialFiles: initialFiles,albumName: c.collection.displayName,@@ -223,7 +228,7 @@ class _CollectionPageState extends State<CollectionPage> {builder: (context, value, _) {return value? HierarchicalSearchGallery(- tagPrefix: tagPrefix,+ tagPrefix: "${tagPrefix}_files",selectedFiles: _selectedFiles,appBar: appBar,)diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/component/album_cover_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/gallery/component/album_cover_app_bar.dartindex d960bdb7be..dce7382380 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/component/album_cover_app_bar.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/component/album_cover_app_bar.dart@@ -2,6 +2,7 @@ import "dart:math" as math;import "dart:ui" as ui;import "package:ente_components/ente_components.dart";+import "package:figma_squircle/figma_squircle.dart";import "package:flutter/material.dart";import "package:flutter/rendering.dart";import "package:flutter/services.dart";@@ -11,6 +12,8 @@ import "package:photos/core/constants.dart";import "package:photos/core/page_route_observer.dart";import "package:photos/models/collection/collection.dart";import "package:photos/models/file/file.dart";+import "package:photos/models/file/file_type.dart";+import "package:photos/ui/viewer/file/file_icons_widget.dart";import "package:photos/ui/viewer/file/thumbnail_widget.dart";import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";@@ -24,6 +27,7 @@ class AlbumCoverAppBar extends StatefulWidget {required this.coverActions,required this.backgroundColor,required this.collapsedHeight,+ this.heroTag,this.bottom,});@@ -34,6 +38,7 @@ class AlbumCoverAppBar extends StatefulWidget {final List<Widget> coverActions;final Color backgroundColor;final double collapsedHeight;+ final String? heroTag;final PreferredSizeWidget? bottom;static HeaderAppBarGeometry resolveGeometry(@@ -93,6 +98,9 @@ class _AlbumCoverAppBarState extends State<AlbumCoverAppBar> with RouteAware {final colors = context.componentColors;final bottomHeight = widget.bottom?.preferredSize.height ?? 0;final description = widget.collection.displayDescription;+ final animation = MediaQuery.disableAnimationsOf(context)+ ? kAlwaysCompleteAnimation+ : ModalRoute.of(context)?.animation ?? kAlwaysCompleteAnimation;return SliverPersistentHeader(pinned: true,@@ -115,6 +123,8 @@ class _AlbumCoverAppBarState extends State<AlbumCoverAppBar> with RouteAware {photo: _CoverPhoto(cover: widget.cover,backgroundColor: widget.backgroundColor,+ heroTag: widget.heroTag,+ contentOpacity: animation,),content: SizedBox(width: MediaQuery.sizeOf(context).width - Spacing.lg * 2,@@ -139,9 +149,7 @@ class _AlbumCoverAppBarState extends State<AlbumCoverAppBar> with RouteAware {if (description != null) ...[const SizedBox(height: Spacing.sm),Padding(- padding: const EdgeInsets.symmetric(- horizontal: _descriptionHorizontalInset,- ),+ padding: const EdgeInsets.symmetric(horizontal: Spacing.lg),child: Text(description,maxLines: _descriptionMaxLines,@@ -213,23 +221,209 @@ class AlbumCoverActionButton extends StatelessWidget {}class _CoverPhoto extends StatelessWidget {- const _CoverPhoto({required this.cover, required this.backgroundColor});+ const _CoverPhoto({+ required this.cover,+ required this.backgroundColor,+ this.heroTag,+ required this.contentOpacity,+ });+ final Animation<double> contentOpacity;final EnteFile cover;final Color backgroundColor;+ final String? heroTag;@overrideWidget build(BuildContext context) {- return Stack(+ final thumbnail = ThumbnailWidget(+ cover,+ rawThumbnail: true,+ thumbnailSize: thumbnailLargeSize,+ useRequestedThumbnailSizeForLocalCache: true,+ useCachedThumbnailAsPlaceholder: true,+ );+ final photo = Stack(fit: StackFit.expand,clipBehavior: Clip.none,children: [- ThumbnailWidget(- cover,- rawThumbnail: true,- thumbnailSize: thumbnailLargeSize,- useRequestedThumbnailSizeForLocalCache: true,+ thumbnail,+ _CoverPhotoScrims(backgroundColor: backgroundColor),+ ],+ );+ if (heroTag == null) {+ return photo;+ }+ const motionCurve = Curves.easeInOut;+ return Hero(+ tag: heroTag!,+ curve: motionCurve,+ reverseCurve: motionCurve,+ transitionOnUserGestures: true,+ placeholderBuilder: (context, size, child) =>+ SizedBox.fromSize(size: size, child: child),+ flightShuttleBuilder:+ (+ flightContext,+ animation,+ flightDirection,+ fromHeroContext,+ toHeroContext,+ ) {+ final cardContext = flightDirection == HeroFlightDirection.push+ ? fromHeroContext+ : toHeroContext;+ final coverContext = flightDirection == HeroFlightDirection.push+ ? toHeroContext+ : fromHeroContext;+ var card = (cardContext.widget as Hero).child;+ if (card is SizedBox && card.child != null) {+ card = card.child!;+ }+ final SmoothBorderRadius cardRadius;+ if (card is ClipSmoothRect) {+ cardRadius = card.radius;+ card = card.child;+ } else if (card is ClipRRect) {+ final radius = card.borderRadius.resolve(+ Directionality.of(cardContext),+ );+ cardRadius = SmoothBorderRadius.only(+ topLeft: SmoothRadius(+ cornerRadius: radius.topLeft.x,+ cornerSmoothing: 0,+ ),+ topRight: SmoothRadius(+ cornerRadius: radius.topRight.x,+ cornerSmoothing: 0,+ ),+ bottomLeft: SmoothRadius(+ cornerRadius: radius.bottomLeft.x,+ cornerSmoothing: 0,+ ),+ bottomRight: SmoothRadius(+ cornerRadius: radius.bottomRight.x,+ cornerSmoothing: 0,+ ),+ );+ card = card.child!;+ } else {+ cardRadius = SmoothBorderRadius.zero;+ }+ final image =+ _heroImage(fromHeroContext) ?? _heroImage(cardContext);+ return _CoverHeroFlight(+ animation: (ModalRoute.of(coverContext)! as PageRoute).animation!+ .drive(CurveTween(curve: motionCurve)),+ image: image?.image,+ contentOpacity: contentOpacity,+ card: card,+ showVideoIcon: cover.fileType == FileType.video,+ cardRadius: cardRadius,+ backgroundColor: backgroundColor,+ );+ },+ child: photo,+ );+ }+}++RenderImage? _heroImage(BuildContext context) {+ RenderImage? image;+ void visit(RenderObject renderObject) {+ if (renderObject is RenderImage && renderObject.image != null) {+ image ??= renderObject;+ } else if (image == null) {+ renderObject.visitChildren(visit);+ }+ }++ final renderObject = context.findRenderObject();+ if (renderObject != null) {+ visit(renderObject);+ }+ return image;+}++class _CoverHeroFlight extends StatefulWidget {+ const _CoverHeroFlight({+ required this.animation,+ required this.contentOpacity,+ required this.image,+ required this.card,+ required this.showVideoIcon,+ required this.cardRadius,+ required this.backgroundColor,+ });++ final Animation<double> animation;+ final Animation<double> contentOpacity;+ final ui.Image? image;+ final Widget card;+ final bool showVideoIcon;+ final SmoothBorderRadius cardRadius;+ final Color backgroundColor;++ @override+ State<_CoverHeroFlight> createState() => _CoverHeroFlightState();+}++class _CoverHeroFlightState extends State<_CoverHeroFlight> {+ late final ui.Image? _image = widget.image?.clone();++ @override+ void dispose() {+ _image?.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ return FadeTransition(+ opacity: ReverseAnimation(widget.contentOpacity),+ child: AnimatedBuilder(+ animation: widget.animation,+ child: Stack(+ fit: StackFit.expand,+ children: [+ if (_image != null)+ RawImage(image: _image, fit: BoxFit.cover)+ else+ widget.card,+ if (_image != null && widget.showVideoIcon)+ FadeTransition(+ opacity: ReverseAnimation(widget.animation),+ child: const VideoOverlayIcon(),+ ),+ FadeTransition(+ opacity: widget.animation,+ child: _CoverPhotoScrims(backgroundColor: widget.backgroundColor),+ ),+ ],),+ builder: (context, child) => ClipSmoothRect(+ radius: SmoothBorderRadius.lerp(+ widget.cardRadius,+ SmoothBorderRadius.zero,+ widget.animation.value,+ )!,+ child: child!,+ ),+ ),+ );+ }+}++class _CoverPhotoScrims extends StatelessWidget {+ const _CoverPhotoScrims({required this.backgroundColor});++ final Color backgroundColor;++ @override+ Widget build(BuildContext context) {+ return Stack(+ fit: StackFit.expand,+ clipBehavior: Clip.none,+ children: [const ColoredBox(color: _photoScrimColor),Positioned(left: 0,@@ -250,13 +444,17 @@ class _CoverPhoto extends StatelessWidget {width: _contentScrimWidth + _contentScrimBlur * 4,height: _contentScrimHeight + _contentScrimBlur * 4,child: IgnorePointer(- child: ClipRect(- child: ImageFiltered(- imageFilter: ui.ImageFilter.blur(- sigmaX: _contentScrimBlur,- sigmaY: _contentScrimBlur,+ child: RepaintBoundary(+ child: ClipRect(+ child: ImageFiltered(+ imageFilter: ui.ImageFilter.blur(+ sigmaX: _contentScrimBlur,+ sigmaY: _contentScrimBlur,+ ),+ child: const CustomPaint(+ painter: _CoverContentScrimPainter(),+ ),),- child: const CustomPaint(painter: _CoverContentScrimPainter()),),),),@@ -510,7 +708,7 @@ class _AlbumCoverDelegate extends SliverPersistentHeaderDelegate {left: 0,right: 0,bottom: coverBottomInset - 1,- child: photo,+ child: HeroMode(enabled: collapseOffset == 0, child: photo),),Positioned(top: 0,@@ -633,7 +831,6 @@ const _pinnedFadeStart = 0.6;const _foregroundSwitchStart = 0.4;const _foregroundSwitchEnd = 0.6;const _descriptionMaxLines = 3;-const _descriptionHorizontalInset = 18.0;const _coverActionSize = 42.0;const _coverActionIconSize = 17.0;diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dartindex 14a6c52d5a..23a46d53bd 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart@@ -41,7 +41,6 @@ import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dartimport "package:photos/ui/viewer/gallery/swipe_selection_wrapper.dart";import "package:photos/ui/viewer/gallery/swipe_to_select_helper.dart";import "package:photos/utils/hierarchical_search_util.dart";-import "package:photos/utils/misc_util.dart";import "package:photos/utils/widget_util.dart";typedef GalleryLoader =@@ -172,7 +171,6 @@ class GalleryState extends State<Gallery> {final _scrollController = ScrollController();final _headerKey = GlobalKey();final _headerHeightNotifier = ValueNotifier<double?>(null);- final miscUtil = MiscUtil();final scrollBarInUseNotifier = ValueNotifier<bool>(false);late GroupType _groupType;final scrollbarBottomPaddingNotifier = ValueNotifier<double>(0);@@ -331,22 +329,10 @@ class GalleryState extends State<Gallery> {});}- WidgetsBinding.instance.addPostFrameCallback((_) async {- _selectedFilesListener();- try {- final headerRenderBox = await miscUtil- .getNonNullValueWithRetry(- () => _headerKey.currentContext?.findRenderObject(),- retryInterval: const Duration(milliseconds: 750),- id: "headerRenderBox",- )- .then((value) => value as RenderBox);-- _headerHeightNotifier.value = headerRenderBox.size.height;- } catch (e, s) {- _logger.warning("Error getting renderBox offset", e, s);+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (mounted) {+ _selectedFilesListener();}- setState(() {});});widget.selectedFiles?.addListener(_selectedFilesListener);@@ -921,6 +907,16 @@ class GalleryState extends State<Gallery> {});}+ if (_headerHeightNotifier.value == null && _allGalleryFiles.isNotEmpty) {+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (!mounted) return;+ final renderBox = _headerKey.currentContext?.findRenderObject();+ if (renderBox is RenderBox && renderBox.hasSize) {+ _headerHeightNotifier.value = renderBox.size.height;+ }+ });+ }+return SwipeSelectionWrapper(isEnabled: shouldEnableSwipeSelection && !widget.disableSelection,swipeHelper: _swipeHelper,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.dartindex 0aa182c0c8..242dffbcf1 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@@ -77,6 +77,8 @@ class GalleryAppBarWidget extends StatefulWidget {Future<void> Function()? onDisableDeviceFolderBackup,Collection? collection,EnteFile? cover,+ String? coverHeroTag,+ Key? coverAppBarKey,List<EnteFile>? files,PreferredSizeWidget? bottom,bool showOverflowMenu = true,@@ -93,6 +95,8 @@ class GalleryAppBarWidget extends StatefulWidget {onDisableDeviceFolderBackup: onDisableDeviceFolderBackup,collection: collection,cover: cover,+ coverHeroTag: coverHeroTag,+ coverAppBarKey: coverAppBarKey,files: files,bottom: bottom,showOverflowMenu: showOverflowMenu,@@ -159,6 +163,8 @@ class GalleryAppBarWidget extends StatefulWidget {final Future<void> Function()? onDisableDeviceFolderBackup;final Collection? collection;final EnteFile? cover;+ final String? coverHeroTag;+ final Key? coverAppBarKey;final List<EnteFile>? files;final PreferredSizeWidget? bottom;final bool showOverflowMenu;@@ -173,6 +179,8 @@ class GalleryAppBarWidget extends StatefulWidget {this.onDisableDeviceFolderBackup,this.collection,this.cover,+ this.coverHeroTag,+ this.coverAppBarKey,this.files,this.bottom,required this.showOverflowMenu,@@ -332,7 +340,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {preferredSize: Size.fromHeight(AppBarFilterChips.preferredHeight(context),),- child: const AppBarFilterChips(),+ child: AppBarFilterChips(animateRecommendations: widget.cover != null),),builder: (context, isSearching, child) {if (widget.cover != null && !isSearching) {@@ -352,8 +360,10 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {Widget _albumCoverAppBar({PreferredSizeWidget? bottom}) {final strings = context.strings;return AlbumCoverAppBar(+ key: widget.coverAppBarKey,collection: widget.collection!,cover: widget.cover!,+ heroTag: widget.coverHeroTag,title: _appBarTitle,backgroundColor: GalleryAppBarWidget.backgroundColor(context),collapsedHeight: GalleryAppBarWidget.toolbarHeight,diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dartindex 0832ab0c78..f53b0f47e5 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dart@@ -101,6 +101,7 @@ class _SharedPublicCollectionPageStateawait routeToPage(context,CollectionPage(CollectionWithThumbnail(c!, null)),+ forceCustomPageRoute: true,);} catch (e, s) {logger.severe("Failed to join public album", e, s);@@ -249,6 +250,7 @@ class _SharedPublicCollectionPageStateawait routeToPage(context,CollectionPage(CollectionWithThumbnail(c!, null)),+ forceCustomPageRoute: true,);} catch (e, s) {logger.severe("Failed to join collection", e, s);diff --git a/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/app_bar_filter_chips.dart b/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/app_bar_filter_chips.dartindex c247a18608..7e9b3d4168 100644--- a/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/app_bar_filter_chips.dart+++ b/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/app_bar_filter_chips.dart@@ -10,7 +10,9 @@ import "package:photos/ui/viewer/hierarchicial_search/filter_options_bottom_sheeimport "package:photos/utils/hierarchical_search_util.dart";class AppBarFilterChips extends StatefulWidget {- const AppBarFilterChips({super.key});+ const AppBarFilterChips({super.key, this.animateRecommendations = false});++ final bool animateRecommendations;static const bottomPadding = 8.0;@@ -87,13 +89,13 @@ class _AppBarFilterChipsState extends State<AppBarFilterChips> {final recommendations = getRecommendedFiltersForAppBar(searchFilterDataProvider,);- if (appliedFilters.isEmpty && recommendations.isEmpty) {+ final hasFilters = appliedFilters.isNotEmpty || recommendations.isNotEmpty;+ if (!hasFilters && !widget.animateRecommendations) {return const SizedBox.shrink();}final chipHeight = AppBarFilterChips.chipHeight(context);-- return Padding(+ final chips = Padding(padding: const EdgeInsets.only(bottom: AppBarFilterChips.bottomPadding),child: SizedBox(width: double.infinity,@@ -103,11 +105,12 @@ class _AppBarFilterChipsState extends State<AppBarFilterChips> {padding: const EdgeInsets.symmetric(horizontal: 4),child: Row(children: [- _buildAllFiltersButton(- context,- searchFilterDataProvider,- chipHeight,- ),+ if (hasFilters)+ _buildAllFiltersButton(+ context,+ searchFilterDataProvider,+ chipHeight,+ ),for (final filter in appliedFilters)Padding(padding: const EdgeInsets.symmetric(horizontal: 4),@@ -123,6 +126,16 @@ class _AppBarFilterChipsState extends State<AppBarFilterChips> {),),);+ return widget.animateRecommendations+ ? AnimatedOpacity(+ opacity: hasFilters ? 1 : 0,+ duration: MediaQuery.disableAnimationsOf(context)+ ? Duration.zero+ : const Duration(milliseconds: 180),+ curve: Curves.easeInOut,+ child: chips,+ )+ : chips;}Widget _buildAllFiltersButton(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.dartindex 8ee661580e..062351fc21 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@@ -225,6 +225,7 @@ class _SearchSectionAllPageState extends State<SearchSectionAllPage> {result.collectionWithThumbnail,tagPrefix: "searchable_item" + result.heroTag(),),+ forceCustomPageRoute: true,);},);diff --git a/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart b/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dartindex a4e2cf3bbb..6a7cd2a4fc 100644--- a/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart@@ -239,6 +239,7 @@ class SearchResultsWidgetGenerator extends StatelessWidget {albumSearchResult.collectionWithThumbnail,tagPrefix: result.heroTag(),),+ forceCustomPageRoute: true,),);} else if (result is DeviceAlbumSearchResult) {diff --git a/mobile/apps/photos/test/ui/viewer/gallery/album_cover_app_bar_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/album_cover_app_bar_test.dartindex 3b76937c91..fa045fac02 100644--- a/mobile/apps/photos/test/ui/viewer/gallery/album_cover_app_bar_test.dart+++ b/mobile/apps/photos/test/ui/viewer/gallery/album_cover_app_bar_test.dart@@ -4,8 +4,8 @@ import "dart:convert";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:flutter/material.dart";import "package:flutter/services.dart";-import "package:flutter_test/flutter_test.dart";import "package:flutter_localizations/flutter_localizations.dart";+import "package:flutter_test/flutter_test.dart";import "package:intl/date_symbol_data_local.dart";import "package:photos/core/cache/thumbnail_in_memory_cache.dart";import "package:photos/core/page_route_observer.dart";diff --git a/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dartindex 42730e69e5..49113e1b16 100644--- a/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dart+++ b/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dart@@ -3,6 +3,7 @@ import "dart:io";import "package:dio/dio.dart";import "package:ente_strings/ente_strings.dart";+import "package:figma_squircle/figma_squircle.dart";import "package:flutter/material.dart";import "package:flutter_test/flutter_test.dart";import "package:package_info_plus/package_info_plus.dart";@@ -22,13 +23,19 @@ import "package:photos/models/file/file.dart";import "package:photos/models/file/file_type.dart";import "package:photos/models/ignored_file.dart";import "package:photos/models/metadata/collection_magic.dart";+import "package:photos/models/search/hierarchical/file_type_filter.dart";+import "package:photos/module/download/thumbnail.dart";import "package:photos/service_locator.dart";import "package:photos/services/collections_service.dart";import "package:photos/services/favorites_service.dart";import "package:photos/services/ignored_files_service.dart";+import "package:photos/ui/collections/album/row_item.dart";import "package:photos/ui/viewer/gallery/collection_page.dart";import "package:photos/ui/viewer/gallery/component/album_cover_app_bar.dart";import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";+import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dart";+import "package:photos/ui/viewer/gallery/state/search_filter_data_provider.dart";+import "package:photos/ui/viewer/hierarchicial_search/app_bar_filter_chips.dart";import "package:shared_preferences/shared_preferences.dart";void main() {@@ -73,6 +80,60 @@ void main() {await tempDir.delete(recursive: true);});+ for (final disableAnimations in [false, true]) {+ testWidgets(+ "fades late album recommendations with reduced motion $disableAnimations",+ (tester) async {+ final provider = SearchFilterDataProvider(+ initialGalleryFilter: FileTypeFilter(+ fileType: FileType.video,+ typeName: "Videos",+ occurrence: 1,+ ),+ );+ await tester.pumpWidget(+ MaterialApp(+ theme: lightThemeData,+ localizationsDelegates: StringsLocalizations.localizationsDelegates,+ supportedLocales: StringsLocalizations.supportedLocales,+ home: MediaQuery(+ data: MediaQueryData(disableAnimations: disableAnimations),+ child: InheritedSearchFilterDataWrapper(+ searchFilterDataProvider: provider,+ child: const Scaffold(+ body: AppBarFilterChips(animateRecommendations: true),+ ),+ ),+ ),+ ),+ );+ provider.clearAndAddRecommendations([+ FileTypeFilter(+ fileType: FileType.image,+ typeName: "Photos",+ occurrence: 1,+ ),+ ]);+ await tester.pump();+ final fade = find+ .descendant(+ of: find.byType(AnimatedOpacity),+ matching: find.byType(FadeTransition),+ )+ .first;+ double opacity() => tester.widget<FadeTransition>(fade).opacity.value;+ expect(opacity(), disableAnimations ? 1 : 0);+ await tester.pump(const Duration(milliseconds: 90));+ if (!disableAnimations) {+ expect(opacity(), inExclusiveRange(0, 1));+ }+ await tester.pumpAndSettle();+ expect(opacity(), 1);+ await tester.pumpWidget(const SizedBox.shrink());+ },+ );+ }+testWidgets("uses a pending local photo and excludes ignored photos", (tester,) async {@@ -151,6 +212,145 @@ void main() {await _disposeAlbum(tester);},);++ for (final platform in [TargetPlatform.iOS, TargetPlatform.android]) {+ testWidgets(+ "animates the album thumbnail into the header on ${platform.name}",+ (tester) async {+ final collection = _collection();+ final oldest = _file(1);+ final newest = _file(2);+ ThumbnailInMemoryLruCache.clearCache(newest);+ ThumbnailInMemoryLruCache.put(+ newest,+ base64Decode(_onePixelPng),+ thumbnailSmallSize,+ );+ await tester.runAsync(() async {+ await FilesDB.instance.insertMultiple([oldest, newest]);+ expect(+ await CollectionsService.instance.getCover(collection),+ newest,+ );+ await cachedThumbnailPath(+ newest,+ ).writeAsBytes(base64Decode(_onePixelPng));+ });+ await tester.pumpWidget(+ MaterialApp(+ theme: lightThemeData.copyWith(platform: platform),+ localizationsDelegates: StringsLocalizations.localizationsDelegates,+ supportedLocales: StringsLocalizations.supportedLocales,+ home: Scaffold(+ body: Align(+ alignment: Alignment.topLeft,+ child: AlbumRowItemWidget(collection, 100),+ ),+ ),+ ),+ );+ await tester.pumpAndSettle();+ final heroTag = "collection_1${newest.tag}";+ expect(+ tester.widgetList<Hero>(find.byType(Hero)).map((hero) => hero.tag),+ contains(heroTag),+ );++ await tester.tap(+ find.byWidgetPredicate(+ (widget) => widget is Hero && widget.tag == heroTag,+ ),+ );+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 75));+ final route = ModalRoute.of(+ tester.element(find.byType(CollectionPage)),+ )!;+ expect(route, isA<PageRouteBuilder>());+ expect(route.transitionDuration, const Duration(milliseconds: 200));+ expect(+ route.reverseTransitionDuration,+ const Duration(milliseconds: 300),+ );+ final pageFade = find+ .ancestor(+ of: find.byType(CollectionPage),+ matching: find.byType(FadeTransition),+ )+ .first;+ final opacity = tester.widget<FadeTransition>(pageFade).opacity.value;+ expect(opacity, inExclusiveRange(0, 1));+ final flightClip = find.ancestor(+ of: find.byType(RawImage),+ matching: find.byType(ClipSmoothRect),+ );+ final radius = tester+ .widget<ClipSmoothRect>(flightClip)+ .radius+ .topLeft+ .x;+ expect(radius, inExclusiveRange(0, 20));+ Navigator.of(tester.element(find.byType(CollectionPage))).pop();+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 30));+ expect(+ tester.widget<FadeTransition>(pageFade).opacity.value,+ lessThan(opacity),+ );+ expect(+ tester.widget<ClipSmoothRect>(flightClip).radius.topLeft.x,+ greaterThan(radius),+ );+ await tester.pumpAndSettle();+ expect(tester.takeException(), isNull);+ await tester.tap(+ find.byWidgetPredicate(+ (widget) => widget is Hero && widget.tag == heroTag,+ ),+ );+ await tester.pumpAndSettle();+ await _expectCover(tester, newest, count: 2);+ expect(+ find.descendant(+ of: find.byType(AlbumCoverAppBar),+ matching: find.byType(Image),+ ),+ findsOneWidget,+ );+ final headerHero = find.descendant(+ of: find.byType(AlbumCoverAppBar),+ matching: find.byType(Hero),+ );+ expect(tester.widget<Hero>(headerHero).tag, heroTag);+ final tags = tester+ .widgetList<Hero>(+ find.descendant(+ of: find.byType(CollectionPage),+ matching: find.byType(Hero),+ ),+ )+ .map((hero) => hero.tag)+ .toList();+ expect(tags.toSet().length, tags.length);++ collection.pubMagicMetadata = CollectionPubMagicMetadata(asc: true);+ Bus.instance.fire(+ CollectionMetaEvent(+ collection.id,+ CollectionMetaEventType.sortChanged,+ ),+ );+ await _expectCover(tester, oldest, count: 2);+ expect(tester.widget<Hero>(headerHero).tag, heroTag);++ Navigator.of(tester.element(find.byType(CollectionPage))).pop();+ await tester.pumpAndSettle();+ expect(find.byType(AlbumRowItemWidget), findsOneWidget);+ expect(tester.takeException(), isNull);+ await _disposeAlbum(tester);+ },+ );+ }}Collection _collection() => Collection(@@ -256,6 +456,9 @@ class _FakePathProvider extends PathProviderPlatform {@overrideFuture<String?> getApplicationSupportPath() async => path;++ @override+ Future<String?> getTemporaryPath() async => path;}const _onePixelPng =