π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add tap-to-scroll for parent comment quotes
ashilkndc867c5cb619
diff --git a/mobile/apps/photos/lib/ui/social/comments_screen.dart b/mobile/apps/photos/lib/ui/social/comments_screen.dartindex 8b83718a05..f46b9d7ccf 100644--- a/mobile/apps/photos/lib/ui/social/comments_screen.dart+++ b/mobile/apps/photos/lib/ui/social/comments_screen.dart@@ -130,6 +130,8 @@ class _FileCommentsBottomSheetState extends State<FileCommentsBottomSheet> {String? _highlightedCommentID;bool _hasScrolledToHighlight = false;GlobalKey? _highlightedCommentKey;+ String? _scrollTargetCommentID;+ GlobalKey? _scrollTargetKey;List<CollectionCommentInfo> _sharedCollections = [];late int _selectedCollectionID;@@ -364,6 +366,71 @@ class _FileCommentsBottomSheetState extends State<FileCommentsBottomSheet> {});}+ Future<void> _scrollToParentComment(String parentCommentID) async {+ _scrollTargetCommentID =+ parentCommentID; // Set immediately for race detection++ // Check if already loaded+ int index = _comments.indexWhere((c) => c.id == parentCommentID);++ if (index != -1) {+ _performScrollToIndex(index, parentCommentID);+ return;+ }++ // Parent not in loaded comments - need to load more+ while (_hasMoreComments) {+ await _loadMoreComments();++ // Check if user tapped a different parent (race condition)+ if (_scrollTargetCommentID != null &&+ _scrollTargetCommentID != parentCommentID) {+ return; // Abort, another scroll is in progress+ }++ index = _comments.indexWhere((c) => c.id == parentCommentID);+ if (index != -1) {+ _performScrollToIndex(index, parentCommentID);+ return;+ }+ }++ // Parent not found (deleted) - do nothing silently+ }++ void _performScrollToIndex(int index, String commentID) {+ _scrollTargetCommentID = commentID;+ _scrollTargetKey = GlobalKey();+ setState(() {});++ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (!mounted || !_scrollController.hasClients) return;++ // Phase 1: Jump to approximate position+ const estimatedItemHeight = 120.0;+ final maxScroll = _scrollController.position.maxScrollExtent;+ final scrollPosition =+ (index * estimatedItemHeight).clamp(0.0, maxScroll);+ _scrollController.jumpTo(scrollPosition);++ // Phase 2: Precise scroll with ensureVisible+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (!mounted) return;+ final context = _scrollTargetKey?.currentContext;+ if (context != null) {+ Scrollable.ensureVisible(+ context,+ duration: const Duration(milliseconds: 300),+ curve: Curves.easeOutExpo,+ );+ }+ // Clear scroll target after animation+ _scrollTargetCommentID = null;+ _scrollTargetKey = null;+ });+ });+ }+void _onCollectionSelected(int collectionID) {setState(() {_selectedCollectionID = collectionID;@@ -606,10 +673,13 @@ class _FileCommentsBottomSheetState extends State<FileCommentsBottomSheet> {final isHighlighted =comment.id == _highlightedCommentID;// Use widget.highlightCommentID (not state) to keep key stable after dismiss+ // Priority: highlightCommentID (deep link) > scrollTargetCommentID (tap)final key =(comment.id == widget.highlightCommentID)? (_highlightedCommentKey ??= GlobalKey())- : ValueKey(comment.id);+ : (comment.id == _scrollTargetCommentID)+ ? _scrollTargetKey+ : ValueKey(comment.id);return CommentBubbleWidget(key: key,comment: comment,@@ -636,6 +706,11 @@ class _FileCommentsBottomSheetState extends State<FileCommentsBottomSheet> {// Don't clear _highlightedCommentKey - prevents avatar flicker}},+ onParentQuoteTap: comment.isReply+ ? () => _scrollToParentComment(+ comment.parentCommentID!,+ )+ : null,);},),diff --git a/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart b/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dartindex 3390e7f6ba..db7ba64abb 100644--- a/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart+++ b/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart@@ -44,6 +44,9 @@ class CommentBubbleWidget extends StatefulWidget {/// Callback invoked when auto-highlight animation completes (dismissed).final VoidCallback? onAutoHighlightDismissed;+ /// Callback invoked when the user taps on the parent quote preview.+ final VoidCallback? onParentQuoteTap;+const CommentBubbleWidget({required this.comment,required this.user,@@ -58,6 +61,7 @@ class CommentBubbleWidget extends StatefulWidget {this.onCommentDeleted,this.isHighlighted = false,this.onAutoHighlightDismissed,+ this.onParentQuoteTap,super.key,});@@ -540,6 +544,7 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget>parentComment: _parentComment,currentUserID: widget.currentUserID,userResolver: widget.userResolver,+ onParentQuoteTap: widget.onParentQuoteTap,),),Positioned(@@ -600,6 +605,7 @@ class _InlineParentQuote extends StatelessWidget {final bool isOwnComment;final int currentUserID;final User Function(Comment) userResolver;+ final VoidCallback? onTap;const _InlineParentQuote({required this.isLoading,@@ -607,6 +613,7 @@ class _InlineParentQuote extends StatelessWidget {required this.isOwnComment,required this.currentUserID,required this.userResolver,+ this.onTap,});@override@@ -652,7 +659,7 @@ class _InlineParentQuote extends StatelessWidget {? const Color(0xB3FFFFFF): const Color(0xB3000000);- return Container(+ final content = Container(margin: const EdgeInsets.only(bottom: 8),child: IntrinsicHeight(child: Row(@@ -702,6 +709,18 @@ class _InlineParentQuote extends StatelessWidget {),),);++ if (onTap != null) {+ return GestureDetector(+ onTap: () {+ HapticFeedback.lightImpact();+ onTap!();+ },+ behavior: HitTestBehavior.opaque,+ child: content,+ );+ }+ return content;}}@@ -712,6 +731,7 @@ class _CommentBubble extends StatelessWidget {final Comment? parentComment;final int currentUserID;final User Function(Comment) userResolver;+ final VoidCallback? onParentQuoteTap;const _CommentBubble({required this.comment,@@ -720,6 +740,7 @@ class _CommentBubble extends StatelessWidget {required this.parentComment,required this.currentUserID,required this.userResolver,+ this.onParentQuoteTap,});@override@@ -759,6 +780,7 @@ class _CommentBubble extends StatelessWidget {isOwnComment: isOwnComment,currentUserID: currentUserID,userResolver: userResolver,+ onTap: onParentQuoteTap,),Text(comment.data,