| 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 'package:sky/theme/typography.dart' as typography; | 7 import 'package:sky/theme/typography.dart' as typography; |
| 8 import 'package:sky/theme/colors.dart' as colors; | 8 import 'package:sky/theme/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 this.accentColorBrightness: ThemeBrightness.dark, | 18 this.accentColorBrightness: ThemeBrightness.dark, |
| 19 typography.TextTheme text }) | 19 typography.TextTheme text }) |
| 20 : this.brightness = brightness, | 20 : this.brightness = brightness, |
| 21 this.primarySwatch = primarySwatch, | 21 this.primarySwatch = primarySwatch, |
| 22 primaryColorBrightness = primarySwatch == null ? brightness : ThemeBrightn
ess.dark, | 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 // Some users want the pre-multiplied color, others just want the opacity. |
| 27 hintColor = brightness == ThemeBrightness.dark ? const Color(0x42FFFFFF) :
const Color(0x4C000000), |
| 28 hintOpacity = brightness == ThemeBrightness.dark ? 0.26 : 0.30, |
| 26 text = brightness == ThemeBrightness.dark ? typography.white : typography.
black { | 29 text = brightness == ThemeBrightness.dark ? typography.white : typography.
black { |
| 27 assert(brightness != null); | 30 assert(brightness != null); |
| 28 | 31 |
| 29 if (primarySwatch == null) { | 32 if (primarySwatch == null) { |
| 30 if (brightness == ThemeBrightness.dark) { | 33 if (brightness == ThemeBrightness.dark) { |
| 31 _primaryColor = colors.Grey[900]; | 34 _primaryColor = colors.Grey[900]; |
| 32 } else { | 35 } else { |
| 33 _primaryColor = colors.Grey[100]; | 36 _primaryColor = colors.Grey[100]; |
| 34 } | 37 } |
| 35 } else { | 38 } else { |
| 36 _primaryColor = primarySwatch[500]; | 39 _primaryColor = primarySwatch[500]; |
| 37 } | 40 } |
| 38 | 41 |
| 39 if (accentColor == null) { | 42 if (accentColor == null) { |
| 40 _accentColor = primarySwatch == null ? colors.Blue[500] : primarySwatch[50
0]; | 43 _accentColor = primarySwatch == null ? colors.Blue[500] : primarySwatch[50
0]; |
| 41 } else { | 44 } else { |
| 42 _accentColor = accentColor; | 45 _accentColor = accentColor; |
| 43 } | 46 } |
| 44 } | 47 } |
| 45 | 48 |
| 46 factory ThemeData.light() => new ThemeData(primarySwatch: colors.Blue, brightn
ess: ThemeBrightness.light); | 49 factory ThemeData.light() => new ThemeData(primarySwatch: colors.Blue, brightn
ess: ThemeBrightness.light); |
| 47 factory ThemeData.dark() => new ThemeData(brightness: ThemeBrightness.dark); | 50 factory ThemeData.dark() => new ThemeData(brightness: ThemeBrightness.dark); |
| 48 factory ThemeData.fallback() => new ThemeData.light(); | 51 factory ThemeData.fallback() => new ThemeData.light(); |
| 49 | 52 |
| 50 final ThemeBrightness brightness; | 53 final ThemeBrightness brightness; |
| 51 final Map<int, Color> primarySwatch; | 54 final Map<int, Color> primarySwatch; |
| 52 final Color canvasColor; | 55 final Color canvasColor; |
| 53 final Color cardColor; | 56 final Color cardColor; |
| 54 final Color dividerColor; | 57 final Color dividerColor; |
| 58 final Color hintColor; |
| 59 final double hintOpacity; |
| 55 final typography.TextTheme text; | 60 final typography.TextTheme text; |
| 56 | 61 |
| 57 Color _primaryColor; | 62 Color _primaryColor; |
| 58 Color get primaryColor => _primaryColor; | 63 Color get primaryColor => _primaryColor; |
| 59 | 64 |
| 60 final ThemeBrightness primaryColorBrightness; | 65 final ThemeBrightness primaryColorBrightness; |
| 61 | 66 |
| 62 Color _accentColor; | 67 Color _accentColor; |
| 63 Color get accentColor => _accentColor; | 68 Color get accentColor => _accentColor; |
| 64 | 69 |
| 65 final ThemeBrightness accentColorBrightness; | 70 final ThemeBrightness accentColorBrightness; |
| 66 } | 71 } |
| OLD | NEW |