| 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 '../fn2.dart'; | 7 import '../fn2.dart'; |
| 8 import '../rendering/object.dart'; | 8 import '../rendering/object.dart'; |
| 9 import 'button_base.dart'; | 9 import 'button_base.dart'; |
| 10 import 'ink_well.dart'; | 10 import 'ink_well.dart'; |
| 11 import 'dart:sky' as sky; | 11 import 'dart:sky' as sky; |
| 12 | 12 |
| 13 typedef void ValueChanged(value); | 13 typedef void ValueChanged(value); |
| 14 | 14 |
| 15 class Radio extends ButtonBase { | 15 class Radio extends ButtonBase { |
| 16 | 16 |
| 17 Radio({ | 17 Radio({ |
| 18 Object key, | 18 Object key, |
| 19 this.onChanged, | |
| 20 this.value, | 19 this.value, |
| 21 this.groupValue | 20 this.groupValue, |
| 21 this.onChanged |
| 22 }) : super(key: key); | 22 }) : super(key: key); |
| 23 | 23 |
| 24 Object value; | 24 Object value; |
| 25 Object groupValue; | 25 Object groupValue; |
| 26 ValueChanged onChanged; | 26 ValueChanged onChanged; |
| 27 | 27 |
| 28 void syncFields(Radio source) { |
| 29 value = source.value; |
| 30 groupValue = source.groupValue; |
| 31 onChanged = source.onChanged; |
| 32 super.syncFields(source); |
| 33 } |
| 34 |
| 28 UINode buildContent() { | 35 UINode buildContent() { |
| 29 // TODO(jackson): This should change colors with the theme | 36 // TODO(jackson): This should change colors with the theme |
| 30 Color color = highlight ? colors.Purple[500] : const Color(0x8A000000); | 37 Color color = highlight ? colors.Purple[500] : const Color(0x8A000000); |
| 31 const double diameter = 16.0; | 38 const double diameter = 16.0; |
| 32 const double outerRadius = diameter / 2; | 39 const double outerRadius = diameter / 2; |
| 33 const double innerRadius = 5.0; | 40 const double innerRadius = 5.0; |
| 34 return new EventListenerNode( | 41 return new EventListenerNode( |
| 35 new Container( | 42 new Container( |
| 36 margin: const EdgeDims.symmetric(horizontal: 5.0), | 43 margin: const EdgeDims.symmetric(horizontal: 5.0), |
| 37 width: diameter, | 44 width: diameter, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 56 ), | 63 ), |
| 57 onGestureTap: _handleClick | 64 onGestureTap: _handleClick |
| 58 ); | 65 ); |
| 59 } | 66 } |
| 60 | 67 |
| 61 void _handleClick(_) { | 68 void _handleClick(_) { |
| 62 onChanged(value); | 69 onChanged(value); |
| 63 } | 70 } |
| 64 | 71 |
| 65 } | 72 } |
| OLD | NEW |