Skip to content

Commit

Permalink
feat: switch short press and long press comment navigator functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hjiangsu committed Oct 22, 2024
1 parent b281caf commit dbb94e5
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/shared/comment_navigator_fab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class _CommentNavigatorFabState extends State<CommentNavigatorFab> {
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,
Expand All @@ -104,8 +104,8 @@ class _CommentNavigatorFabState extends State<CommentNavigatorFab> {
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,
Expand Down Expand Up @@ -140,6 +140,13 @@ class _CommentNavigatorFabState extends State<CommentNavigatorFab> {
}

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;
Expand Down Expand Up @@ -189,6 +196,13 @@ class _CommentNavigatorFabState extends State<CommentNavigatorFab> {
}

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;
Expand Down

0 comments on commit dbb94e5

Please sign in to comment.