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' as colors; | 5 import '../theme/colors.dart' as colors; |
6 import '../theme/edges.dart'; | |
7 import 'basic.dart'; | 6 import 'basic.dart'; |
8 import 'material.dart'; | 7 import 'material.dart'; |
9 import "theme.dart"; | 8 import "theme.dart"; |
10 | 9 |
11 class Card extends Component { | 10 class Card extends Component { |
12 Card({ String key, this.child, this.color }) : super(key: key); | 11 Card({ String key, this.child, this.color }) : super(key: key); |
13 | 12 |
14 final Widget child; | 13 final Widget child; |
15 final Color color; | 14 final Color color; |
16 | 15 |
17 Color get materialColor { | |
18 if (color != null) | |
19 return color; | |
20 switch (Theme.of(this).brightness) { | |
21 case ThemeBrightness.light: | |
22 return colors.White; | |
23 case ThemeBrightness.dark: | |
24 return colors.Grey[800]; | |
25 } | |
26 } | |
27 | |
28 Widget build() { | 16 Widget build() { |
29 return new Container( | 17 return new Container( |
30 margin: const EdgeDims.all(4.0), | 18 margin: const EdgeDims.all(4.0), |
31 child: new Material( | 19 child: new Material( |
32 color: materialColor, | 20 color: color, |
33 edge: MaterialEdge.card, | 21 type: MaterialType.card, |
34 level: 2, | 22 level: 2, |
35 child: new ClipRRect( | 23 child: new ClipRRect( |
36 xRadius: edges[MaterialEdge.card], | 24 xRadius: edges[MaterialType.card], |
37 yRadius: edges[MaterialEdge.card], | 25 yRadius: edges[MaterialType.card], |
38 child: child | 26 child: child |
39 ) | 27 ) |
40 ) | 28 ) |
41 ); | 29 ); |
42 } | 30 } |
43 } | 31 } |
OLD | NEW |