[Android 10] Activity zoom transition#41935
[Android 10] Activity zoom transition#41935shihaohong merged 9 commits intoflutter:masterfrom shihaohong:zoom-transitions
Conversation
TODO: implement reverse curve and further improve fastOutExtraSlowIn curve to look more like native transition
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
I created a separate issue (#42802) to track setting page transition duration to a value other than 300ms, since the Android 10 activity transition is supposed to be over 400ms. |
|
Should this be the default behavior when this PR is merged? https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#widget-libraries-follow-the-latest-oem-behavior |
|
@Zazo032 I was thinking of making this the default transition in a separate PR. Making that change would be breaking and involve some code and documentation changes. I would prefer to distinguish between the implementation details of the transition from making it the default Android transition for this PR. |
HansMuller
left a comment
There was a problem hiding this comment.
LGTM. Just a few comments about small stuff.
| /// | ||
| /// This tween sequence assumes that the evaluated result has to be a double | ||
| /// between 0.0 and 1.0. | ||
| class FlippedTweenSequence extends TweenSequence<double> { |
There was a problem hiding this comment.
Maybe we should also provide (separate PR) a FlippedTween, like ReverseTween:
class FlipTween<T> extends Tween<T> {
FlipTween(this.parent)
: assert(parent != null),
super(begin: parent.end, end: parent.begin);
final Tween<T> parent;
@override
T lerp(double t) => 1.0 - parent.lerp(1.0 - t);
}| super(items); | ||
|
|
||
| @override | ||
| double transform(double t) { |
There was a problem hiding this comment.
Why isn't this just
double transform(double t) => 1 - super.transform(1 - t);There was a problem hiding this comment.
This is indeed just that. Updated it
| end: 0.60, | ||
| ); | ||
|
|
||
| // A curve sequence similar to the 'fastOutExtraSlowIn' curve used in the |
There was a problem hiding this comment.
similar => that's similar
| /// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition | ||
| /// that's similar to the one provided by Android P. | ||
| /// * [ZoomPageTransitionsBuilder], which defines a page transition similar | ||
| /// to the one provided in Android Q. |
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final Animation<double> _forwardScrimOpacityAnimation = _ZoomPageTransition._scrimOpacityTween |
There was a problem hiding this comment.
You could write these animations in terms of Animation.drive. For example:
final Animation<double> _forwardScrimOpacityAnimation = widget.animation.drive(
CurveTween(curve: const Interval(0.2075, 0.4175)),
);There was a problem hiding this comment.
Is there a difference having these animations in terms of Animation.drive vs using Tween.animate?
There was a problem hiding this comment.
Animation.drive is consider to be a little easier to read. They're functionally the same.
| }); | ||
| } | ||
|
|
||
| bool get _transitionWasInterrupted { |
There was a problem hiding this comment.
This would be a good place to explain why we're checking if the transition was interrupted.
* Android 10 zoom transition
Description
Implement the Android 10 Zoom transition.
Edit: The yellow tinge in the gif is an artifact from creating the gif.

To use this transition, add it your app's theme. For example, this is how you would do this with
MaterialAppfor Android devices:Related Issues
Fixes #39812
Related to #40258
Related to #39858
Tests
I added the following tests:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?