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