Make Cupertino page transitions match native behaviours#9138
Make Cupertino page transitions match native behaviours#9138xster merged 34 commits intoflutter:masterfrom
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.
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.
looks like you don't need this class after all so you can remove it and get away without changing the example. :-)
|
cc @Hixie @abarth @cbracken |
| @required Animation<double> outgoingRouteAnimation, | ||
| @required this.child, | ||
| }) | ||
| : incomingPositionAnimation = _kRightMiddleTween.animate( |
There was a problem hiding this comment.
nit: the : should be one space to the right of the ) on the same line
There was a problem hiding this comment.
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.
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.
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.
use a Listenable.merge instead:
https://docs.flutter.io/flutter/foundation/Listenable/Listenable.merge.html
There was a problem hiding this comment.
yay! so much more readable! I was hoping there was something like this
| // 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.
you can do -1.0/3.0 to more precisely capture "one third"
| ); | ||
|
|
||
| // Fractional offset from offscreen to the right to fully on screen. | ||
| static final FractionalOffsetTween _kRightMiddleTween = new FractionalOffsetTween( |
There was a problem hiding this comment.
Might not fully understand dart const constructors. Don't think one is defined for fractional offset tween though.
| ), | ||
| ); | ||
|
|
||
| static final FractionalOffsetTween _kBottomUpTween = new FractionalOffsetTween( |
| assert(controller != null); | ||
| } | ||
|
|
||
| AnimationController controller; |
There was a problem hiding this comment.
presumably this should be final?
| 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.
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.
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.
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.
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.
nit: no space between type and bracket
# 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