Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable gesture immediately on the underlying page when swiping back #140704

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

toda-bps
Copy link

@toda-bps toda-bps commented Dec 28, 2023

  • Introduce Navigator.popGestureStarted.
  • Enable gesture immediately on the underlying page when swiping back using CupertinoRouteTransitionMixin.
  • Add cupertino/page_transition_test.dart.

Fixes #48225.

The behavior fixed in this pull request will probably not be completely identical to iOS native, but it will improve the user experience over the current state.
(See also: #48225 (comment))

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Copy link

google-cla bot commented Dec 28, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository f: routes Navigator, Router, and related APIs. labels Dec 28, 2023
@MitchellGoodwin
Copy link
Contributor

Hi @toda-bps. Thank you for taking the time to put this PR together. Looks like there's some test failures in packages/flutter/test/cupertino/route_test.dart and packages/flutter/test/material/page_test.dart.

@toda-bps
Copy link
Author

toda-bps commented Jan 2, 2024

Looks like there's some test failures in packages/flutter/test/cupertino/route_test.dart and packages/flutter/test/material/page_test.dart.

@MitchellGoodwin

In my local environment, the tests cupertino/route_test.dart and material/page_test.dart pass.
(Also, all other tests have passed.)

route_test page_test
route_test page_test

Where can I find detailed logs of test failures?

Edit: These screenshots were a mistake: I checked out the wrong commit.

@MitchellGoodwin
Copy link
Contributor

MitchellGoodwin commented Jan 2, 2024

You can find logs by selecting "Details" next to a failed check -> then "View more details on flutter-dashboard" near the bottom -> then looking under Steps and Logs. Usually test_stdout is the most useful, but navigating through the block of text can be tough. At a glance, the tests do look related. If it's not failing locally, try rebasing, and see if they still pass. If they do, rebasing would rerun the tests on Github and it may be something unrelated. If they still fail, then there may be something different between your local and the testing environment that is causing the split. Or the tests running on different platforms is causing issues that aren't on your local.

Edit: oh, you found it while I was typing. Oops.

@github-actions github-actions bot added the f: material design flutter/packages/flutter/material repository. label Jan 2, 2024
@toda-bps toda-bps force-pushed the fix/48225 branch 2 times, most recently from 1da4ed3 to a944492 Compare January 3, 2024 07:43
@github-actions github-actions bot removed the f: material design flutter/packages/flutter/material repository. label Jan 3, 2024
* Introduce Navigator.popGestureStarted.

* Enable gesture immediately on the underlying page
  when swiping back using CupertinoRouteTransitionMixin.

* Add cupertino/page_transition_test.dart.
@toda-bps toda-bps changed the title Fix CupertinoPageTransition back gesture behavior Enable gesture immediately on the underlying page when swiping back Jan 3, 2024
@toda-bps
Copy link
Author

toda-bps commented Jan 3, 2024

I tried to fix the test failure, but realized that it was difficult to improve the swipeback behavior while preserving the existing behavior using the previous methods.

So, I implemented another method that allows Navigator to have a separate userGestureInProgress that indicates the start of the pop gesture.

This method improves swipeback behavior while allowing existing tests to pass.

However, I don't think this method is optimal because it adds a public property with limited use to Navigator, and I think it might be better to stop this PR.

I'd like to ask for some advice.

@MitchellGoodwin
Copy link
Contributor

I tried to fix the test failure, but realized that it was difficult to improve the swipeback behavior while preserving the existing behavior using the previous methods.

So, I implemented another method that allows Navigator to have a separate userGestureInProgress that indicates the start of the pop gesture.

This method improves swipeback behavior while allowing existing tests to pass.

However, I don't think this method is optimal because it adds a public property with limited use to Navigator, and I think it might be better to stop this PR.

I'd like to ask for some advice.

@chunhtai I'm not super familiar with navigator design. Can you take a look at this concern?

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@Piinks Piinks requested a review from chunhtai May 1, 2024 19:13
@@ -3516,6 +3516,9 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res

bool get _usingPagesAPI => widget.pages != const <Page<dynamic>>[];

/// Whether the route was started popping by user gesture.
bool popGestureStarted = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a confusing name, should probably called inAutomatedPopGesture, or finalizingPopGesture

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property contradict the userGestureInProgressNotifier, which is unfortunate.

It looks like userGestureInProgressNotifier needs a new name like userGestureDrivenPopInProgress, or update its logic to match its name. The former will be a breaking change, the latter will require making cupertinoPageTransition more resilient (See

// Keep the userGestureInProgress in true state since AndroidBackGesturePageTransitionsBuilder
)

@@ -957,8 +957,9 @@ class _ModalScopeState<T> extends State<_ModalScope<T>> {
builder: (BuildContext context, Widget? child) {
final bool ignoreEvents = _shouldIgnoreFocusRequest;
focusScopeNode.canRequestFocus = !ignoreEvents;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want user interaction, we should probably also allow request focus

@Piinks
Copy link
Contributor

Piinks commented May 22, 2024

Hey @toda-bps would you like to continue working on this PR and address the above feedback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: cupertino flutter/packages/flutter/cupertino repository f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS App Freeze for ~0.5 second on Swipe Back Gesture
4 participants