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 'package:sky/framework/theme2/colors.dart' as colors; | 5 import 'package:sky/framework/theme2/colors.dart' as colors; |
6 | 6 |
7 import 'dart:sky' as sky; | 7 import 'dart:sky' as sky; |
8 import '../fn2.dart'; | 8 import '../fn2.dart'; |
9 import '../rendering/box.dart'; | 9 import '../rendering/box.dart'; |
10 import '../rendering/object.dart'; | 10 import '../rendering/object.dart'; |
11 import 'button_base.dart'; | 11 import 'button_base.dart'; |
12 | 12 |
13 typedef void ValueChanged(value); | 13 typedef void ValueChanged(value); |
14 | 14 |
15 class Checkbox extends ButtonBase { | 15 class Checkbox extends ButtonBase { |
16 | 16 |
17 Checkbox({ Object key, this.onChanged, this.checked }) : super(key: key); | 17 Checkbox({ Object key, this.onChanged, this.checked }) : super(key: key); |
18 | 18 |
19 bool checked; | 19 bool checked; |
20 ValueChanged onChanged; | 20 ValueChanged onChanged; |
21 | 21 |
| 22 void syncFields(Checkbox source) { |
| 23 checked = source.checked; |
| 24 onChanged = source.onChanged; |
| 25 super.syncFields(source); |
| 26 } |
| 27 |
22 void _handleClick(sky.Event e) { | 28 void _handleClick(sky.Event e) { |
23 onChanged(!checked); | 29 onChanged(!checked); |
24 } | 30 } |
25 | 31 |
26 UINode buildContent() { | 32 UINode buildContent() { |
27 // TODO(jackson): This should change colors with the theme | 33 // TODO(jackson): This should change colors with the theme |
28 sky.Color color = highlight ? colors.Purple[500] : const sky.Color(0x8A00000
0); | 34 sky.Color color = highlight ? colors.Purple[500] : const sky.Color(0x8A00000
0); |
29 const double edgeSize = 20.0; | 35 const double edgeSize = 20.0; |
30 const double edgeRadius = 1.0; | 36 const double edgeRadius = 1.0; |
31 return new EventListenerNode( | 37 return new EventListenerNode( |
(...skipping 26 matching lines...) Expand all Loading... |
58 canvas.drawPath(path, paint); | 64 canvas.drawPath(path, paint); |
59 } | 65 } |
60 } | 66 } |
61 ) | 67 ) |
62 ), | 68 ), |
63 onGestureTap: _handleClick | 69 onGestureTap: _handleClick |
64 ); | 70 ); |
65 } | 71 } |
66 | 72 |
67 } | 73 } |
OLD | NEW |