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

Side by Side Diff: sky/sdk/lib/widgets/material.dart

Issue 1217293003: Remove Material's opinion about background colours, since in fact the background colour varies dram… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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/widgets/flat_button.dart ('k') | sky/sdk/lib/widgets/scrollable.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 '../painting/box_painter.dart'; 5 import '../painting/box_painter.dart';
6 import '../theme/colors.dart' as colors;
7 import '../theme/edges.dart'; 6 import '../theme/edges.dart';
8 import '../theme/shadows.dart'; 7 import '../theme/shadows.dart';
9 import 'basic.dart'; 8 import 'basic.dart';
10 import 'default_text_style.dart'; 9 import 'default_text_style.dart';
11 import 'theme.dart'; 10 import 'theme.dart';
12 11
13 export '../theme/edges.dart' show MaterialEdge; 12 export '../theme/edges.dart' show MaterialEdge;
14 13
15 class Material extends Component { 14 class Material extends Component {
16 15
17 Material({ 16 Material({
18 String key, 17 String key,
19 this.child, 18 this.child,
20 this.edge: MaterialEdge.card, 19 this.edge: MaterialEdge.card,
21 this.level: 0, 20 this.level: 0,
22 this.color 21 this.color
23 }) : super(key: key); 22 }) : super(key: key);
24 23
25 final Widget child; 24 final Widget child;
26 final int level; 25 final int level;
27 final MaterialEdge edge; 26 final MaterialEdge edge;
28 final Color color; 27 final Color color;
29 28
30 Color get backgroundColor {
31 if (color != null)
32 return color;
33 switch (Theme.of(this).brightness) {
34 case ThemeBrightness.light:
35 return colors.Grey[50];
36 case ThemeBrightness.dark:
37 return colors.Grey[850];
38 }
39 }
40
41 // TODO(ianh): we should make this animate level changes and color changes 29 // TODO(ianh): we should make this animate level changes and color changes
42 30
43 Widget build() { 31 Widget build() {
44 return new Container( 32 return new Container(
45 decoration: new BoxDecoration( 33 decoration: new BoxDecoration(
46 boxShadow: shadows[level], 34 boxShadow: shadows[level],
47 borderRadius: edges[edge], 35 borderRadius: edges[edge],
48 backgroundColor: backgroundColor, 36 backgroundColor: color,
49 shape: edge == MaterialEdge.circle ? Shape.circle : Shape.rectangle 37 shape: edge == MaterialEdge.circle ? Shape.circle : Shape.rectangle
50 ), 38 ),
51 child: new DefaultTextStyle(style: Theme.of(this).text.body1, child: child ) 39 child: new DefaultTextStyle(style: Theme.of(this).text.body1, child: child )
52 ); 40 );
53 } 41 }
54 42
55 } 43 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/flat_button.dart ('k') | sky/sdk/lib/widgets/scrollable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698