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 '../painting/box_painter.dart'; | 5 import '../painting/box_painter.dart'; |
6 import '../theme/colors.dart'; | 6 import '../theme/colors.dart'; |
7 import '../theme/edges.dart'; | 7 import '../theme/edges.dart'; |
8 import '../theme/shadows.dart'; | 8 import '../theme/shadows.dart'; |
9 import 'basic.dart'; | 9 import 'basic.dart'; |
| 10 import 'default_text_style.dart'; |
| 11 import 'theme.dart'; |
10 | 12 |
11 class Material extends Component { | 13 class Material extends Component { |
12 | 14 |
13 Material({ | 15 Material({ |
14 String key, | 16 String key, |
15 this.child, | 17 this.child, |
16 this.edge: MaterialEdge.card, | 18 this.edge: MaterialEdge.card, |
17 this.level: 0, | 19 this.level: 0, |
18 this.color | 20 this.color |
19 }) : super(key: key); | 21 }) : super(key: key); |
20 | 22 |
21 final Widget child; | 23 final Widget child; |
22 final int level; | 24 final int level; |
23 final MaterialEdge edge; | 25 final MaterialEdge edge; |
24 final Color color; | 26 final Color color; |
25 | 27 |
26 // TODO(ianh): we should make this animate level changes and color changes | 28 // TODO(ianh): we should make this animate level changes and color changes |
27 | 29 |
28 Widget build() { | 30 Widget build() { |
29 return new Container( | 31 return new Container( |
30 decoration: new BoxDecoration( | 32 decoration: new BoxDecoration( |
31 boxShadow: shadows[level], | 33 boxShadow: shadows[level], |
32 borderRadius: edges[edge], | 34 borderRadius: edges[edge], |
33 backgroundColor: color == null ? Grey[50] : color, | 35 backgroundColor: color == null ? Theme.of(this).backgroundColor : color, |
34 shape: edge == MaterialEdge.circle ? Shape.circle : Shape.rectangle | 36 shape: edge == MaterialEdge.circle ? Shape.circle : Shape.rectangle |
35 ), | 37 ), |
36 child: child | 38 child: new DefaultTextStyle(style: Theme.of(this).text.body1, child: child
) |
37 ); | 39 ); |
38 } | 40 } |
39 | 41 |
40 } | 42 } |
OLD | NEW |