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 '../fn.dart'; | 5 import '../fn.dart'; |
6 import '../layout.dart'; | 6 import '../layout.dart'; |
7 import 'button_base.dart'; | 7 import 'button_base.dart'; |
8 import 'icon.dart'; | 8 import 'icon.dart'; |
9 import 'ink_well.dart'; | 9 import 'ink_well.dart'; |
10 | 10 |
11 class MenuItem extends ButtonBase { | 11 class MenuItem extends ButtonBase { |
12 static final Style _style = new Style(''' | 12 static final Style _style = new Style(''' |
13 align-items: center; | 13 align-items: center; |
14 height: 48px; | 14 height: 48px; |
15 -webkit-user-select: none;''' | 15 -webkit-user-select: none;''' |
16 ); | 16 ); |
17 | 17 |
18 static final Style _highlightStyle = new Style(''' | 18 static final Style _highlightStyle = new Style(''' |
19 align-items: center; | 19 align-items: center; |
20 height: 48px; | 20 height: 48px; |
21 background: rgba(153, 153, 153, 0.4); | 21 background: rgba(153, 153, 153, 0.4); |
22 -webkit-user-select: none;''' | 22 -webkit-user-select: none;''' |
23 ); | 23 ); |
24 | 24 |
25 static final Style _iconStyle = new Style(''' | 25 static final Style _iconStyle = new Style(''' |
26 padding: 0px 16px;''' | 26 padding: 0px 16px;''' |
27 ); | 27 ); |
28 | 28 |
29 static final Style _labelStyle = new Style(''' | 29 static final Style _labelStyle = new Style(''' |
30 padding: 0px 16px; | 30 padding: 0px 16px;''' |
31 flex: 1;''' | |
32 ); | 31 ); |
33 | 32 |
| 33 static final FlexBoxParentData _labelFlex = new FlexBoxParentData()..flex = 1; |
| 34 |
34 List<UINode> children; | 35 List<UINode> children; |
35 String icon; | 36 String icon; |
36 GestureEventListener onGestureTap; | 37 GestureEventListener onGestureTap; |
37 | 38 |
38 MenuItem({ Object key, this.icon, this.children, this.onGestureTap }) : super(
key: key); | 39 MenuItem({ Object key, this.icon, this.children, this.onGestureTap }) : super(
key: key); |
39 | 40 |
40 UINode buildContent() { | 41 UINode buildContent() { |
41 return new EventListenerNode( | 42 return new EventListenerNode( |
42 new StyleNode( | 43 new StyleNode( |
43 new InkWell( | 44 new InkWell( |
44 children: [ | 45 children: [ |
45 new StyleNode( | 46 new StyleNode( |
46 new Icon( | 47 new Icon( |
47 size: 24, | 48 size: 24, |
48 type: "${icon}_grey600" | 49 type: "${icon}_grey600" |
49 ), | 50 ), |
50 _iconStyle | 51 _iconStyle |
51 ), | 52 ), |
52 new FlexContainer( | 53 new ParentDataNode( |
53 direction: FlexDirection.Row, | 54 new FlexContainer( |
54 style: _labelStyle, | 55 direction: FlexDirection.Row, |
55 children: children | 56 style: _labelStyle, |
| 57 children: children |
| 58 ), |
| 59 _labelFlex |
56 ) | 60 ) |
57 ] | 61 ] |
58 ), | 62 ), |
59 highlight ? _highlightStyle : _style | 63 highlight ? _highlightStyle : _style |
60 ), | 64 ), |
61 onGestureTap: onGestureTap | 65 onGestureTap: onGestureTap |
62 ); | 66 ); |
63 } | 67 } |
64 } | 68 } |
OLD | NEW |