π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Disable forward feed hero for comment and reply items
ashilkn31cb983b7538
diff --git a/mobile/apps/photos/lib/ui/social/feed_screen.dart b/mobile/apps/photos/lib/ui/social/feed_screen.dartindex d2504f7c88..5322eea7b3 100644--- a/mobile/apps/photos/lib/ui/social/feed_screen.dart+++ b/mobile/apps/photos/lib/ui/social/feed_screen.dart@@ -102,6 +102,7 @@ class _FeedScreenState extends State<FeedScreen> {FeedNavigationTarget? _pendingNavigationTarget;bool _didHandleNavigationTarget = false;bool _isOpeningNavigationTarget = false;+ final Set<String> _suppressedForwardHeroPrefixes = <String>{};final ScrollController _scrollController = ScrollController();final GlobalKey _navigationTargetItemKey = GlobalKey();@@ -559,6 +560,10 @@ class _FeedScreenState extends State<FeedScreen> {final isLastItem = index == _feedItems.length - 1;final itemKey = _feedItemStableKey(item);final heroTagPrefix = _heroTagPrefixForFeedItem(item);+ final isForwardHeroSuppressed =+ _suppressedForwardHeroPrefixes.contains(+ heroTagPrefix,+ );final key = _shouldUseNavigationTargetKey(item)? _navigationTargetItemKey: ValueKey(itemKey);@@ -566,6 +571,7 @@ class _FeedScreenState extends State<FeedScreen> {key: key,feedItem: item,heroTagPrefix: heroTagPrefix,+ enableThumbnailHero: !isForwardHeroSuppressed,currentUserID: _currentUserID,anonDisplayNames:_anonDisplayNamesByCollection[item.collectionID] ??@@ -645,6 +651,12 @@ class _FeedScreenState extends State<FeedScreen> {break;case FeedItemType.comment:case FeedItemType.reply:+ _openComments(+ item,+ heroTagPrefix: heroTagPrefix,+ disableForwardHero: true,+ );+ break;case FeedItemType.commentLike:case FeedItemType.replyLike:_openComments(item, heroTagPrefix: heroTagPrefix);@@ -723,7 +735,11 @@ class _FeedScreenState extends State<FeedScreen> {}/// Opens the photo viewer for the feed item, then shows the comments sheet.- Future<void> _openComments(FeedItem item, {String? heroTagPrefix}) async {+ Future<void> _openComments(+ FeedItem item, {+ String? heroTagPrefix,+ bool disableForwardHero = false,+ }) async {var fileID = item.fileID;if (fileID == null && item.commentID != null) {@@ -733,6 +749,9 @@ class _FeedScreenState extends State<FeedScreen> {}if (fileID == null) return;+ final shouldDisableForwardHero = disableForwardHero &&+ heroTagPrefix != null &&+ !_suppressedForwardHeroPrefixes.contains(heroTagPrefix);final file = await FilesDB.instance.getUploadedFile(fileID,@@ -741,6 +760,13 @@ class _FeedScreenState extends State<FeedScreen> {if (file == null || !mounted) return;final capturedFileID = fileID;+ if (shouldDisableForwardHero) {+ setState(() {+ _suppressedForwardHeroPrefixes.add(heroTagPrefix);+ });+ await WidgetsBinding.instance.endOfFrame;+ if (!mounted) return;+ }// Navigate to the photo first, then show comments sheet after first frameunawaited(@@ -764,6 +790,15 @@ class _FeedScreenState extends State<FeedScreen> {forceCustomPageRoute: true,),);+ if (shouldDisableForwardHero) {+ unawaited(() async {+ await WidgetsBinding.instance.endOfFrame;+ if (!mounted) return;+ setState(() {+ _suppressedForwardHeroPrefixes.remove(heroTagPrefix);+ });+ }());+ }}/// Opens the photo viewer for the feed item.diff --git a/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart b/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dartindex 64905d3d06..b716a4d282 100644--- a/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart+++ b/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart@@ -18,6 +18,7 @@ import "package:photos/ui/viewer/file/thumbnail_widget.dart";class FeedItemWidget extends StatelessWidget {final FeedItem feedItem;final String heroTagPrefix;+ final bool enableThumbnailHero;final int currentUserID;/// Called when the user taps anywhere on the feed item.@@ -38,6 +39,7 @@ class FeedItemWidget extends StatelessWidget {const FeedItemWidget({required this.feedItem,required this.heroTagPrefix,+ this.enableThumbnailHero = true,required this.currentUserID,this.onTap,this.onSharedPhotoTap,@@ -116,6 +118,7 @@ class FeedItemWidget extends StatelessWidget {fileID: feedItem.fileID!,collectionID: feedItem.collectionID,heroTagPrefix: heroTagPrefix,+ enableHeroAnimation: enableThumbnailHero,),)else@@ -670,11 +673,13 @@ class _FeedThumbnail extends StatefulWidget {final int fileID;final int collectionID;final String heroTagPrefix;+ final bool enableHeroAnimation;const _FeedThumbnail({required this.fileID,required this.collectionID,required this.heroTagPrefix,+ required this.enableHeroAnimation,});@override@@ -745,27 +750,33 @@ class _FeedThumbnailState extends State<_FeedThumbnail> {);}- return Hero(- tag: widget.heroTagPrefix + _file!.tag,- child: Container(- decoration: BoxDecoration(- borderRadius: BorderRadius.circular(9),- border: Border.all(color: colorScheme.strokeFaint),- ),- child: ClipRRect(- borderRadius: BorderRadius.circular(8),- child: SizedBox(- width: 66,- height: 66,- child: ThumbnailWidget(- _file!,- fit: BoxFit.cover,- rawThumbnail: true,- ),+ final thumbnail = Container(+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(9),+ border: Border.all(color: colorScheme.strokeFaint),+ ),+ child: ClipRRect(+ borderRadius: BorderRadius.circular(8),+ child: SizedBox(+ width: 66,+ height: 66,+ child: ThumbnailWidget(+ _file!,+ fit: BoxFit.cover,+ rawThumbnail: true,),),),);++ if (!widget.enableHeroAnimation) {+ return thumbnail;+ }++ return Hero(+ tag: widget.heroTagPrefix + _file!.tag,+ child: thumbnail,+ );}}