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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.light({ 14 ThemeData({
15 this.primary, 15 ThemeBrightness brightness,
16 this.accent, 16 Map<int, Color> primarySwatch,
17 bool darkToolbar: false }) 17 Color accentColor,
18 : brightness = ThemeBrightness.light, 18 Color floatingActionButtonColor,
19 toolbarText = darkToolbar ? typography.white : typography.black, 19 typography.TextTheme text,
20 text = typography.black; 20 typography.TextTheme toolbarText })
21 : this.brightness = brightness,
22 this.primarySwatch = primarySwatch,
23 canvasColor = brightness == ThemeBrightness.dark ? colors.Grey[850] : colo rs.Grey[50],
24 cardColor = brightness == ThemeBrightness.dark ? colors.Grey[800] : colors .White,
25 text = brightness == ThemeBrightness.dark ? typography.white : typography. black {
26 assert(brightness != null);
21 27
22 ThemeData.dark({ this.primary, this.accent }) 28 if (primarySwatch == null) {
23 : brightness = ThemeBrightness.dark, 29 _primaryColor = brightness == ThemeBrightness.dark ? colors.Grey[900] : co lors.Grey[100];
24 toolbarText = typography.white, 30 } else {
25 text = typography.white; 31 _primaryColor = primarySwatch[500];
32 }
26 33
27 ThemeData.fallback() 34 if (accentColor == null) {
28 : brightness = ThemeBrightness.light, 35 _accentColor = primarySwatch == null ? colors.Blue[500] : primarySwatch[50 0];
29 primary = colors.Indigo, 36 } else {
30 accent = colors.PinkAccent, 37 _accentColor = accentColor;
31 toolbarText = typography.white, 38 }
32 text = typography.black; 39
40 if (floatingActionButtonColor == null) {
41 _floatingActionButtonColor = accentColor == null ? colors.PinkAccent[200] : accentColor;
42 } else {
43 _floatingActionButtonColor = floatingActionButtonColor;
44 }
45
46 if (toolbarText == null) {
47 if (colors.DarkColors.contains(primarySwatch) || _primaryColor == colors.G rey[900])
48 _toolbarText = typography.white;
49 else
50 _toolbarText = typography.black;
51 } else {
52 _toolbarText = toolbarText;
53 }
54 }
55
56 factory ThemeData.light() => new ThemeData(primarySwatch: colors.Blue, brightn ess: ThemeBrightness.light);
57 factory ThemeData.dark() => new ThemeData(brightness: ThemeBrightness.dark);
58 factory ThemeData.fallback() => new ThemeData.light();
33 59
34 final ThemeBrightness brightness; 60 final ThemeBrightness brightness;
35 final Map<int, Color> primary; 61 final Map<int, Color> primarySwatch;
36 final Map<int, Color> accent; 62 final Color canvasColor;
63 final Color cardColor;
37 final typography.TextTheme text; 64 final typography.TextTheme text;
38 final typography.TextTheme toolbarText; 65
66 Color _primaryColor;
67 Color get primaryColor => _primaryColor;
68
69 Color _accentColor;
70 Color get accentColor => _accentColor;
71
72 Color _floatingActionButtonColor;
73 Color get floatingActionButtonColor => _floatingActionButtonColor;
74
75 typography.TextTheme _toolbarText;
76 typography.TextTheme get toolbarText => _toolbarText;
39 } 77 }
OLDNEW
« 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