| 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 'basic.dart'; | 5 import 'basic.dart'; |
| 6 | 6 |
| 7 abstract class ButtonBase extends StatefulComponent { | 7 abstract class ButtonBase extends StatefulComponent { |
| 8 | 8 |
| 9 ButtonBase({ String key, this.highlight: false }) : super(key: key); | 9 ButtonBase({ String key, this.highlight: false }) : super(key: key); |
| 10 | 10 |
| 11 bool highlight; | 11 bool highlight; |
| 12 | 12 |
| 13 @override |
| 13 void syncFields(ButtonBase source) { | 14 void syncFields(ButtonBase source) { |
| 14 highlight = source.highlight; | 15 highlight = source.highlight; |
| 15 } | 16 } |
| 16 | 17 |
| 17 void _handlePointerDown(_) { | 18 void _handlePointerDown(_) { |
| 18 setState(() { | 19 setState(() { |
| 19 highlight = true; | 20 highlight = true; |
| 20 }); | 21 }); |
| 21 } | 22 } |
| 22 void _handlePointerUp(_) { | 23 void _handlePointerUp(_) { |
| 23 setState(() { | 24 setState(() { |
| 24 highlight = false; | 25 highlight = false; |
| 25 }); | 26 }); |
| 26 } | 27 } |
| 27 void _handlePointerCancel(_) { | 28 void _handlePointerCancel(_) { |
| 28 setState(() { | 29 setState(() { |
| 29 highlight = false; | 30 highlight = false; |
| 30 }); | 31 }); |
| 31 } | 32 } |
| 32 | 33 |
| 34 @override |
| 33 Widget build() { | 35 Widget build() { |
| 34 return new Listener( | 36 return new Listener( |
| 35 child: buildContent(), | 37 child: buildContent(), |
| 36 onPointerDown: _handlePointerDown, | 38 onPointerDown: _handlePointerDown, |
| 37 onPointerUp: _handlePointerUp, | 39 onPointerUp: _handlePointerUp, |
| 38 onPointerCancel: _handlePointerCancel | 40 onPointerCancel: _handlePointerCancel |
| 39 ); | 41 ); |
| 40 } | 42 } |
| 41 | 43 |
| 42 Widget buildContent(); | 44 Widget buildContent(); |
| 43 | 45 |
| 44 } | 46 } |
| OLD | NEW |