| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 import '../fn.dart'; | |
| 6 import 'button_base.dart'; | |
| 7 import 'ink_well.dart'; | |
| 8 | |
| 9 typedef void ValueChanged(value); | |
| 10 | |
| 11 class Radio extends ButtonBase { | |
| 12 Object value; | |
| 13 Object groupValue; | |
| 14 ValueChanged onChanged; | |
| 15 | |
| 16 static final Style _style = new Style(''' | |
| 17 width: 14px; | |
| 18 height: 14px; | |
| 19 border-radius: 7px; | |
| 20 border: 1px solid blue; | |
| 21 margin: 0 5px;''' | |
| 22 ); | |
| 23 | |
| 24 static final Style _highlightStyle = new Style(''' | |
| 25 width: 14px; | |
| 26 height: 14px; | |
| 27 border-radius: 7px; | |
| 28 border: 1px solid blue; | |
| 29 margin: 0 5px; | |
| 30 background-color: orange;''' | |
| 31 ); | |
| 32 | |
| 33 static final Style _dotStyle = new Style(''' | |
| 34 width: 10px; | |
| 35 height: 10px; | |
| 36 border-radius: 5px; | |
| 37 background-color: black; | |
| 38 margin: 2px;''' | |
| 39 ); | |
| 40 | |
| 41 Radio({ | |
| 42 Object key, | |
| 43 this.onChanged, | |
| 44 this.value, | |
| 45 this.groupValue | |
| 46 }) : super(key: key); | |
| 47 | |
| 48 UINode buildContent() { | |
| 49 return new EventListenerNode( | |
| 50 new StyleNode( | |
| 51 new InkWell( | |
| 52 children: value == groupValue ? [new Container(style: _dotStyle)] : [] | |
| 53 ), | |
| 54 highlight ? _highlightStyle : _style | |
| 55 ), | |
| 56 onGestureTap: _handleClick | |
| 57 ); | |
| 58 } | |
| 59 | |
| 60 void _handleClick(_) { | |
| 61 onChanged(value); | |
| 62 } | |
| 63 } | |
| OLD | NEW |