Repository navigation
Extend SystemUiOverlayStyle with additonal values for each platform - #17171
Conversation
| /// applications with a dark background. | ||
| light, | ||
| static const SystemUiOverlayStyle light = const SystemUiOverlayStyle( | ||
| navigationBarColor: 0xFF000000, |
There was a problem hiding this comment.
Black seems at odds with overlays should be drawn with a light color
There was a problem hiding this comment.
Let me do another pass on these values... I keep getting my wires crossed whether we are referring to the color of the UI or the color to match the UI.
| /// applications with a light background. | ||
| dark, | ||
| static const SystemUiOverlayStyle dark = const SystemUiOverlayStyle( | ||
| navigationBarColor: 0xFFFFFFFF, |
There was a problem hiding this comment.
White seems at odds with overlays should be drawn with a dark color.
Shouldn't this version specify a navigationDividerColor (because a non-white divider looks best on white).
There was a problem hiding this comment.
Fixed colors.
I can add a divider color, but we can't actually invoke that API until we update our target SDK version to P though. We can address this later if we decide to draw the bar ourselves using a transparent navigation bar
| /// The color of the divider between the bottom navigation and content. | ||
| /// | ||
| /// Only honored in Android versions P and greater. | ||
| final int navigationDividerColor; |
There was a problem hiding this comment.
For the sake of consistency (but not brevity): navigationBarDividerColor
| /// Only honored in Android versions O and greater. | ||
| final int navigationBarColor; | ||
|
|
||
| /// The color of the divider between the bottom navigation and content. |
There was a problem hiding this comment.
between the systems bottom navigation bar and the app's content.
| } | ||
|
|
||
| /// Specifies a dark vs light preference for certain system chrome options. | ||
| enum SystemChromeTheme { |
There was a problem hiding this comment.
We've been using FooTheme to name inherited widgets (typically configured with FooData) that configure visuals for descendant Foo widgets.
Instead of defining a new enum here, could we use Brightness
There was a problem hiding this comment.
Sounds good. brightness was defined in material so I pulled it into services and re-exported from theme_data. Let me know if there is a better approach here, I didn't think that services should import material since it is supposed to be at a lower level
There was a problem hiding this comment.
Having services provide Brightness sounds sensible to me.
| this.navigationIconTheme, | ||
| }); | ||
|
|
||
| /// The color of the bottom navigation bar. |
There was a problem hiding this comment.
Even though the doc's context informs otherwise, think it's worth qualifying this as the "system" navigation bar to avoid confusion with BottomNavigationBar.
| /// The theme of the navigation bar buttons. | ||
| /// | ||
| /// Only honored in Android versions O and greater. | ||
| final SystemChromeTheme navigationIconTheme; |
There was a problem hiding this comment.
Folding in earlier naming suggestions: Brightness navigationBarIconBrightness
| /// The color of top status bar. | ||
| /// | ||
| /// Only honored in Android version O and greater. | ||
| final int statusBarColor; |
There was a problem hiding this comment.
Why not use a Color here (and pass along it's int value)?
| /// The theme of top status bar. | ||
| /// | ||
| /// Only honored in iOS and Android version O and greater. | ||
| final SystemChromeTheme statusBarTheme; |
There was a problem hiding this comment.
Folding in earlier naming suggestions: Brightness statusBarBrightness
There was a problem hiding this comment.
Done - split into statusBarBrightness and statusBarIconBrightness
…ave platform themes (no breaking change)
|
To keep this from being a breaking change, I have added checks to prevent the light theme from being set for Android. These checks can be removed when I add platform themes and clean up the app bars |
|
Actually it looks like some of these properties can be used before O. I will double check everything and update |
|
flutter-team-archive/engine#5112 is merged into flutter/flutter, @HansMuller PTAL when you have a minute |
HansMuller
left a comment
There was a problem hiding this comment.
Just some small-time feedback about the details.
| light, | ||
| static const SystemUiOverlayStyle light = const SystemUiOverlayStyle( | ||
| systemNavigationBarColor: const Color(0xFFFFFFFF), | ||
| systemNavigationBarDividerColor: null, |
There was a problem hiding this comment.
Don't we want a shade of gray here?
There was a problem hiding this comment.
Since I haven't gotten a chance to play with the P preview I don't really know what the behavior is. null makes sure the API isn't invoked yet.
There was a problem hiding this comment.
Good point. I imagine that we'll have to render this divider on the framework side anyway.
| /// Only honored in Android version M and greater. | ||
| final Brightness statusBarIconBrightness; | ||
|
|
||
| /// The brightness of the system navigation bar icons. |
There was a problem hiding this comment.
It would be a little tidier if this definition was next to the other system nav bar defs
| } | ||
|
|
||
| @override | ||
| int get hashCode => |
There was a problem hiding this comment.
We usually reserve => for one-liners that return a value
| final Brightness systemNavigationBarIconBrightness; | ||
|
|
||
| /// Convert this event to a map for serialization. | ||
| Map<String, dynamic> toMap() { |
There was a problem hiding this comment.
I believe this is just for communicating with the native code, so _toMap()
| } | ||
| } | ||
|
|
||
| List<String> _stringify(List<dynamic> list) { |
There was a problem hiding this comment.
This function could be written or just inlined as
list.map((item) => item.toString()).toList()
The toList() might not be needed either, depending the implementation of invokeMethod.
There was a problem hiding this comment.
I didn't write this code so I'm going to leave it as is
| SystemChrome.setSystemUIOverlayStyle( | ||
| darkBackground ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark | ||
| ); | ||
| // TODO(jonahwilliams): remove once we have platform themes. |
There was a problem hiding this comment.
in general i wouldn't bother with this kind of TODO. Either we eventually add platform themes and remove it, or we don't and this TODO isn't necessary.
I recommend reserving TODOs for more fundamental things where we know there's a limitation to the current implementation but we are intentionally cutting corners for some reason (e.g. because we are waiting an upstream fix).
| return false; | ||
| final SystemUiOverlayStyle typedOther = other; | ||
| return typedOther.systemNavigationBarColor == systemNavigationBarColor | ||
| && typedOther.systemNavigationBarDividerColor == systemNavigationBarDividerColor |
There was a problem hiding this comment.
these should be indented so that the expressions line up
Requires flutter-team-archive/engine#5112. See this PR for more context
Work towards full support for #16837