| 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); |
| 18 |
| 17 bool checked; | 19 bool checked; |
| 18 ValueChanged onChanged; | 20 ValueChanged onChanged; |
| 19 | 21 |
| 20 Checkbox({ Object key, this.onChanged, this.checked }) : super(key: key); | |
| 21 | |
| 22 void _handleClick(sky.Event e) { | 22 void _handleClick(sky.Event e) { |
| 23 onChanged(!checked); | 23 onChanged(!checked); |
| 24 } | 24 } |
| 25 | 25 |
| 26 UINode buildContent() { | 26 UINode buildContent() { |
| 27 // TODO(jackson): This should change colors with the theme | 27 // TODO(jackson): This should change colors with the theme |
| 28 sky.Color color = highlight ? colors.Purple[500] : const sky.Color(0x8A00000
0); | 28 sky.Color color = highlight ? colors.Purple[500] : const sky.Color(0x8A00000
0); |
| 29 const double edgeSize = 20.0; | 29 const double edgeSize = 20.0; |
| 30 const double edgeRadius = 1.0; | 30 const double edgeRadius = 1.0; |
| 31 return new EventListenerNode( | 31 return new EventListenerNode( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 56 path.lineTo(edgeSize * 0.4, edgeSize * 0.7); | 56 path.lineTo(edgeSize * 0.4, edgeSize * 0.7); |
| 57 path.lineTo(edgeSize * 0.8, edgeSize * 0.3); | 57 path.lineTo(edgeSize * 0.8, edgeSize * 0.3); |
| 58 canvas.drawPath(path, paint); | 58 canvas.drawPath(path, paint); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 ) | 61 ) |
| 62 ), | 62 ), |
| 63 onGestureTap: _handleClick | 63 onGestureTap: _handleClick |
| 64 ); | 64 ); |
| 65 } | 65 } |
| 66 |
| 66 } | 67 } |
| OLD | NEW |