Index: sky/sdk/lib/widgets/icon.dart |
diff --git a/sky/sdk/lib/widgets/icon.dart b/sky/sdk/lib/widgets/icon.dart |
index 51117235b4fb02791d814cdfd5275147f2ac131e..30aceaf420175073d776f33c880c16c99d20cb60 100644 |
--- a/sky/sdk/lib/widgets/icon.dart |
+++ b/sky/sdk/lib/widgets/icon.dart |
@@ -4,6 +4,8 @@ |
import '../mojo/asset_bundle.dart'; |
import 'basic.dart'; |
+import 'icon_theme.dart'; |
+import 'theme.dart'; |
AssetBundle _initIconBundle() { |
if (rootBundle != null) |
@@ -15,10 +17,29 @@ AssetBundle _initIconBundle() { |
final AssetBundle _iconBundle = _initIconBundle(); |
class Icon extends Component { |
- Icon({ String key, this.size, this.type: '' }) : super(key: key); |
+ Icon({ String key, this.size, this.type: '', this.color }) : super(key: key); |
final int size; |
final String type; |
+ final IconThemeColor color; |
+ |
+ String get colorSuffix { |
+ IconThemeColor iconThemeColor = color; |
+ if (iconThemeColor == null) { |
+ IconThemeData iconThemeData = IconTheme.of(this); |
+ iconThemeColor = iconThemeData == null ? null : iconThemeData.color; |
+ } |
+ if (iconThemeColor == null) { |
+ ThemeBrightness themeBrightness = Theme.of(this).brightness; |
+ iconThemeColor = themeBrightness == ThemeBrightness.dark ? IconThemeColor.white : IconThemeColor.black; |
+ } |
+ switch(iconThemeColor) { |
+ case IconThemeColor.white: |
+ return "white"; |
+ case IconThemeColor.black: |
+ return "black"; |
+ } |
+ } |
Widget build() { |
String category = ''; |
@@ -33,7 +54,7 @@ class Icon extends Component { |
String density = 'drawable-xxhdpi'; |
return new AssetImage( |
bundle: _iconBundle, |
- name: '${category}/${density}/ic_${subtype}_${size}dp.png', |
+ name: '${category}/${density}/ic_${subtype}_${colorSuffix}_${size}dp.png', |
size: new Size(size.toDouble(), size.toDouble()) |
); |
} |