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 '../rendering/flex.dart'; | 5 import '../rendering/flex.dart'; |
6 import '../theme2/shadows.dart'; | 6 import '../theme2/shadows.dart'; |
7 import '../theme2/view_configuration.dart'; | 7 import '../theme2/view_configuration.dart'; |
8 import 'wrappers.dart'; | 8 import 'wrappers.dart'; |
9 | 9 |
10 class ToolBar extends Component { | 10 class ToolBar extends Component { |
11 | 11 |
12 ToolBar({ | 12 ToolBar({ |
13 String key, | 13 String key, |
14 this.left, | 14 this.left, |
15 this.center, | 15 this.center, |
16 this.right, | 16 this.right, |
17 this.backgroundColor | 17 this.backgroundColor |
18 }) : super(key: key); | 18 }) : super(key: key); |
19 | 19 |
20 final UINode left; | 20 final UINode left; |
21 final UINode center; | 21 final UINode center; |
22 final List<UINode> right; | 22 final List<UINode> right; |
23 final Color backgroundColor; | 23 final Color backgroundColor; |
24 | 24 |
25 UINode build() { | 25 UINode build() { |
26 List<UINode> children = [ | 26 List<UINode> children = new List<UINode>(); |
27 left, | 27 if (left != null) |
28 new FlexExpandingChild( | 28 children.add(left); |
29 new Padding( | 29 |
30 child: center, | 30 if (center != null) { |
31 padding: new EdgeDims.only(left: 24.0) | 31 children.add(new FlexExpandingChild( |
32 )) | 32 new Padding(child: center, padding: new EdgeDims.only(left: 24.0)))); |
33 ]; | 33 } |
34 | 34 |
35 if (right != null) | 35 if (right != null) |
36 children.addAll(right); | 36 children.addAll(right); |
37 | 37 |
38 return new Container( | 38 return new Container( |
39 child: new Flex( | 39 child: new Flex( |
40 [new Container(child: new Flex(children), height: kToolBarHeight)], | 40 [new Container(child: new Flex(children), height: kToolBarHeight)], |
41 alignItems: FlexAlignItems.flexEnd | 41 alignItems: FlexAlignItems.flexEnd |
42 ), | 42 ), |
43 padding: new EdgeDims.symmetric(horizontal: 8.0), | 43 padding: new EdgeDims.symmetric(horizontal: 8.0), |
44 decoration: new BoxDecoration( | 44 decoration: new BoxDecoration( |
45 backgroundColor: backgroundColor, | 45 backgroundColor: backgroundColor, |
46 boxShadow: shadows[2] | 46 boxShadow: shadows[2] |
47 ) | 47 ) |
48 ); | 48 ); |
49 } | 49 } |
50 | 50 |
51 } | 51 } |
OLD | NEW |