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