Commit b0f7da92 authored by Conor Dockry's avatar Conor Dockry Committed by Hans Muller

Choose default icon color based on theme brightness (#15450)

* Use theme for default icon color

Replaces hard-coded black.

* Better icon defaults for dark/light modes

* Add default case to silence warning
parent b6cca392
...@@ -1437,6 +1437,17 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat ...@@ -1437,6 +1437,17 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
return lightEnabled; return lightEnabled;
} }
Color _getDefaultIconColor(ThemeData themeData) {
switch (themeData.brightness) {
case Brightness.dark:
return Colors.white70;
case Brightness.light:
return Colors.black45;
default:
return themeData.iconTheme.color;
}
}
// True if the label will be shown and the hint will not. // True if the label will be shown and the hint will not.
// If we're not focused, there's no value, and labelText was provided, // If we're not focused, there's no value, and labelText was provided,
// then the label appears where the hint would. // then the label appears where the hint would.
...@@ -1556,7 +1567,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat ...@@ -1556,7 +1567,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
final Color activeColor = _getActiveColor(themeData); final Color activeColor = _getActiveColor(themeData);
final bool decorationIsDense = decoration.isDense == true; // isDense == null, same as false final bool decorationIsDense = decoration.isDense == true; // isDense == null, same as false
final double iconSize = decorationIsDense ? 18.0 : 24.0; final double iconSize = decorationIsDense ? 18.0 : 24.0;
final Color iconColor = isFocused ? activeColor : Colors.black45; final Color iconColor = isFocused ? activeColor : _getDefaultIconColor(themeData);
final Widget icon = decoration.icon == null ? null : final Widget icon = decoration.icon == null ? null :
new Padding( new Padding(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment