-
Notifications
You must be signed in to change notification settings - Fork 28.6k
fix: BottomNavigationBarItem colors #96664
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
fix: BottomNavigationBarItem colors #96664
Conversation
add: _effectiveIconTheme function add: logic for setting the effective selected/unselected icon theme change: color tweens to use the effective label style color if not null change: use the new effective selected/unselected Icon theme when generating _BottomNavigationTile add: tests to capture the issues with the label style color, matching the docs
I would love to get some feedback on the PR. I'm prepared to make any additional changes to meet the requirements. |
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
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.
Thanks for the contribution! It appears this is a bit of a confusing API, so thanks for cleaning it up. In addition to the comments and suggestions below, can we add something to the class doc comment about the IconThemeData
taking precedence over iconSize
and item colors?
It also appears that the analyzer is complaining about trailing spaces on the ends of some lines. (See the |
Gold has detected about 1 new digest(s) on patchset 4. |
Gold has detected about 1 new digest(s) on patchset 5. |
Gold has detected about 8 new digest(s) on patchset 7. |
Gold has detected about 16 new digest(s) on patchset 8. |
Gold has detected about 6 new digest(s) on patchset 9. |
@darrenaustin fixed everything. |
Gold has detected about 18 new digest(s) on patchset 10. |
change: rewording in test cases remove: trailing spaces remove blank lines add: docs for IconThemeData's fix: typos
8a08988
to
8ee841f
Compare
reset and re-applied changes to avoid CLA issues and not waste more time on this. |
@talamaska thanks for the update. It looks like the new tests are failing however. From the logs for one of the failing checks:
Can you take a look? Thx. |
@darrenaustin it seems your suggestion for shortening is not working as expected. return (iconTheme ?? const IconThemeData()).copyWith(color: itemColor); I think you missed the point initially or overlooked. The thing here is that itemColor can be null and the short variant is not covering this case. In any case, if I return my code to the previous state the tests are passing. P.S on additional look I see another problem that I miss. iconTheme will never be null in the condition cause we just assigned a fresh IconThemData. Will try to make it better. P.S Also it seems that iconTheme should override not only iconColor, but also textStyle color. |
add: more tests change: _effectiveIconTheme to account for textStyle
I think it is fixed now. |
@darrenaustin is there something else that is blocking this PR? |
@darrenaustin, hi there. I wonder, can I get a review again? It's been quite some time since I implemented the requested changes. I would really like this to be merged before starting other efforts for eventual material 3 migration, because I'm afraid the issues will end up in the new version as well. I have pinged in discord as well. If it is more convenient we can chat there. |
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.
@talamaska, thanks so much for your patience. Sorry I haven't been able to get to this sooner.
Taking a closer look, I am confused why we are conflating the icon and label colors (other than through the (un)selectedItemColor
). This conflation in the tweens was there before your fix, but it seems wrong to keep mixing the two. Perhaps I am missing something though.
Also, I fear this may be a breaking change, as I tried this patch against internal Google tests and it failed several golden tests. There appear to be usages of this API that depend on the current behaviour. We might be able to either fix the tests or ensure they don't break, but first I want to see if we can resolve the icon vs. label color issues.
colorTween = ColorTween( | ||
begin: widget.unselectedItemColor | ||
begin: effectiveUnselectedLabelStyle.color | ||
?? widget.unselectedItemColor | ||
?? bottomTheme.unselectedItemColor | ||
?? themeData.unselectedWidgetColor, | ||
end: widget.selectedItemColor | ||
end: effectiveSelectedLabelStyle.color | ||
?? widget.selectedItemColor | ||
?? bottomTheme.selectedItemColor | ||
?? widget.fixedColor | ||
?? themeColor, |
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 ColorTween
is a bit odd in that it is used for both the icon and label colors, even though they can be different colors. I know this was already in place before your fix, but this just seems to conflate the two even more. Perhaps we should break these out into a tween for the icon and a tween for the text.
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.
@darrenaustin So, if I make the previous changes without changing this color tween, all tests are successful, as soon I add a separate tween for the icon colors some golden tests fail. Specifically this one "BottomNavigationBar shifting backgroundColor with transition". How would you recommend to proceed?
fix: tests for icon color
@darrenaustin in the end, would it make sense to drop all those fixes if there is a material 3 rewrite going? Or is the new material 3 navigation bar will be a new widget? |
I saw #96480 this morning and filed a PR for it based on Hixie's comment, which addresses Now I found this PR and #64358 Just closed new issue #96480 for a duplicate of the issue linked here #64358
I think my PR addressed the issue matching the Flutter docs
|
@darrenaustin @TahaTesser if my PR is not needed anymore feel free to close. It's a shame that I was waiting for review months and @TahaTesser PR was reviewed and approved in a matter of hours. I understand that my PR was not perfect, but anyways. |
@talamaska |
What is the status of this PR? Did we end up fixing this issue in the other PR? @talamaska sorry for the delays in dealing with this PR. You are welcome to come bug us on our Discord server (link in the contributing guidelines) if you would like to ask for reviews when we drop the ball. :-) |
@Hixie Hi, well, it seems the PR is a no go, because it is breaking some golden tests. Which on my opinion just rely on a wrong behavior and in addition the reported issues are not included in the existing tests. I didn't get any feedback on the question about the shifting bottom bar styles or any other question in my comment to @darrenaustin. In the other PR #102756 that was reverted I got an explanation that this is a breaking change and there is a different process of implementing those - with temporary flags or something else that can gracefully help devs migrate to the new behavior. So I'm not sure what to do here. About the Discord channel I didn't get any response there when i was waiting for a review last time. |
fix: icon color should not depend on text style color add: a separate tween of the icons fix: tests
If it's breaking some customer tests then yeah, generally that means we end up putting a flag that flips between the old and new behaviours for a while, so that we can migrate the code. That's relatively straight forward; you just have a static boolean variable |
Looks like the customer_testing shard is breaking because you may have done a merge instead of a rebase. I recommend squashing your commits then rebasing so that it's the last commit on your branch, that way the script knows which version of the customer tests to run. |
I couldn't figure out what the shifting label issue was, can you elaborate on this? Where do the screenshots come from? For the migration guide the documentation for doing that is in the template: https://github.com/flutter/website/blob/main/src/release/breaking-changes/template.md More information about breaking changes is at: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes |
change: tests fix: docs fix: shifting bottom navigation bar colors add: legacy flag add: conditions for loading different tweens and themes depending on the legacy flag value.
@Hixie |
@Hixie will check the info about the breaking changes. For now the flag is implemented and all the conditional logic is there, so with the flag true, no tests are breaking and tests are testing with the flag equal to false. Thanks for sharing those with me. |
Yes I merged from master. I didn't know I have to rebase. I'm not sure how to squash my commits and then rebase since i already merged master in my branch. |
@Hixie Could you please elaborate on squashing and rebasing. I have like 3 merges from master thought the life of this branch. Do I need to revert from the beginning, make my changes, then rebase master into my branch? I'm sorry if this is a trivial question, but I have never rebased before and I see I can't squash commits if they include a merge in the middle. Would it be easier to just drop this PR, make a new branch from the current master, add my changes and submit a new PR? |
Easiest way is probably to just create a new branch, then cherry-pick your commits onto it. Alternatively you might be able to do it using |
@darrenaustin @Hixie closing this PR in favor of a new one #107924 |
add: _effectiveIconTheme function
add: logic for setting the effective selected/unselected icon theme
change: color tweens to use the effective label style color if not null
change: use the new effective selected/unselected Icon theme when generating _BottomNavigationTile
add: tests to capture the issues with the label style color, matching the docs
fix: BottomNavigationBarItem title's color is not overriden neither by selectedLabelStyle nor unselectedLabelStyle
#64358
Pre-launch Checklist
///
).