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 'dart:sky' as sky; |
6 | 6 |
7 import 'package:sky/painting/text_style.dart'; | 7 import 'package:sky/painting/text_style.dart'; |
8 import 'package:sky/theme/colors.dart' as colors; | 8 import 'package:sky/theme/colors.dart' as colors; |
9 import 'package:sky/widgets/basic.dart'; | 9 import 'package:sky/widgets/basic.dart'; |
10 import 'package:sky/widgets/button_base.dart'; | 10 import 'package:sky/widgets/button_base.dart'; |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 Color _getBackgroundColor(ThemeData themeData) { | 41 Color _getBackgroundColor(ThemeData themeData) { |
42 if (highlight) | 42 if (highlight) |
43 return themeData.highlightColor; | 43 return themeData.highlightColor; |
44 if (selected) | 44 if (selected) |
45 return themeData.selectedColor; | 45 return themeData.selectedColor; |
46 return colors.transparent; | 46 return colors.transparent; |
47 } | 47 } |
48 | 48 |
| 49 sky.ColorFilter _getColorFilter(ThemeData themeData) { |
| 50 if (selected) |
| 51 return new sky.ColorFilter.mode(themeData.primaryColor, sky.TransferMode.s
rcATop); |
| 52 return new sky.ColorFilter.mode(const Color(0x73000000), sky.TransferMode.ds
tIn); |
| 53 } |
| 54 |
49 Widget buildContent() { | 55 Widget buildContent() { |
50 ThemeData themeData = Theme.of(this); | 56 ThemeData themeData = Theme.of(this); |
51 | 57 |
52 List<Widget> flexChildren = new List<Widget>(); | 58 List<Widget> flexChildren = new List<Widget>(); |
53 if (icon != null) { | 59 if (icon != null) { |
54 Widget child = new Icon(type: icon, size: 24); | |
55 if (selected) { | |
56 child = new ColorFilter( | |
57 color: themeData.primaryColor, | |
58 transferMode: sky.TransferMode.srcATop, | |
59 child: child | |
60 ); | |
61 } | |
62 flexChildren.add( | 60 flexChildren.add( |
63 new Opacity( | 61 new Padding( |
64 opacity: selected ? 1.0 : 0.45, | 62 padding: const EdgeDims.symmetric(horizontal: 16.0), |
65 child: new Padding( | 63 child: new Icon( |
66 padding: const EdgeDims.symmetric(horizontal: 16.0), | 64 type: icon, |
67 child: child | 65 size: 24, |
68 ) | 66 colorFilter: _getColorFilter(themeData)) |
69 ) | 67 ) |
70 ); | 68 ); |
71 } | 69 } |
72 flexChildren.add( | 70 flexChildren.add( |
73 new Flexible( | 71 new Flexible( |
74 child: new Padding( | 72 child: new Padding( |
75 padding: const EdgeDims.symmetric(horizontal: 16.0), | 73 padding: const EdgeDims.symmetric(horizontal: 16.0), |
76 child: new DefaultTextStyle( | 74 child: new DefaultTextStyle( |
77 style: _getTextStyle(themeData), | 75 style: _getTextStyle(themeData), |
78 child: new Flex(children, direction: FlexDirection.horizontal) | 76 child: new Flex(children, direction: FlexDirection.horizontal) |
(...skipping 10 matching lines...) Expand all Loading... |
89 child: new Container( | 87 child: new Container( |
90 height: 48.0, | 88 height: 48.0, |
91 decoration: new BoxDecoration(backgroundColor: _getBackgroundColor(theme
Data)), | 89 decoration: new BoxDecoration(backgroundColor: _getBackgroundColor(theme
Data)), |
92 child: new InkWell( | 90 child: new InkWell( |
93 child: new Flex(flexChildren) | 91 child: new Flex(flexChildren) |
94 ) | 92 ) |
95 ) | 93 ) |
96 ); | 94 ); |
97 } | 95 } |
98 } | 96 } |
OLD | NEW |