-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Back swipe hero #23320
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
Back swipe hero #23320
Conversation
HansMuller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good API change. I had a few comments about the details.
|
|
||
| // Called by _CupertinoBackGestureDetector when a pop ("back") drag start | ||
| // gesture is detected. The returned controller handles all of the subsquent | ||
| // gesture is detected. The returned controller handles all of the subsequent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NICE
| this.createRectTween, | ||
| this.flightShuttleBuilder, | ||
| this.placeholderBuilder, | ||
| this.transitionForUserGestures = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just bike shedding.
We call methods or callbacks that are triggered by "foo" onFoo. Since we're talking about a transition that's triggered by a user gesture here, maybe transitionOnUserGesture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is sensible
| final TransitionBuilder placeholderBuilder; | ||
|
|
||
| /// Whether to perform the hero transition if the [PageRoute] transition was | ||
| /// triggered by a user gesture such as a back swipe on iOS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user gesture, such as
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
| /// left in place once the Hero shuttle has taken flight. | ||
| final TransitionBuilder placeholderBuilder; | ||
|
|
||
| /// Whether to perform the hero transition if the [PageRoute] transition was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really just a transition, it's a pop transition, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Though from this perspective (docs of Hero), the reader shouldn't really be concerned about the direction of the transition.
| /// triggered by a user gesture such as a back swipe on iOS. | ||
| /// | ||
| /// If [Hero]s with the same [tag] on both the from and the to routes have | ||
| /// [transitionForUserGestures] set to true, a back swipe gesture will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "back swipe" gesture is too specific, it's just whatever "user gesture" triggered the call to Navigator.didStartUserGesture(). It's definitely useful to tie this stuff back to the iOS back gesture, since that's the only current user case. We just don't want to imply that other use cases aren't possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Though I'm not too sure what to put more specifically.
I think didStartUserGesture is a bit of an implementation detail (in terms of how the HeroController receives events but we can envision changing that implementation detail without having to change the 'API' in the future).
Since I can't think of a specific other use case for the trigger and it's API stable now, it's probably better to be very specific in the doc and later expand than trying to restrict the API in the future.
| } | ||
|
|
||
| // Find the matching pairs of heros in from and to and either start or a new | ||
| // Find the matching pairs of heroes in from and to and either start or a new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NICE
| PageRoute<dynamic> to, | ||
| Animation<double> animation, | ||
| HeroFlightDirection flightType, | ||
| bool fromGesture, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as before about this parameter name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| /// | ||
| /// If present, the route immediately below `route` is `previousRoute`. | ||
| /// Though the gesture may not necessarily conclude at `previousRoute` if | ||
| /// canceled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
canceled => it is canceled.
Perhaps it's obvious but it seems like it would be worth explaining how a pop might be canceled and what that means vis didStopUserGesture().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a bit more details.
| void didReplace({ Route<dynamic> newRoute, Route<dynamic> oldRoute }) { } | ||
|
|
||
| /// The [Navigator]'s routes are being moved by a user gesture. | ||
| /// The [Navigator]'s route `route` is being moved by a user gesture. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should explain who needs to call this and when. From the sound of it, it's just a notification.
The doc should link to and summarize the role of didStopUserGesture as well as Hero.transitionFromUserGestures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cross referenced didStopUserGesture.
Though this is a more generic callback API than heroes. We should probably not reference users of the API from the API.
| _userGesturesInProgress += 1; | ||
| if (_userGesturesInProgress == 1) { | ||
| final Route<dynamic> route = _history.last; | ||
| final Route<dynamic> previousRoute = route.willHandlePopInternally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final Route<dynamic> previousRoute = route.willHandlePopInternally || history.length < 2
? null
: _history[_history.length - 2]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shortened.
HansMuller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #9446
Lets Heroes be initiated from a back swipe gesture.
Changes signature for NavigatorObserver.didStartUserGesture from
to
Measures and inserts hero flight into overlay on first frame.
Use in Cupertino nav bars.
Breaking signature announce: https://groups.google.com/forum/#!topic/flutter-dev/SBAlcp6W_3g