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