-
Notifications
You must be signed in to change notification settings - Fork 29.7k
PageTransitionsTheme, new MountainView page transition #21715
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
74af122 to
2696f0f
Compare
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.
please run flutter analyze --dartdocs to catch places where we need to add docs.
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
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 technically a breaking change so we should definitely mention it on flutter-dev, but I find it hard to imagine that it's going to break any actual apps since it doesn't really do anything.
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 sent a warning about this change to flutter-dev, subject "Proposed changes to the CupertinoPageRoute class", on 9/10. Will definitely send a definitive message when this PR lands.
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.
Great, thanks.
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: s/ - /, /
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.
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: (not new, but since you're here) return after else
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 assumed that what's needed here is:
assert(false);
return null;
At the end of the method. The analyzer reports that as dead code. What did you want here?
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 just meant that you could remove the else { part and just have that be at the top level of the method.
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.
docs need updating a bit
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
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 you pass transformHitTests: false to this widget and remove the TODO while you're here?
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.
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 undid this change. It cause a few tests to fail and in the interest of limiting the scope of this PR, I've put the TODO back for now.
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.
do we need the clip?
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. The new page is pinned to the bottom and the clip exposes more and more of it.
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 it's pinned to the bottom of the screen then we don't need to clip it, since it's overflowing the screen where the physical device will handle clipping for us, 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.
Other than a tiny translation, the new page appears exactly where it will end up (it doesn't overflow). The clip is like a vertical curtain that's pulled upwards: so the bottom of the page is exposed first.
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 would call this (and the previous one) something more descriptive.
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 avoid using underscores for argument names, it just makes people confused when reading the code
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.
Sorry about. Plus now I'm using the parameter.
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 make this a child of the outer AnimatedBuilder to avoid rebuilding the inner one each time
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.
Good point! Done.
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.
shouldn't this be in the cupertino library?
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.
oh, i see, this is sort of specific to material...
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 seems overly general when the reality is we just care about iOS vs anything else.
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.
maybe we care about more than that though? I don't really understand why the PageTransitionsBuilders have explicit platforms, and why the general one is different than the mountain view one.
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 PR enables one to add an Android-specific transition, the MountainViewPageTransition. I've enabled configuring the default transition for any platform, which is indeed over achievement, however I think it's a useful point for customization.
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.
The default generic transition is identical to the one we use on Android/Fuschia today. It's no longer part of the Material Spec and it's very different from the default transition on the latest Android (P).
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.
is there much benefit to having the _GenericPageTransition widget rather than just inlining its build method here?
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 way you can substitute your own generic (not target platform specific) page transition.
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 don't see how it helps with this? The widgets are private, so the effect seems to be identical, from a black-box perspective, as having the widgets inlined.
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.
boy is this out of hand
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.
please make sure these are in the exact same order as in operator == and in the constructor and in the order of fields in the class
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.
and in the lerps
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.
Fixed up the order of everything and added some missing (yikes) arguments to hashValues/==.
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.
Not quite sure what "per [TargetPlatform]" means here. Maybe elaborate a bit for these docs?
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
8f7f512 to
a7adfaf
Compare
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 we keep this one around for back-compat? It can be implemented just like popGestureEnabled, using the statics and 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
|
I have to be honest the whole thing with the transitions having platforms feels very strange to me. I don't see why the opening up transition has any affinity to Android, and why the sliding one doesn't. I understand why the Cupertino one does, but only insofar as we have to use that one to enable the back gesture. Why can't the |
a1cce5c to
c8f8105
Compare
|
PageTransitionsBuilders no longer have a platform. The PageTransitionsTheme now has a TargetPlatform => PageTransitionsBuilder map. |
c8f8105 to
7b2f3ae
Compare
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 one should probably transform if it's being driven by the user and not otherwise... :-/
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.
still mentions platform
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.
[] around the class 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.
ditto
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
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 paragraph is obsolete
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.
Should this use the iOS platform to look it up in the map, or should it forcibly use the cupertino transition?
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 it makes sense to continue using whatever transition was defined for iOS. That's CupertinoTransition by default of course.
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.
maybe ?? const FadeUpwardsPageTransitionsBuilder() ?
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 method is just for the operator == definition. I added an explanatory 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.
might be good to precache this on creation, since i imagine (hope?) that this class will be compared more often than created...
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.
The operator == method only uses this value when the lists of builders aren't identical. Hopefully that's a rarity. If not I'll add some caching.
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 could just hand in _defaultBuilders directly instead of the dance here with defaultTheme, no?
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, done.
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 can be made 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.
Yes, good point.
dc5e37c to
7b9152f
Compare
xster
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 modulo the 'Open' name. I wish we can call it something more visually descriptive.
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.
Needs a small tweak. As-is, it reads a bit as if this class itself doesn't use 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.
For future readers, describe which Android versions this corresponds too.
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.
Describe the motion briefly?
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.
Since this is // internal documentation, I included the motion descriptions with the Tweens that define them.
The corresponding (public) PageTransitionBuilder does explain the motion in its class dartdoc.
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.
'Open' isn't very visually descriptive. Perhaps 'Parallax' or 'Reveal'?
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 like calling this transition OpenUpwards. The new page doesn't really move (not much), but we "open" a view of it that expands upwards.
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.
Chatted a bit offline. Conceptually, this sounds a bit suspicious
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've reversed the direction, which undid a last-minute and ill considered change.
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
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.
No change needed, though I'm a bit surprised we don't have a FractionalClip or something.
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.
Maybe just create this once since you use it 3 times
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.
Good idea
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.
Add a small commentary for when users should choose to use 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.
At the moment I don't have anything to add. It's the default, same as it ever was.
It was based on video content from the original Material spec and it's common in Material Android apps before version P.
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.
Open still doesn't feel descriptive. I'm sure there are prior-art from things like PowerPoint or Adobe Premier that we can re-use.
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.
So PowerPoint calls it 'Wipe' or 'Cover' and Apple Keynote calls it 'Reveal'. I think any of them are an improvement on 'Open'
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 they're all OK, and I'm happy with "open".
a766aeb to
0d98dcc
Compare
MaterialPageRoute transitions are now defined by the Theme. Added (optional) support for Android P style page transitions.
The default MaterialPageRoute transitions have not changed: the horizontal
CuperitinoPageTransitionis still used when the target platform isiOSand the fading upwards transition is used for all other target platforms.Added a
ThemeData.pageTransitionsThemewhich provides the default implementation ofMaterialPageRoute.buildTransitionsper target platform. Subclasses ofPageTransitionsBuilderdefinebuildTransitionsmethods.Three
PageTransitionsBuildersubclasses are provided:FadeUpwardsTransitionsBuilder,CupertinoPageTransitionsBuilder,OpenUpwardsPageTransitionsBuilder.By default
PageTransitionsThemeonly includes FadeUpwardsPageTransitionsBuilder, and CupertinoPageTransitionsBuilder.To use the new Android P style page transition when the target platform is Android, include
OpenUpwardsPageTransitionsBuilderin the Theme'spageTransitionsTheme. For example:Two of the CupertinoPageRoute methods that had been used to enable building a MaterialPageRoute that used a "host" CupertinoPageRoute's
buildTransitions()method have been removed or changed:The last method was replaced by a static method that reports the same value for any route that's using a Cupertino transition:
These are backwards incompatible changes. However it seems unlikely that any existing apps depended on them.