Skip to content

Conversation

@jacek-marchwicki
Copy link
Contributor

@jacek-marchwicki jacek-marchwicki commented Oct 14, 2020

Description

Use the correct place for the system navigation bar color adjustment

Before the fix: the center of the screen were used to adjust navigation bar color.
After the fix: the center of the bottom navigation bar is used to adjust navigation bar color.

Before After the fix
incorrect correct

For more you can read the following issue: #66429

For example code that shows differences before and after the change you can use https://github.com/jacek-marchwicki/flutter-insets-bug2

Keep in mind, that window.padding isn't calculated correctly for translucent navigation bar on Android (issue: #63761) and this is not fixed by the PR.

If you have further questions related to this PR, I'm happy to try answering all of them.

Related Issues

Tests

I added the following tests:

  • 'statusBarColor isn't set for unannotated view',
  • 'statusBarColor is set for annotated view',
  • 'statusBarColor isn't set when view covers less than half of the system status bar',
  • 'statusBarColor is set when view covers more than half of tye system status bar',
  • 'systemNavigationBarColor isn't set for non Android device',
  • 'systemNavigationBarColor isn't set for unannotated view',
  • 'systemNavigationBarColor is set for annotated view',
  • 'systemNavigationBarColor isn't set when view covers less than half of navigation bar',
  • 'systemNavigationBarColor is set when view covers more than half of navigation bar'

Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///). NOT NEED
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR. (I'll wait for the CI build to pass, because unchanged master branch analyze execution is failing on my computer. But I got success on stable branch)
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read [Handling breaking changes].

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Oct 14, 2020
@google-cla google-cla bot added the cla: yes label Oct 14, 2020
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

info: bottom padding shouldn't be divided by _window.devicePixelRatio because everywhere we use native pixels. We should just divide the top padding by two so we get the status bar center.
Before this calculations worked correctly only on 2x screens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

info: I couldn't use view_test.dart file because TestRenderingFlutterBinding it is used there. Those tests uses TestWidgetsFlutterBinding.
Different types of bindings can't be used in the same file.

@pedromassango
Copy link
Member

Thanks for this PR. Does this PR also fixes the issues mentioned in #66429 (comment)?

@jacek-marchwicki
Copy link
Contributor Author

@pedromassango yes it fixes the issue :)

@jacek-marchwicki
Copy link
Contributor Author

I see some CI failures on this PR:

  • "Linux docs" failing - looks like not related to this PR issue /b/s/w/ir/kitchen-checkout/flutter/recipe_modules/firebase/resources/firebase_deploy.sh: line 10: firebase: command not found
  • "flutter-build" failing - I can't get details at the build. It displays some flutter dashboard
  • "flutter-gold" pending - it is still pending after 8 hours. Unfortunately, I can't get details here too :(

Can you guys help me solve those problems?

@pedromassango
Copy link
Member

Those failing tests are probably unrelated to the changes so don’t worry about them. They will get fixed once the fix lands into master and you rebase your branch.

I would suggest you to verify and add then into Relates issues section so they will also get closed automatically. This avoid having opened issues that were fixed already.

@HansMuller HansMuller changed the title [Flutter] Use the correct pleace for the system navigation bar color adjustment [Flutter] Use the correct place for the system navigation bar color adjustment Oct 15, 2020
@HansMuller HansMuller requested a review from goderbauer October 15, 2020 23:55
@jonahwilliams jonahwilliams self-requested a review October 16, 2020 00:04
@jacek-marchwicki jacek-marchwicki force-pushed the system-navigation-bar-style-fix branch from 07cd7dc to 30118d4 Compare October 16, 2020 07:42
@jacek-marchwicki
Copy link
Contributor Author

⬆️ FYI: I've just rebased my change to the current master branch and now all tests passes!
Unfortunately, I still see a lot of flutter analyze issues on my computer unrelated to the change.

@jonahwilliams
Copy link
Contributor

Since you branched from master when there was an analysis failure, you'll need to pull in the fixes to your local branch. git fetch upstream master -> git pull upstream master

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is necessary, doesn't each testWidgets get its own binding/render tree? @goderbauer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonahwilliams Looks like it's necessary, testWidgets doesn't clear those values by itself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanations make sense, could you leave a detailed comment in the code here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you look at the updated?

@jacek-marchwicki jacek-marchwicki force-pushed the system-navigation-bar-style-fix branch from 30118d4 to 126e792 Compare October 19, 2020 12:13
@jacek-marchwicki jacek-marchwicki force-pushed the system-navigation-bar-style-fix branch from 126e792 to 2c22116 Compare October 19, 2020 14:53
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android - systemNavigationBarColor is taken from the incorrect place of the screen Overstretching SliverAppBar causes navigation bar color to reset

5 participants