-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Document the buildTransitions() method #9182
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
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 rename all the overrides to be consistent?
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.
Certainly.
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 we'd usually ave a comma after child and put the ) on the next 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.
s/PageRouteBuilder/[PageRouteBuilder]/ to linkify 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.
Maybe we don't need this paragraph. A bit verbose.
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, that's backwards than what I would have assumed.
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 assumed correctly, I've fixed that.
|
FYI @xster |
91bebc8 to
bf58ae3
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.
'that was previously on the top'?
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 secondaryAnimation executed in reverse defines how the route below 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.
I think it's the other way around
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.
That's correct. I've fixed 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.
Maybe we don't need this paragraph. A bit verbose.
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 paragraph is too much opinion on how users would use the API
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 route's transition as the new top of the navigator stack'?
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's important to note that this parameter is rarely used but I've left out my opnion as to why.
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 whole paragraph sounds like it's referring to something that's not 'self' but the API is still asking the user to build animated widgets associated with the same 'self' route.
Perhaps 'The animation for this route when it's the second topmost route on the stack. It runs from 0.0 to 1.0 as another route is pushed on top of this one and from 1.0 to 0.0 as another route above this one is popped.
This animation runs together with the [primaryAnimation] of the route above 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.
I agree, the way this is written (likewise for the other animation parameter) could be confusing. I've rewritten it in the same terms as the introductory material.
|
Let's chat in person. I still like Adam's idea of splitting the API into 2 methods for clarity. |
|
re: #9182 (comment) p.s. there are more animations in cupertino/page.dart to swap incoming->primary and outgoing->secondary for consistency |
…uildTransitions and buildPage animation paramter name to primaryAnimation
e771174 to
a4267c0
Compare
| /// | ||
| /// ```dart | ||
| /// new PageRouteBuilder( | ||
| /// pageBuilder: (BuildContext context, _, __) { |
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.
an argument for not using _: when someone copies this code, they will wonder what those parameters are. It will be a pain for them to find out, because they'll have to first look at PageRouteBuilder, then look up pageBuilder from there, then look up the typedef, then study it. If we just type and name the parameters here, it will be self-documenting.
| /// BuildContext context, | ||
| /// Animation<double> animation, | ||
| /// Animation<double> secondaryAnimation, | ||
| /// Widget child) { |
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: newline before )

Clarify the roles of the two buildTransitions() animation parameters. I've renamed them primaryAnimation and secondaryAnimation to make it easier to write about them.
Fixes #9132