OLD | NEW |
| (Empty) |
1 part of widgets; | |
2 | |
3 class Radio extends ButtonBase { | |
4 | |
5 Object value; | |
6 Object groupValue; | |
7 ValueChanged onChanged; | |
8 | |
9 static Style _style = new Style(''' | |
10 transform: translateX(0); | |
11 display: inline-block; | |
12 -webkit-user-select: none; | |
13 width: 14px; | |
14 height: 14px; | |
15 border-radius: 7px; | |
16 border: 1px solid blue; | |
17 margin: 0 5px;''' | |
18 ); | |
19 | |
20 static Style _highlightStyle = new Style(''' | |
21 transform: translateX(0); | |
22 display: inline-block; | |
23 -webkit-user-select: none; | |
24 width: 14px; | |
25 height: 14px; | |
26 border-radius: 7px; | |
27 border: 1px solid blue; | |
28 margin: 0 5px; | |
29 background-color: orange;''' | |
30 ); | |
31 | |
32 static Style _dotStyle = new Style(''' | |
33 -webkit-user-select: none; | |
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 Node build() { | |
49 return new Container( | |
50 style: _highlight ? _highlightStyle : _style, | |
51 children: value == groupValue ? | |
52 [super.build(), new Container( style : _dotStyle )] : [super.build()] | |
53 )..events.listen('click', _handleClick); | |
54 } | |
55 | |
56 void _handleClick(_) { | |
57 onChanged(value); | |
58 } | |
59 } | |
OLD | NEW |