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

Side by Side Diff: sky/sdk/lib/framework/components2/button_base.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 6
7 abstract class ButtonBase extends Component { 7 abstract class ButtonBase extends Component {
8 8
9 ButtonBase({ Object key }) : super(key: key); 9 ButtonBase({ Object key, this.highlight: false }) : super(key: key);
10 10
11 UINode buildContent(); 11 bool highlight;
12 12
13 UINode build() { 13 void syncFields(ButtonBase source) {
14 return new EventListenerNode( 14 highlight = source.highlight;
15 buildContent(),
16 onPointerDown: _handlePointerDown,
17 onPointerUp: _handlePointerUp,
18 onPointerCancel: _handlePointerCancel
19 );
20 } 15 }
21 16
22 bool highlight = false;
23
24 void _handlePointerDown(_) { 17 void _handlePointerDown(_) {
25 setState(() { 18 setState(() {
26 highlight = true; 19 highlight = true;
27 }); 20 });
28 } 21 }
29 void _handlePointerUp(_) { 22 void _handlePointerUp(_) {
30 setState(() { 23 setState(() {
31 highlight = false; 24 highlight = false;
32 }); 25 });
33 } 26 }
34 void _handlePointerCancel(_) { 27 void _handlePointerCancel(_) {
35 setState(() { 28 setState(() {
36 highlight = false; 29 highlight = false;
37 }); 30 });
38 } 31 }
32
33 UINode build() {
34 return new EventListenerNode(
35 buildContent(),
36 onPointerDown: _handlePointerDown,
37 onPointerUp: _handlePointerUp,
38 onPointerCancel: _handlePointerCancel
39 );
40 }
41
42 UINode buildContent();
43
39 } 44 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/components2/button.dart ('k') | sky/sdk/lib/framework/components2/checkbox.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698