Chromium Code Reviews

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.
Jump to:
View unified diff |
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 }) : super(key: key);
10
11 UINode buildContent();
12
13 UINode build() {
14 return new EventListenerNode(
15 buildContent(),
16 onPointerDown: _handlePointerDown,
17 onPointerUp: _handlePointerUp,
18 onPointerCancel: _handlePointerCancel
19 );
20 }
21 10
22 bool highlight = false; 11 bool highlight = false;
23 12
13 void syncFields(ButtonBase source) {
14 highlight = source.highlight;
15 super.syncFields(source);
16 }
17
24 void _handlePointerDown(_) { 18 void _handlePointerDown(_) {
25 setState(() { 19 setState(() {
26 highlight = true; 20 highlight = true;
27 }); 21 });
28 } 22 }
29 void _handlePointerUp(_) { 23 void _handlePointerUp(_) {
30 setState(() { 24 setState(() {
31 highlight = false; 25 highlight = false;
32 }); 26 });
33 } 27 }
34 void _handlePointerCancel(_) { 28 void _handlePointerCancel(_) {
35 setState(() { 29 setState(() {
36 highlight = false; 30 highlight = false;
37 }); 31 });
38 } 32 }
33
34 UINode build() {
35 return new EventListenerNode(
36 buildContent(),
37 onPointerDown: _handlePointerDown,
38 onPointerUp: _handlePointerUp,
39 onPointerCancel: _handlePointerCancel
40 );
41 }
42
43 UINode buildContent();
44
39 } 45 }
OLDNEW

Powered by Google App Engine