| 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 '../fn.dart'; | 5 import '../fn.dart'; |
| 6 import 'button_base.dart'; | 6 import 'button_base.dart'; |
| 7 import 'material.dart'; |
| 7 | 8 |
| 8 typedef void ValueChanged(value); | 9 typedef void ValueChanged(value); |
| 9 | 10 |
| 10 class Radio extends ButtonBase { | 11 class Radio extends ButtonBase { |
| 11 Object value; | 12 Object value; |
| 12 Object groupValue; | 13 Object groupValue; |
| 13 ValueChanged onChanged; | 14 ValueChanged onChanged; |
| 14 | 15 |
| 15 static final Style _style = new Style(''' | 16 static final Style _style = new Style(''' |
| 16 transform: translateX(0); | 17 transform: translateX(0); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 47 Radio({ | 48 Radio({ |
| 48 Object key, | 49 Object key, |
| 49 this.onChanged, | 50 this.onChanged, |
| 50 this.value, | 51 this.value, |
| 51 this.groupValue | 52 this.groupValue |
| 52 }) : super(key: key) { | 53 }) : super(key: key) { |
| 53 events.listen('click', _handleClick); | 54 events.listen('click', _handleClick); |
| 54 } | 55 } |
| 55 | 56 |
| 56 Node build() { | 57 Node build() { |
| 57 return new Container( | 58 return new Material( |
| 58 style: highlight ? _highlightStyle : _style, | 59 style: highlight ? _highlightStyle : _style, |
| 59 children: value == groupValue ? | 60 children: value == groupValue ? [new Container( style : _dotStyle )] : [] |
| 60 [super.build(), new Container( style : _dotStyle )] : [super.build()] | |
| 61 ) | 61 ) |
| 62 } | 62 } |
| 63 | 63 |
| 64 void _handleClick(_) { | 64 void _handleClick(_) { |
| 65 onChanged(value); | 65 onChanged(value); |
| 66 } | 66 } |
| 67 } | 67 } |
| OLD | NEW |