| 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 '../painting/text_style.dart'; |
| 5 import 'basic.dart'; | 6 import 'basic.dart'; |
| 6 import 'button_base.dart'; | 7 import 'button_base.dart'; |
| 8 import 'default_text_style.dart'; |
| 7 import 'icon.dart'; | 9 import 'icon.dart'; |
| 8 import 'ink_well.dart'; | 10 import 'ink_well.dart'; |
| 11 import 'theme.dart'; |
| 9 import 'widget.dart'; | 12 import 'widget.dart'; |
| 10 | 13 |
| 11 const BoxDecoration _kHighlightDecoration = const BoxDecoration( | 14 const BoxDecoration _kHighlightDecoration = const BoxDecoration( |
| 12 backgroundColor: const Color.fromARGB(102, 153, 153, 153) | 15 backgroundColor: const Color.fromARGB(102, 153, 153, 153) |
| 13 ); | 16 ); |
| 14 | 17 |
| 15 // TODO(abarth): We shouldn't need _kHighlightBoring, but currently Container | 18 // TODO(abarth): We shouldn't need _kHighlightBoring, but currently Container |
| 16 // isn't smart enough to retain the components it builds when we | 19 // isn't smart enough to retain the components it builds when we |
| 17 // add or remove a |decoration|. For now, we use a transparent | 20 // add or remove a |decoration|. For now, we use a transparent |
| 18 // decoration to avoid changing the structure of the tree. The | 21 // decoration to avoid changing the structure of the tree. The |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 List<Widget> children; | 33 List<Widget> children; |
| 31 Function onPressed; | 34 Function onPressed; |
| 32 | 35 |
| 33 void syncFields(MenuItem source) { | 36 void syncFields(MenuItem source) { |
| 34 icon = source.icon; | 37 icon = source.icon; |
| 35 children = source.children; | 38 children = source.children; |
| 36 onPressed = source.onPressed; | 39 onPressed = source.onPressed; |
| 37 super.syncFields(source); | 40 super.syncFields(source); |
| 38 } | 41 } |
| 39 | 42 |
| 43 TextStyle get textStyle { |
| 44 TextStyle result = Theme.of(this).text.body2; |
| 45 if (highlight) |
| 46 result = result.copyWith(color: Theme.of(this).primary[500]); |
| 47 return result; |
| 48 } |
| 49 |
| 40 Widget buildContent() { | 50 Widget buildContent() { |
| 41 return new Listener( | 51 return new Listener( |
| 42 onGestureTap: (_) { | 52 onGestureTap: (_) { |
| 43 if (onPressed != null) | 53 if (onPressed != null) |
| 44 onPressed(); | 54 onPressed(); |
| 45 }, | 55 }, |
| 46 child: new Container( | 56 child: new Container( |
| 47 height: 48.0, | 57 height: 48.0, |
| 48 decoration: highlight ? _kHighlightDecoration : _kHighlightBoring, | 58 decoration: highlight ? _kHighlightDecoration : _kHighlightBoring, |
| 49 child: new InkWell( | 59 child: new InkWell( |
| 50 child: new Flex([ | 60 child: new Flex([ |
| 51 new Padding( | 61 new Padding( |
| 52 padding: const EdgeDims.symmetric(horizontal: 16.0), | 62 padding: const EdgeDims.symmetric(horizontal: 16.0), |
| 53 child: new Icon(type: "${icon}_grey600", size: 24) | 63 child: new Icon(type: "${icon}_grey600", size: 24) |
| 54 ), | 64 ), |
| 55 new Flexible( | 65 new Flexible( |
| 56 flex: 1, | |
| 57 child: new Padding( | 66 child: new Padding( |
| 58 padding: const EdgeDims.symmetric(horizontal: 16.0), | 67 padding: const EdgeDims.symmetric(horizontal: 16.0), |
| 59 child: new Flex(children, direction: FlexDirection.horizontal) | 68 child: new DefaultTextStyle( |
| 69 style: textStyle, |
| 70 child: new Flex(children, direction: FlexDirection.horizontal) |
| 71 ) |
| 60 ) | 72 ) |
| 61 ) | 73 ) |
| 62 ]) | 74 ]) |
| 63 ) | 75 ) |
| 64 ) | 76 ) |
| 65 ); | 77 ); |
| 66 } | 78 } |
| 67 } | 79 } |
| OLD | NEW |