Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(981)

Unified Diff: sky/sdk/lib/theme/theme_data.dart

Issue 1218153005: Refactoring to support dark theme better (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix import issues Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/lib/theme/colors.dart ('k') | sky/sdk/lib/widgets/card.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « sky/sdk/lib/theme/colors.dart ('k') | sky/sdk/lib/widgets/card.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698