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 '../theme/colors.dart'; | 5 import '../theme/colors.dart' as colors; |
6 import 'basic.dart'; | 6 import 'basic.dart'; |
7 import 'material_button.dart'; | 7 import 'material_button.dart'; |
8 | 8 import 'theme.dart'; |
9 export 'material_button.dart' show MaterialButtonTheme; | |
10 | 9 |
11 class RaisedButton extends MaterialButton { | 10 class RaisedButton extends MaterialButton { |
12 | 11 |
13 RaisedButton({ | 12 RaisedButton({ |
14 String key, | 13 String key, |
15 Widget child, | 14 Widget child, |
16 bool enabled: true, | 15 bool enabled: true, |
17 Function onPressed, | 16 Function onPressed |
18 MaterialButtonTheme theme: MaterialButtonTheme.light | |
19 }) : super(key: key, | 17 }) : super(key: key, |
20 child: child, | 18 child: child, |
21 enabled: enabled, | 19 enabled: enabled, |
22 onPressed: onPressed, | 20 onPressed: onPressed); |
23 theme: theme); | |
24 | 21 |
25 Color get color { | 22 Color get color { |
26 if (enabled) { | 23 if (enabled) { |
27 switch (theme) { | 24 switch (Theme.of(this).brightness) { |
28 case MaterialButtonTheme.light: | 25 case ThemeBrightness.light: |
29 if (highlight) | 26 if (highlight) |
30 return Grey[350]; | 27 return colors.Grey[350]; |
31 else | 28 else |
32 return Grey[300]; | 29 return colors.Grey[300]; |
33 break; | 30 break; |
34 case MaterialButtonTheme.dark: | 31 case ThemeBrightness.dark: |
35 if (highlight) | 32 if (highlight) |
36 return Blue[700]; | 33 return Theme.of(this).primary[700]; |
37 else | 34 else |
38 return Blue[600]; | 35 return Theme.of(this).primary[600]; |
39 break; | 36 break; |
40 } | 37 } |
41 } else { | 38 } else { |
42 return Grey[350]; | 39 return colors.Grey[350]; |
43 } | 40 } |
44 } | 41 } |
45 | 42 |
46 int get level => enabled ? (highlight ? 2 : 1) : 0; | 43 int get level => enabled ? (highlight ? 2 : 1) : 0; |
47 } | 44 } |
OLD | NEW |