-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Add HeroMode widget #48223
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
Add HeroMode widget #48223
Conversation
justinmc
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.
Sorry this took so long to get a review! Here are a few minor changes that I saw. I checked out the branch and confirmed that the tests properly test the added functionality.
We should get an approval of the overall strategy from @goderbauer since you guys were talking about this approach in the previous PR.
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.
Also the child argument must not be null.
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.
What do you think about replacing "heroes" with [Hero]es? Here and below.
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: Maybe shorten this to: (widget is HeroMode && !widget.enabled).
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 trying to think of a more accurate way to describe this since I don't know what "perform" means at first glance. Is this really just enabling/disabling animations? Maybe this is better:
/// Whether or not [Hero]es are enabled in this subtree.
///
/// If true, then the [Hero]es in this subtree will animate as usual.
///
/// If false, then the [Hero]es in this subtree will not animate.
///
/// Defaults to true and must not be null.
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.
Put a period at the end of this comment (and a few others below).
|
@najeira Are you still available to help finish up this PR? |
|
Yes! Thanks for the review. Sorry for noticing late. I will update. |
|
Cool, no problem! Thanks for taking a look at my review. |
|
Some CI tests have failed. Should I rebase? |
|
@najeira Yes, it looks like that's not caused by your changes. Rebase with master (or merge master) and hopefully it will go away. And let me know if you're ready for me to review again. Thanks! |
9d3b345 to
5180231
Compare
goderbauer
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.
Approach seems fine.
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 could inherit from ProxyWidget instead?
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.
ProxyWidget is abstract, the code addition will increase. SingleChildRenderObjectWidget is good for this, 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.
Is it better to inherit ProxyWidget and return SingleChildRenderObjectElement?
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, SingleChildRenderObjectWidget is expected to have a renderObject, The HeroMode itself does not layout or paint in the render layer. It is only adding information to the widget tree. The ProxyWidget returns ComponentElement might make most sense in this case.
Note: there is a ProxyElement, but it has specific logic built in to notify child when its configuration changes. We do not need this functionality, so i think ProxyElement is not suitable in this use case
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 not be addressed yet?
|
I cannot reproduce the original error, and #28042 seems to be fixed. |
|
Explanation of reproduction procedure was not enough. Try:
Error: |
|
@chunhtai can you reproduce this with the additional steps? |
|
I got a crash when I followed those steps on the iOS simulator, and I confirmed that this PR fixes it. |
|
I see, yes i can reproduce it now. Can you open a new issue about this? It is fixing a different problem from #28042 |
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: this have to be a full sentence.
Maybe combine both sentences.
If this property is false, the [Hero]es in this subtree will not animate on route changes; Otherwise, they will animate as usual
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.
same 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 seems not addressed yet?
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 might miss something, but is this really related to nested navigators? I thought the problem is the CupertinoTabScaffold builds a stack where some of the children are offstage and the heroes in those children conflicting with each other?
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.
same 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 is not addressed yet?
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.
Heroes are animated by screen transition. This is related to Navigator. The problem is caused by multiple nested Navigators.
|
Thanks for the review! I'm not good at English. I'm not sure how to fix any documentation issues. I will check and respond to issues regarding the implementation. |
|
@najeira How's it going with these last few comments? Let me know if anything isn't clear about the documentation and I can help out by writing the English. |
|
updated comments |
justinmc
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 but @chunhtai and/or @goderbauer should take a final look before we merge. There are one or two comments that I'm not sure have been addressed.
chunhtai
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.
Some of the comments have not been addressed yet
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 not be addressed yet?
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.
same 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.
same here
The ProxyElement is for inheritedElement that it implement extra logic |
|
Could anybody show me an example using ProxyWidget and ComponentElement? |
|
Is |
|
In my understanding, implementing HeroModeElement skips the call HeroMode.build. extends StatelessWidget:
extends ProxyWidget and impelement HeroModeElement:
Is this all? Please let me know if there are any other processes that affect performance. |
yes that is all as far as I know
It is not a heavy process, but we can improve it by implementing the HeroModeElement which is not too much work. |
|
If we should optimize it, it is better to do it in another PR together with the following classes:
These widgets inherit StatelessWidget and do Additionally: what do you think of this comment?
I want you to comment on which is preferable. CC: @justinmc @goderbauer |
chunhtai
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, with some nit pick
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 not addressed yet?
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 can be an arrow function
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 not addressed yet?
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.
| /// When [enabled] is true (the default), Hero widgets may be involved in a | |
| /// When [enabled] is true (the default), [Hero] widgets may be involved in |
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.
| /// Hero animation, like normal. | |
| /// hero animations, as usual. |
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.
| /// When [enabled] is false, all Hero widgets in this subtree will not be | |
| /// When [enabled] is false, all [Hero] widgets in this subtree will not be |
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.
| /// considered for Hero animations. | |
| /// involved in hero animations. |
|
@najeira it seems like this branch is outdated, can you try to rebase off latest master and see if you can fix the cirrus? |
1a722e4 to
3e317ef
Compare
|
I rebased this branch. |
|
@najeira |
|
I am very grateful for the long discussions and for helping me with my poor English. Thank you all. |
|
Just saw that this was merged, thank you @najeira! |
Description
When there are multiple Navigators like CupertinoPageScaffold, I want to disable heroes in the page that is not displayed.
HeroMode widget provides a means to control whether heroes is enabled or disabled.
Error
current Flutter, An error occurs in the following step:
Related Issues
#44890
#28042
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?
This is the addition of a new widget, will not break existing apps.