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

Side by Side Diff: sky/sdk/lib/framework/components2/menu_item.dart

Issue 1174023003: Remove one more use of mirrors: Components now have to explicitly sync their fields. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
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( 10 const BoxDecoration _kHighlightDecoration = const BoxDecoration(
11 backgroundColor: const Color.fromARGB(102, 153, 153, 153) 11 backgroundColor: const Color.fromARGB(102, 153, 153, 153)
12 ); 12 );
13 13
14 // TODO(abarth): We shouldn't need _kHighlightBoring, but currently Container 14 // TODO(abarth): We shouldn't need _kHighlightBoring, but currently Container
15 // isn't smarth enough to retain the components it builds when we 15 // isn't smart enough to retain the components it builds when we
16 // add or remove a |decoration|. For now, we use a transparent 16 // add or remove a |decoration|. For now, we use a transparent
17 // decoration to avoid changing the structure of the tree. The 17 // decoration to avoid changing the structure of the tree. The
18 // right fix, however, is to make Container smarter about how it 18 // right fix, however, is to make Container smarter about how it
19 // syncs its subcomponents. 19 // syncs its subcomponents.
20 const BoxDecoration _kHighlightBoring = const BoxDecoration( 20 const BoxDecoration _kHighlightBoring = const BoxDecoration(
21 backgroundColor: const Color.fromARGB(0, 0, 0, 0) 21 backgroundColor: const Color.fromARGB(0, 0, 0, 0)
22 ); 22 );
23 23
24 class MenuItem extends ButtonBase { 24 class MenuItem extends ButtonBase {
25 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);
26 26
27 String icon;
27 List<UINode> children; 28 List<UINode> children;
28 String icon;
29 GestureEventListener onGestureTap; 29 GestureEventListener onGestureTap;
30 30
31 void syncFields(MenuItem source) {
32 icon = source.icon;
33 children = source.children;
34 onGestureTap = source.onGestureTap;
35 super.syncFields(source);
36 }
37
31 UINode buildContent() { 38 UINode buildContent() {
32 return new EventListenerNode( 39 return new EventListenerNode(
33 new Container( 40 new Container(
34 child: new InkWell( 41 child: new InkWell(
35 children: [ 42 children: [
36 new Padding( 43 new Padding(
37 child: new Icon(type: "${icon}_grey600", size: 24), 44 child: new Icon(type: "${icon}_grey600", size: 24),
38 padding: const EdgeDims.symmetric(horizontal: 16.0) 45 padding: const EdgeDims.symmetric(horizontal: 16.0)
39 ), 46 ),
40 new FlexExpandingChild( 47 new FlexExpandingChild(
41 new Padding( 48 new Padding(
42 child: new FlexContainer( 49 child: new FlexContainer(
43 direction: FlexDirection.horizontal, 50 direction: FlexDirection.horizontal,
44 children: children 51 children: children
45 ), 52 ),
46 padding: const EdgeDims.symmetric(horizontal: 16.0) 53 padding: const EdgeDims.symmetric(horizontal: 16.0)
47 ), 54 ),
48 flex: 1 55 flex: 1
49 ) 56 )
50 ] 57 ]
51 ), 58 ),
52 height: 48.0, 59 height: 48.0,
53 decoration: highlight ? _kHighlightDecoration : _kHighlightBoring 60 decoration: highlight ? _kHighlightDecoration : _kHighlightBoring
54 ), 61 ),
55 onGestureTap: onGestureTap 62 onGestureTap: onGestureTap
56 ); 63 );
57 } 64 }
58 } 65 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/components2/material.dart ('k') | sky/sdk/lib/framework/components2/modal_overlay.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698