Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] Fix album cover Hero transitions in list view

r4khul9b21db380fa6
diff --git a/mobile/apps/photos/lib/ui/collections/album/list_item.dart b/mobile/apps/photos/lib/ui/collections/album/list_item.dart
index 67f6dff491..101829149d 100644
--- a/mobile/apps/photos/lib/ui/collections/album/list_item.dart
+++ b/mobile/apps/photos/lib/ui/collections/album/list_item.dart
@@ -21,6 +21,7 @@ class AlbumListItemWidget extends StatelessWidget {
getAvatarSize(AvatarType.medium) + getOverlapPadding(AvatarType.medium);
final Collection collection;
+ final String? tag;
final void Function(Collection)? onTapCallback;
final void Function(Collection)? onLongPressCallback;
final SelectedAlbums? selectedAlbums;
@@ -29,6 +30,7 @@ class AlbumListItemWidget extends StatelessWidget {
const AlbumListItemWidget(
this.collection, {
super.key,
+ this.tag,
this.onTapCallback,
this.onLongPressCallback,
this.selectedAlbums,
@@ -76,7 +78,15 @@ class AlbumListItemWidget extends StatelessWidget {
onLongPress: onLongPressCallback == null
? null
: () => onLongPressCallback!(collection),
- leading: AlbumListItemCover(collection: collection),
+ leading: AlbumListItemCover(
+ collection: collection,
+ heroTag: tag == null
+ ? null
+ : (isOwner ? "collection" : "shared_collection") +
+ tag! +
+ "_" +
+ collection.id.toString(),
+ ),
title: _buildTitle(
context,
showSharingIndicator: showSharingIndicator,
@@ -265,16 +275,18 @@ class AlbumListItemWidget extends StatelessWidget {
class AlbumListItemCover extends StatelessWidget {
const AlbumListItemCover({
required this.collection,
+ this.heroTag,
this.borderRadius = ThumbnailListItem.defaultLeadingRadius,
super.key,
});
final Collection collection;
+ final String? heroTag;
final double borderRadius;
@override
Widget build(BuildContext context) {
- return ClipRRect(
+ final cover = ClipRRect(
borderRadius: BorderRadius.circular(borderRadius),
child: SizedBox.expand(
child: FutureBuilder<EnteFile?>(
@@ -301,5 +313,12 @@ class AlbumListItemCover extends StatelessWidget {
),
),
);
+ if (heroTag == null) return cover;
+ return Hero(
+ tag: heroTag!,
+ createRectTween: (begin, end) => RectTween(begin: begin, end: end),
+ transitionOnUserGestures: true,
+ child: cover,
+ );
}
}
diff --git a/mobile/apps/photos/lib/ui/collections/flex_grid_view.dart b/mobile/apps/photos/lib/ui/collections/flex_grid_view.dart
index 7adf29f82c..84d0a778e3 100644
--- a/mobile/apps/photos/lib/ui/collections/flex_grid_view.dart
+++ b/mobile/apps/photos/lib/ui/collections/flex_grid_view.dart
@@ -340,6 +340,7 @@ class _CollectionsFlexiGridViewWidgetState
item = AlbumListItemWidget(
collection,
+ tag: widget.tag,
selectedAlbums: widget.selectedAlbums,
isSelected: selectionCallbacks?.isSelected(collection) ?? false,
onTapCallback: _handleCollectionTap,
diff --git a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart b/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
index d847c72e4b..abaae072cf 100644
--- a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
+++ b/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
@@ -1089,9 +1089,16 @@ class _AlbumsTabState extends State<AlbumsTab>
fit: StackFit.expand,
children: [
for (final previousChild in previousChildren)
- Positioned.fill(child: previousChild),
+ Positioned.fill(
+ child: HeroMode(
+ enabled: false,
+ child: previousChild,
+ ),
+ ),
if (currentChild != null)
- Positioned.fill(child: currentChild),
+ Positioned.fill(
+ child: HeroMode(child: currentChild),
+ ),
],
);
},