OLD | NEW |
1 part of widgets; | 1 part of widgets; |
2 | 2 |
3 class Checkbox extends ButtonBase { | 3 class Checkbox extends ButtonBase { |
4 | 4 |
5 bool checked; | 5 bool checked; |
6 ValueChanged onChanged; | 6 ValueChanged onChanged; |
7 | 7 |
8 static Style _style = new Style(''' | 8 static Style _style = new Style(''' |
| 9 transform: translateX(0); |
9 display: flex; | 10 display: flex; |
10 justify-content: center; | 11 justify-content: center; |
11 align-items: center; | 12 align-items: center; |
12 -webkit-user-select: none; | 13 -webkit-user-select: none; |
13 cursor: pointer; | 14 cursor: pointer; |
14 width: 30px; | 15 width: 30px; |
15 height: 30px;''' | 16 height: 30px;''' |
16 ); | 17 ); |
17 | 18 |
18 static Style _containerStyle = new Style(''' | 19 static Style _containerStyle = new Style(''' |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 Checkbox({ Object key, this.onChanged, this.checked }) : super(key: key); | 55 Checkbox({ Object key, this.onChanged, this.checked }) : super(key: key); |
55 | 56 |
56 Node render() { | 57 Node render() { |
57 return new Container( | 58 return new Container( |
58 style: _style, | 59 style: _style, |
59 onClick: _handleClick, | 60 onClick: _handleClick, |
60 onPointerDown: _handlePointerDown, | 61 onPointerDown: _handlePointerDown, |
61 onPointerUp: _handlePointerUp, | 62 onPointerUp: _handlePointerUp, |
62 onPointerCancel: _handlePointerCancel, | 63 onPointerCancel: _handlePointerCancel, |
63 children: [ | 64 children: [ |
| 65 super.render(), |
64 new Container( | 66 new Container( |
65 style: _highlight ? _containerHighlightStyle : _containerStyle, | 67 style: _highlight ? _containerHighlightStyle : _containerStyle, |
66 children: [ | 68 children: [ |
67 new Container( | 69 new Container( |
68 style: checked ? _checkedStyle : _uncheckedStyle | 70 style: checked ? _checkedStyle : _uncheckedStyle |
69 ) | 71 ) |
70 ] | 72 ] |
71 ) | 73 ) |
72 ] | 74 ] |
73 ); | 75 ); |
74 } | 76 } |
75 | 77 |
76 void _handleClick(sky.Event e) { | 78 void _handleClick(sky.Event e) { |
77 onChanged(!checked); | 79 onChanged(!checked); |
78 } | 80 } |
79 } | 81 } |
OLD | NEW |