| 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 'dart:sky' as sky; | 5 import 'dart:sky' as sky; |
| 6 | 6 |
| 7 import '../rendering/object.dart'; | 7 import '../rendering/object.dart'; |
| 8 import 'basic.dart'; | 8 import 'basic.dart'; |
| 9 import 'button_base.dart'; | 9 import 'button_base.dart'; |
| 10 import 'theme.dart'; | 10 import 'theme.dart'; |
| 11 | 11 |
| 12 const sky.Color _kLightOffColor = const sky.Color(0x8A000000); | 12 const sky.Color _kLightOffColor = const sky.Color(0x8A000000); |
| 13 const sky.Color _kDarkOffColor = const sky.Color(0xB2FFFFFF); | 13 const sky.Color _kDarkOffColor = const sky.Color(0xB2FFFFFF); |
| 14 | 14 |
| 15 typedef void ValueChanged(value); | 15 typedef void ValueChanged(value); |
| 16 | 16 |
| 17 class Radio extends ButtonBase { | 17 class Radio extends ButtonBase { |
| 18 | 18 |
| 19 Radio({ | 19 Radio({ |
| 20 String key, | 20 String key, |
| 21 this.value, | 21 this.value, |
| 22 this.groupValue, | 22 this.groupValue, |
| 23 this.onChanged | 23 this.onChanged |
| 24 }) : super(key: key); | 24 }) : super(key: key); |
| 25 | 25 |
| 26 Object value; | 26 Object value; |
| 27 Object groupValue; | 27 Object groupValue; |
| 28 ValueChanged onChanged; | 28 ValueChanged onChanged; |
| 29 | 29 |
| 30 @override |
| 30 void syncFields(Radio source) { | 31 void syncFields(Radio source) { |
| 31 value = source.value; | 32 value = source.value; |
| 32 groupValue = source.groupValue; | 33 groupValue = source.groupValue; |
| 33 onChanged = source.onChanged; | 34 onChanged = source.onChanged; |
| 34 super.syncFields(source); | 35 super.syncFields(source); |
| 35 } | 36 } |
| 36 | 37 |
| 37 Color get color { | 38 Color get color { |
| 38 ThemeData themeData = Theme.of(this); | 39 ThemeData themeData = Theme.of(this); |
| 39 if (value == groupValue) | 40 if (value == groupValue) |
| 40 return themeData.accentColor; | 41 return themeData.accentColor; |
| 41 return themeData.brightness == ThemeBrightness.light ? _kLightOffColor : _kD
arkOffColor; | 42 return themeData.brightness == ThemeBrightness.light ? _kLightOffColor : _kD
arkOffColor; |
| 42 } | 43 } |
| 43 | 44 |
| 45 @override |
| 44 Widget buildContent() { | 46 Widget buildContent() { |
| 45 const double kDiameter = 16.0; | 47 const double kDiameter = 16.0; |
| 46 const double kOuterRadius = kDiameter / 2; | 48 const double kOuterRadius = kDiameter / 2; |
| 47 const double kInnerRadius = 5.0; | 49 const double kInnerRadius = 5.0; |
| 48 return new Listener( | 50 return new Listener( |
| 49 child: new Container( | 51 child: new Container( |
| 50 margin: const EdgeDims.symmetric(horizontal: 5.0), | 52 margin: const EdgeDims.symmetric(horizontal: 5.0), |
| 51 width: kDiameter, | 53 width: kDiameter, |
| 52 height: kDiameter, | 54 height: kDiameter, |
| 53 child: new CustomPaint( | 55 child: new CustomPaint( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 ), | 72 ), |
| 71 onGestureTap: _handleClick | 73 onGestureTap: _handleClick |
| 72 ); | 74 ); |
| 73 } | 75 } |
| 74 | 76 |
| 75 void _handleClick(_) { | 77 void _handleClick(_) { |
| 76 onChanged(value); | 78 onChanged(value); |
| 77 } | 79 } |
| 78 | 80 |
| 79 } | 81 } |
| OLD | NEW |