Index: sky/sdk/lib/theme/theme_data.dart |
diff --git a/sky/sdk/lib/theme/theme_data.dart b/sky/sdk/lib/theme/theme_data.dart |
index fe6d3810d49e5216b3fc4cb9639da17f0b390281..cfefa334a4f187c5cb21bb053623549de9481e6a 100644 |
--- a/sky/sdk/lib/theme/theme_data.dart |
+++ b/sky/sdk/lib/theme/theme_data.dart |
@@ -11,29 +11,67 @@ enum ThemeBrightness { dark, light } |
class ThemeData { |
- ThemeData.light({ |
- this.primary, |
- this.accent, |
- bool darkToolbar: false }) |
- : brightness = ThemeBrightness.light, |
- toolbarText = darkToolbar ? typography.white : typography.black, |
- text = typography.black; |
- |
- ThemeData.dark({ this.primary, this.accent }) |
- : brightness = ThemeBrightness.dark, |
- toolbarText = typography.white, |
- text = typography.white; |
- |
- ThemeData.fallback() |
- : brightness = ThemeBrightness.light, |
- primary = colors.Indigo, |
- accent = colors.PinkAccent, |
- toolbarText = typography.white, |
- text = typography.black; |
+ ThemeData({ |
+ ThemeBrightness brightness, |
+ Map<int, Color> primarySwatch, |
+ Color accentColor, |
+ Color floatingActionButtonColor, |
+ typography.TextTheme text, |
+ typography.TextTheme toolbarText }) |
+ : this.brightness = brightness, |
+ this.primarySwatch = primarySwatch, |
+ canvasColor = brightness == ThemeBrightness.dark ? colors.Grey[850] : colors.Grey[50], |
+ cardColor = brightness == ThemeBrightness.dark ? colors.Grey[800] : colors.White, |
+ text = brightness == ThemeBrightness.dark ? typography.white : typography.black { |
+ assert(brightness != null); |
+ |
+ if (primarySwatch == null) { |
+ _primaryColor = brightness == ThemeBrightness.dark ? colors.Grey[900] : colors.Grey[100]; |
+ } else { |
+ _primaryColor = primarySwatch[500]; |
+ } |
+ |
+ if (accentColor == null) { |
+ _accentColor = primarySwatch == null ? colors.Blue[500] : primarySwatch[500]; |
+ } else { |
+ _accentColor = accentColor; |
+ } |
+ |
+ if (floatingActionButtonColor == null) { |
+ _floatingActionButtonColor = accentColor == null ? colors.PinkAccent[200] : accentColor; |
+ } else { |
+ _floatingActionButtonColor = floatingActionButtonColor; |
+ } |
+ |
+ if (toolbarText == null) { |
+ if (colors.DarkColors.contains(primarySwatch) || _primaryColor == colors.Grey[900]) |
+ _toolbarText = typography.white; |
+ else |
+ _toolbarText = typography.black; |
+ } else { |
+ _toolbarText = toolbarText; |
+ } |
+ } |
+ |
+ factory ThemeData.light() => new ThemeData(primarySwatch: colors.Blue, brightness: ThemeBrightness.light); |
+ factory ThemeData.dark() => new ThemeData(brightness: ThemeBrightness.dark); |
+ factory ThemeData.fallback() => new ThemeData.light(); |
final ThemeBrightness brightness; |
- final Map<int, Color> primary; |
- final Map<int, Color> accent; |
+ final Map<int, Color> primarySwatch; |
+ final Color canvasColor; |
+ final Color cardColor; |
final typography.TextTheme text; |
- final typography.TextTheme toolbarText; |
+ |
+ Color _primaryColor; |
+ Color get primaryColor => _primaryColor; |
+ |
+ Color _accentColor; |
+ Color get accentColor => _accentColor; |
+ |
+ Color _floatingActionButtonColor; |
+ Color get floatingActionButtonColor => _floatingActionButtonColor; |
+ |
+ typography.TextTheme _toolbarText; |
+ typography.TextTheme get toolbarText => _toolbarText; |
} |