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
This commit is contained in:
Conor Dockry 2018-03-14 19:01:38 -04:00 committed by Hans Muller
parent b6cca3923a
commit b0f7da9249

View File

@ -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
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(