| 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 '../fn2.dart'; | 5 import '../fn2.dart'; |
| 6 import 'button_base.dart'; | 6 import 'button_base.dart'; |
| 7 import 'icon.dart'; | 7 import 'icon.dart'; |
| 8 import 'ink_well.dart'; | 8 import 'ink_well.dart'; |
| 9 | 9 |
| 10 const BoxDecoration _kHighlightDecoration = const BoxDecoration( |
| 11 backgroundColor: const Color.fromARGB(102, 153, 153, 153) |
| 12 ); |
| 13 |
| 14 // TODO(abarth): We shouldn't need _kHighlightBoring, but currently Container |
| 15 // isn't smarth enough to retain the components it builds when we |
| 16 // add or remove a |decoration|. For now, we use a transparent |
| 17 // decoration to avoid changing the structure of the tree. The |
| 18 // right fix, however, is to make Container smarter about how it |
| 19 // syncs its subcomponents. |
| 20 const BoxDecoration _kHighlightBoring = const BoxDecoration( |
| 21 backgroundColor: const Color.fromARGB(0, 0, 0, 0) |
| 22 ); |
| 23 |
| 10 class MenuItem extends ButtonBase { | 24 class MenuItem extends ButtonBase { |
| 11 | |
| 12 MenuItem({ Object key, this.icon, this.children, this.onGestureTap }) : super(
key: key); | 25 MenuItem({ Object key, this.icon, this.children, this.onGestureTap }) : super(
key: key); |
| 13 | 26 |
| 14 static const BoxDecoration highlightDecoration = const BoxDecoration( | |
| 15 backgroundColor: const Color.fromARGB(102, 153, 153, 153) | |
| 16 ); | |
| 17 | |
| 18 List<UINode> children; | 27 List<UINode> children; |
| 19 String icon; | 28 String icon; |
| 20 GestureEventListener onGestureTap; | 29 GestureEventListener onGestureTap; |
| 21 | 30 |
| 22 UINode buildContent() { | 31 UINode buildContent() { |
| 23 return new EventListenerNode( | 32 return new EventListenerNode( |
| 24 new Container( | 33 new Container( |
| 25 child: new InkWell( | 34 child: new InkWell( |
| 26 children: [ | 35 children: [ |
| 27 new Padding( | 36 new Padding( |
| 28 child: new Icon(type: "${icon}_grey600", size: 24), | 37 child: new Icon(type: "${icon}_grey600", size: 24), |
| 29 padding: const EdgeDims.symmetric(horizontal: 16.0) | 38 padding: const EdgeDims.symmetric(horizontal: 16.0) |
| 30 ), | 39 ), |
| 31 new FlexExpandingChild( | 40 new FlexExpandingChild( |
| 32 new Padding( | 41 new Padding( |
| 33 child: new FlexContainer( | 42 child: new FlexContainer( |
| 34 direction: FlexDirection.horizontal, | 43 direction: FlexDirection.horizontal, |
| 35 children: children | 44 children: children |
| 36 ), | 45 ), |
| 37 padding: const EdgeDims.symmetric(horizontal: 16.0) | 46 padding: const EdgeDims.symmetric(horizontal: 16.0) |
| 38 ), | 47 ), |
| 39 flex: 1 | 48 flex: 1 |
| 40 ) | 49 ) |
| 41 ] | 50 ] |
| 42 ), | 51 ), |
| 43 height: 48.0, | 52 height: 48.0, |
| 44 decoration: highlight ? highlightDecoration : null | 53 decoration: highlight ? _kHighlightDecoration : _kHighlightBoring |
| 45 ), | 54 ), |
| 46 onGestureTap: onGestureTap | 55 onGestureTap: onGestureTap |
| 47 ); | 56 ); |
| 48 } | 57 } |
| 49 | |
| 50 } | 58 } |
| OLD | NEW |