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 'package:sky/widgets/theme.dart'; | 5 import 'package:sky/widgets/theme.dart'; |
6 | 6 |
| 7 import '../painting/text_style.dart'; |
7 import '../rendering/flex.dart'; | 8 import '../rendering/flex.dart'; |
8 import '../theme/shadows.dart'; | 9 import '../theme/shadows.dart'; |
| 10 import '../theme/typography.dart' as typography; |
9 import '../theme/view_configuration.dart'; | 11 import '../theme/view_configuration.dart'; |
10 import 'basic.dart'; | 12 import 'basic.dart'; |
11 import 'default_text_style.dart'; | 13 import 'default_text_style.dart'; |
| 14 import 'icon.dart'; |
12 | 15 |
13 class ToolBar extends Component { | 16 class ToolBar extends Component { |
14 | 17 |
15 ToolBar({ | 18 ToolBar({ |
16 String key, | 19 String key, |
17 this.left, | 20 this.left, |
18 this.center, | 21 this.center, |
19 this.right, | 22 this.right, |
20 this.backgroundColor | 23 this.backgroundColor |
21 }) : super(key: key); | 24 }) : super(key: key); |
22 | 25 |
23 final Widget left; | 26 final Widget left; |
24 final Widget center; | 27 final Widget center; |
25 final List<Widget> right; | 28 final List<Widget> right; |
26 final Color backgroundColor; | 29 final Color backgroundColor; |
27 | 30 |
28 Widget build() { | 31 Widget build() { |
| 32 Color toolbarColor = backgroundColor; |
| 33 IconThemeColor iconThemeColor = IconThemeColor.white; |
| 34 TextStyle defaultTextStyle = typography.white.title; |
| 35 if (toolbarColor == null) { |
| 36 ThemeData themeData = Theme.of(this); |
| 37 toolbarColor = themeData.primaryColor; |
| 38 if (themeData.primaryColorBrightness == ThemeBrightness.light) { |
| 39 iconThemeColor = IconThemeColor.black; |
| 40 defaultTextStyle = typography.black.title; |
| 41 } |
| 42 } |
| 43 |
29 List<Widget> children = new List<Widget>(); | 44 List<Widget> children = new List<Widget>(); |
30 if (left != null) | 45 if (left != null) |
31 children.add(left); | 46 children.add(left); |
32 | 47 |
33 if (center != null) { | 48 if (center != null) { |
34 children.add( | 49 children.add( |
35 new Flexible( | 50 new Flexible( |
36 child: new Padding( | 51 child: new Padding( |
37 child: new DefaultTextStyle( | 52 child: new DefaultTextStyle( |
38 style: Theme.of(this).toolbarText.title, | 53 style: defaultTextStyle, |
39 child: center | 54 child: center |
40 ), | 55 ), |
41 padding: new EdgeDims.only(left: 24.0) | 56 padding: new EdgeDims.only(left: 24.0) |
42 ) | 57 ) |
43 ) | 58 ) |
44 ); | 59 ); |
45 } | 60 } |
46 | 61 |
47 if (right != null) | 62 if (right != null) |
48 children.addAll(right); | 63 children.addAll(right); |
49 | 64 |
50 return new Container( | 65 return new Container( |
51 child: new Flex( | 66 child: new IconTheme( |
52 [new Container(child: new Flex(children), height: kToolBarHeight)], | 67 data: new IconThemeData(color: iconThemeColor), |
53 alignItems: FlexAlignItems.flexEnd | 68 child: new Flex( |
| 69 [new Container(child: new Flex(children), height: kToolBarHeight)], |
| 70 alignItems: FlexAlignItems.flexEnd |
| 71 ) |
54 ), | 72 ), |
55 padding: new EdgeDims.symmetric(horizontal: 8.0), | 73 padding: new EdgeDims.symmetric(horizontal: 8.0), |
56 decoration: new BoxDecoration( | 74 decoration: new BoxDecoration( |
57 backgroundColor: backgroundColor == null ? Theme.of(this).primaryColor :
backgroundColor, | 75 backgroundColor: toolbarColor, |
58 boxShadow: shadows[2] | 76 boxShadow: shadows[2] |
59 ) | 77 ) |
60 ); | 78 ); |
61 } | 79 } |
62 | 80 |
63 } | 81 } |
OLD | NEW |