| 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 '../painting/text_style.dart'; |
| 6 import 'basic.dart'; | 6 import 'basic.dart'; |
| 7 import 'button_base.dart'; | 7 import 'button_base.dart'; |
| 8 import 'default_text_style.dart'; | 8 import 'default_text_style.dart'; |
| 9 import 'icon.dart'; | 9 import 'icon.dart'; |
| 10 import 'ink_well.dart'; | 10 import 'ink_well.dart'; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 class MenuItem extends ButtonBase { | 28 class MenuItem extends ButtonBase { |
| 29 MenuItem({ String key, this.icon, this.children, this.onPressed, this.selected
: false }) | 29 MenuItem({ String key, this.icon, this.children, this.onPressed, this.selected
: false }) |
| 30 : super(key: key); | 30 : super(key: key); |
| 31 | 31 |
| 32 String icon; | 32 String icon; |
| 33 List<Widget> children; | 33 List<Widget> children; |
| 34 Function onPressed; | 34 Function onPressed; |
| 35 bool selected; | 35 bool selected; |
| 36 | 36 |
| 37 @override |
| 37 void syncFields(MenuItem source) { | 38 void syncFields(MenuItem source) { |
| 38 icon = source.icon; | 39 icon = source.icon; |
| 39 children = source.children; | 40 children = source.children; |
| 40 onPressed = source.onPressed; | 41 onPressed = source.onPressed; |
| 41 selected = source.selected; | 42 selected = source.selected; |
| 42 super.syncFields(source); | 43 super.syncFields(source); |
| 43 } | 44 } |
| 44 | 45 |
| 45 TextStyle get textStyle { | 46 TextStyle get textStyle { |
| 46 TextStyle result = Theme.of(this).text.body2; | 47 TextStyle result = Theme.of(this).text.body2; |
| 47 if (highlight) | 48 if (highlight) |
| 48 result = result.copyWith(color: Theme.of(this).primaryColor); | 49 result = result.copyWith(color: Theme.of(this).primaryColor); |
| 49 return result; | 50 return result; |
| 50 } | 51 } |
| 51 | 52 |
| 52 String get iconSuffix { | 53 String get iconSuffix { |
| 53 switch(Theme.of(this).brightness) { | 54 switch(Theme.of(this).brightness) { |
| 54 case ThemeBrightness.dark: | 55 case ThemeBrightness.dark: |
| 55 return "white"; | 56 return "white"; |
| 56 case ThemeBrightness.light: | 57 case ThemeBrightness.light: |
| 57 return "black"; | 58 return "black"; |
| 58 } | 59 } |
| 59 } | 60 } |
| 60 | 61 |
| 62 @override |
| 61 Widget buildContent() { | 63 Widget buildContent() { |
| 62 List<Widget> flexChildren = new List<Widget>(); | 64 List<Widget> flexChildren = new List<Widget>(); |
| 63 if (icon != null) { | 65 if (icon != null) { |
| 64 flexChildren.add( | 66 flexChildren.add( |
| 65 new Opacity( | 67 new Opacity( |
| 66 opacity: selected ? 1.0 : 0.45, | 68 opacity: selected ? 1.0 : 0.45, |
| 67 child: new Padding( | 69 child: new Padding( |
| 68 padding: const EdgeDims.symmetric(horizontal: 16.0), | 70 padding: const EdgeDims.symmetric(horizontal: 16.0), |
| 69 child: new Icon(type: "${icon}_${iconSuffix}", size: 24) | 71 child: new Icon(type: "${icon}_${iconSuffix}", size: 24) |
| 70 ) | 72 ) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 93 child: new Container( | 95 child: new Container( |
| 94 decoration: highlight ? _kHighlightDecoration : _kHighlightBoring, | 96 decoration: highlight ? _kHighlightDecoration : _kHighlightBoring, |
| 95 child: new InkWell( | 97 child: new InkWell( |
| 96 child: new Flex(flexChildren) | 98 child: new Flex(flexChildren) |
| 97 ) | 99 ) |
| 98 ) | 100 ) |
| 99 ) | 101 ) |
| 100 ); | 102 ); |
| 101 } | 103 } |
| 102 } | 104 } |
| OLD | NEW |