From dbb94e50f69970a0568afea7113fe68ed9af88b1 Mon Sep 17 00:00:00 2001 From: Hamlet Jiang Su Date: Tue, 22 Oct 2024 10:09:10 -0700 Subject: [PATCH] feat: switch short press and long press comment navigator functions --- lib/shared/comment_navigator_fab.dart | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/shared/comment_navigator_fab.dart b/lib/shared/comment_navigator_fab.dart index d2a3a1a1f..dddbafb83 100644 --- a/lib/shared/comment_navigator_fab.dart +++ b/lib/shared/comment_navigator_fab.dart @@ -86,8 +86,8 @@ class _CommentNavigatorFabState extends State { color: Colors.transparent, child: InkWell( borderRadius: BorderRadius.circular(50), - onTap: navigateUp, - onLongPress: navigateToParent, + onTap: navigateToParent, + onLongPress: navigateUp, child: Icon( Icons.keyboard_arrow_up_rounded, semanticLabel: AppLocalizations.of(context)!.navigateUp, @@ -104,8 +104,8 @@ class _CommentNavigatorFabState extends State { color: Colors.transparent, child: InkWell( borderRadius: BorderRadius.circular(50), - onTap: navigateDown, - onLongPress: navigateToNextParent, + onTap: navigateToNextParent, + onLongPress: navigateDown, child: Icon( Icons.keyboard_arrow_down_rounded, semanticLabel: AppLocalizations.of(context)!.navigateDown, @@ -140,6 +140,13 @@ class _CommentNavigatorFabState extends State { } void navigateToParent() { + if (widget.comments == null) { + // This is a placeholder to allow the previous post page to function correctly. + // TODO: Remove this logic when we deprecate the legacy post page + navigateUp(); + return; + } + var unobstructedVisibleRange = widget.listController.unobstructedVisibleRange; int previousIndex = (unobstructedVisibleRange?.$1 ?? 0) - 1; @@ -189,6 +196,13 @@ class _CommentNavigatorFabState extends State { } void navigateToNextParent() { + if (widget.comments == null) { + // This is a placeholder to allow the previous post page to function correctly. + // TODO: Remove this logic when we deprecate the legacy post page + navigateDown(); + return; + } + var unobstructedVisibleRange = widget.listController.unobstructedVisibleRange; int nextIndex = (unobstructedVisibleRange?.$1 ?? 0) + 1;