-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Make Cupertino page transitions match native behaviours #9138
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
Conversation
# Conflicts: # packages/flutter/lib/src/cupertino/page.dart
# Conflicts: # packages/flutter/test/material/page_test.dart
# Conflicts: # packages/flutter/lib/src/material/page.dart
| } | ||
| } | ||
|
|
||
| /// An animation of [double]s that tracks the sum of two given animations. |
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.
if we're going to just provide this class, we should change the example at CompoundAnimation to be an example we don't actually provide :-)
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.
looks like you don't need this class after all so you can remove it and get away without changing the example. :-)
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.
ya, reverted. Thanks
| @required Animation<double> outgoingRouteAnimation, | ||
| @required this.child, | ||
| }) | ||
| : incomingPositionAnimation = _kRightMiddleTween.animate( |
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.
nit: the : should be one space to the right of the ) on the same line
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.
Did something. Hope it's right
| CupertinoPageTransition({ | ||
| Key key, | ||
| // Linear route animation from 0.0 to 1.0 when this screen is being pushed. | ||
| @required Animation<double> incomingRouteAnimation, |
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'm not sure incoming/outgoing really captures the semantics of these two animations, but i don't have a better suggestion. :-(
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.
Let's figure it out in #9132 then I'll go rename everything.
| key: key, | ||
| // Trigger a rebuild whenever any animation route happens. The listenable's value is not | ||
| // used. | ||
| listenable: new AnimationSum(left: incomingRouteAnimation, right: outgoingRouteAnimation), |
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.
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.
yay! so much more readable! I was hoping there was something like this
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. Thanks!
| // Fractional offset from fully on screen to 1/3 offscreen to the left. | ||
| static final FractionalOffsetTween _kMiddleLeftTween = new FractionalOffsetTween( | ||
| begin: FractionalOffset.topLeft, | ||
| end: const FractionalOffset(-0.33, 0.0), |
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.
you can do -1.0/3.0 to more precisely capture "one third"
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
| ); | ||
|
|
||
| // Fractional offset from offscreen to the right to fully on screen. | ||
| static final FractionalOffsetTween _kRightMiddleTween = new FractionalOffsetTween( |
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.
can these be const?
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.
Might not fully understand dart const constructors. Don't think one is defined for fractional offset tween though.
| ), | ||
| ); | ||
|
|
||
| static final FractionalOffsetTween _kBottomUpTween = new FractionalOffsetTween( |
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.
const?
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.
ditto
| assert(controller != null); | ||
| } | ||
|
|
||
| AnimationController controller; |
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.
presumably this should be final?
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, done in diffbase PR
| if (!(nextRoute is MaterialPageRoute<dynamic>)) | ||
| return false; | ||
| final MaterialPageRoute<dynamic> nextMaterialPageRoute = nextRoute; | ||
| // Don't perform outgoing animation if the next route is a fullscreen dialog. |
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
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.
Though I had to implement new APIs on the page route for a sec until I remembered you mentioned it in #5690 (comment)
| await tester.pump(const Duration(milliseconds: 1)); | ||
|
|
||
| final Opacity widget2Opacity = | ||
| Opacity widget2Opacity = |
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.
nit: i don't think this newline really help readability since it makes this line not match the others
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, fits in one line now. Done.
|
This is fantastic. LGTM. |
| final MaterialPageRoute<dynamic> nextMaterialPageRoute = nextRoute; | ||
| // Don't perform outgoing animation if the next route is a fullscreen dialog. | ||
| return !nextMaterialPageRoute.fullscreenDialog; | ||
| return nextRoute is MaterialPageRoute && !nextRoute.fullscreenDialog; |
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, neat. I can never figure out when this works and when it doesn't. :-(
| key: key, | ||
| // Trigger a rebuild whenever any of the 2 animation route happens. | ||
| listenable: new Listenable.merge( | ||
| <Listenable> [incomingRouteAnimation, outgoingRouteAnimation] |
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.
nit: no space between type and bracket
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
# Conflicts: # packages/flutter/lib/src/cupertino/page.dart
…ansition # Conflicts: # packages/flutter/lib/src/cupertino/page.dart # packages/flutter/lib/src/material/page.dart
|
This made the flutter_gallery_ios__transition_perf average_frame_build_time_millis benchmark regress substantially. |
|
Also microbenchmarks_ios stock_build_iteration. |
For #8726.
Diffbases against #9059. View the diff only via https://github.com/xster/flutter/compare/mountainview...xster:cupertino-transition?diff=split&name=cupertino-transition