Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1243)

Side by Side Diff: sky/sdk/lib/widgets/menu_item.dart

Issue 1233983002: Rename MenuItem to DrawerItem (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/widgets/menu_divider.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 import 'dart:sky' as sky;
6
7 import 'package:sky/painting/text_style.dart';
8 import 'package:sky/theme/colors.dart' as colors;
9 import 'package:sky/widgets/basic.dart';
10 import 'package:sky/widgets/button_base.dart';
11 import 'package:sky/widgets/default_text_style.dart';
12 import 'package:sky/widgets/icon.dart';
13 import 'package:sky/widgets/ink_well.dart';
14 import 'package:sky/widgets/theme.dart';
15 import 'package:sky/widgets/widget.dart';
16
17 class MenuItem extends ButtonBase {
18 MenuItem({ String key, this.icon, this.children, this.onPressed, this.selected : false })
19 : super(key: key);
20
21 String icon;
22 List<Widget> children;
23 Function onPressed;
24 bool selected;
25
26 void syncFields(MenuItem source) {
27 icon = source.icon;
28 children = source.children;
29 onPressed = source.onPressed;
30 selected = source.selected;
31 super.syncFields(source);
32 }
33
34 TextStyle _getTextStyle(ThemeData themeData) {
35 TextStyle result = themeData.text.body2;
36 if (selected)
37 result = result.copyWith(color: themeData.primaryColor);
38 return result;
39 }
40
41 Color _getBackgroundColor(ThemeData themeData) {
42 if (highlight)
43 return themeData.highlightColor;
44 if (selected)
45 return themeData.selectedColor;
46 return colors.transparent;
47 }
48
49 Widget buildContent() {
50 ThemeData themeData = Theme.of(this);
51
52 List<Widget> flexChildren = new List<Widget>();
53 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(
63 new Opacity(
64 opacity: selected ? 1.0 : 0.45,
65 child: new Padding(
66 padding: const EdgeDims.symmetric(horizontal: 16.0),
67 child: child
68 )
69 )
70 );
71 }
72 flexChildren.add(
73 new Flexible(
74 child: new Padding(
75 padding: const EdgeDims.symmetric(horizontal: 16.0),
76 child: new DefaultTextStyle(
77 style: _getTextStyle(themeData),
78 child: new Flex(children, direction: FlexDirection.horizontal)
79 )
80 )
81 )
82 );
83
84 return new Listener(
85 onGestureTap: (_) {
86 if (onPressed != null)
87 onPressed();
88 },
89 child: new Container(
90 height: 48.0,
91 decoration: new BoxDecoration(backgroundColor: _getBackgroundColor(theme Data)),
92 child: new InkWell(
93 child: new Flex(flexChildren)
94 )
95 )
96 );
97 }
98 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/menu_divider.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698