| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:sky'; | 5 import 'dart:sky'; |
| 6 | 6 |
| 7 import 'typography.dart' as typography; | 7 import 'typography.dart' as typography; |
| 8 import 'colors.dart' as colors; | 8 import 'colors.dart' as colors; |
| 9 | 9 |
| 10 enum ThemeBrightness { dark, light } | 10 enum ThemeBrightness { dark, light } |
| 11 | 11 |
| 12 class ThemeData { | 12 class ThemeData { |
| 13 | 13 |
| 14 ThemeData({ | 14 ThemeData({ |
| 15 ThemeBrightness brightness, | 15 ThemeBrightness brightness, |
| 16 Map<int, Color> primarySwatch, | 16 Map<int, Color> primarySwatch, |
| 17 Color accentColor, | 17 Color accentColor, |
| 18 Color floatingActionButtonColor, | 18 this.accentColorBrightness: ThemeBrightness.dark, |
| 19 typography.TextTheme text, | 19 typography.TextTheme text }) |
| 20 typography.TextTheme toolbarText }) | |
| 21 : this.brightness = brightness, | 20 : this.brightness = brightness, |
| 22 this.primarySwatch = primarySwatch, | 21 this.primarySwatch = primarySwatch, |
| 22 primaryColorBrightness = primarySwatch == null ? brightness : ThemeBrightn
ess.dark, |
| 23 canvasColor = brightness == ThemeBrightness.dark ? colors.Grey[850] : colo
rs.Grey[50], | 23 canvasColor = brightness == ThemeBrightness.dark ? colors.Grey[850] : colo
rs.Grey[50], |
| 24 cardColor = brightness == ThemeBrightness.dark ? colors.Grey[800] : colors
.White, | 24 cardColor = brightness == ThemeBrightness.dark ? colors.Grey[800] : colors
.White, |
| 25 dividerColor = brightness == ThemeBrightness.dark ? const Color(0x1FFFFFFF
) : const Color(0x1F000000), | 25 dividerColor = brightness == ThemeBrightness.dark ? const Color(0x1FFFFFFF
) : const Color(0x1F000000), |
| 26 text = brightness == ThemeBrightness.dark ? typography.white : typography.
black { | 26 text = brightness == ThemeBrightness.dark ? typography.white : typography.
black { |
| 27 assert(brightness != null); | 27 assert(brightness != null); |
| 28 | 28 |
| 29 if (primarySwatch == null) { | 29 if (primarySwatch == null) { |
| 30 _primaryColor = brightness == ThemeBrightness.dark ? colors.Grey[900] : co
lors.Grey[100]; | 30 if (brightness == ThemeBrightness.dark) { |
| 31 _primaryColor = colors.Grey[900]; |
| 32 } else { |
| 33 _primaryColor = colors.Grey[100]; |
| 34 } |
| 31 } else { | 35 } else { |
| 32 _primaryColor = primarySwatch[500]; | 36 _primaryColor = primarySwatch[500]; |
| 33 } | 37 } |
| 34 | 38 |
| 35 if (accentColor == null) { | 39 if (accentColor == null) { |
| 36 _accentColor = primarySwatch == null ? colors.Blue[500] : primarySwatch[50
0]; | 40 _accentColor = primarySwatch == null ? colors.Blue[500] : primarySwatch[50
0]; |
| 37 } else { | 41 } else { |
| 38 _accentColor = accentColor; | 42 _accentColor = accentColor; |
| 39 } | 43 } |
| 40 | |
| 41 if (floatingActionButtonColor == null) { | |
| 42 _floatingActionButtonColor = accentColor == null ? colors.PinkAccent[200]
: accentColor; | |
| 43 } else { | |
| 44 _floatingActionButtonColor = floatingActionButtonColor; | |
| 45 } | |
| 46 | |
| 47 if (toolbarText == null) { | |
| 48 if (colors.DarkColors.contains(primarySwatch) || _primaryColor == colors.G
rey[900]) | |
| 49 _toolbarText = typography.white; | |
| 50 else | |
| 51 _toolbarText = typography.black; | |
| 52 } else { | |
| 53 _toolbarText = toolbarText; | |
| 54 } | |
| 55 } | 44 } |
| 56 | 45 |
| 57 factory ThemeData.light() => new ThemeData(primarySwatch: colors.Blue, brightn
ess: ThemeBrightness.light); | 46 factory ThemeData.light() => new ThemeData(primarySwatch: colors.Blue, brightn
ess: ThemeBrightness.light); |
| 58 factory ThemeData.dark() => new ThemeData(brightness: ThemeBrightness.dark); | 47 factory ThemeData.dark() => new ThemeData(brightness: ThemeBrightness.dark); |
| 59 factory ThemeData.fallback() => new ThemeData.light(); | 48 factory ThemeData.fallback() => new ThemeData.light(); |
| 60 | 49 |
| 61 final ThemeBrightness brightness; | 50 final ThemeBrightness brightness; |
| 62 final Map<int, Color> primarySwatch; | 51 final Map<int, Color> primarySwatch; |
| 63 final Color canvasColor; | 52 final Color canvasColor; |
| 64 final Color cardColor; | 53 final Color cardColor; |
| 65 final Color dividerColor; | 54 final Color dividerColor; |
| 55 final String iconSuffix; |
| 66 final typography.TextTheme text; | 56 final typography.TextTheme text; |
| 67 | 57 |
| 68 Color _primaryColor; | 58 Color _primaryColor; |
| 69 Color get primaryColor => _primaryColor; | 59 Color get primaryColor => _primaryColor; |
| 70 | 60 |
| 61 final ThemeBrightness primaryColorBrightness; |
| 62 |
| 71 Color _accentColor; | 63 Color _accentColor; |
| 72 Color get accentColor => _accentColor; | 64 Color get accentColor => _accentColor; |
| 73 | 65 |
| 74 Color _floatingActionButtonColor; | 66 final ThemeBrightness accentColorBrightness; |
| 75 Color get floatingActionButtonColor => _floatingActionButtonColor; | |
| 76 | |
| 77 typography.TextTheme _toolbarText; | |
| 78 typography.TextTheme get toolbarText => _toolbarText; | |
| 79 } | 67 } |
| OLD | NEW |