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 transform: translateX(0); |
10 display: flex; | 10 display: flex; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 border-right-width: 2px; | 50 border-right-width: 2px; |
51 border-bottom-width: 2px; | 51 border-bottom-width: 2px; |
52 border-color: #0f9d58;''' | 52 border-color: #0f9d58;''' |
53 ); | 53 ); |
54 | 54 |
55 Checkbox({ Object key, this.onChanged, this.checked }) : super(key: key); | 55 Checkbox({ Object key, this.onChanged, this.checked }) : super(key: key); |
56 | 56 |
57 Node render() { | 57 Node render() { |
58 return new Container( | 58 return new Container( |
59 style: _style, | 59 style: _style, |
60 onClick: _handleClick, | |
61 onPointerDown: _handlePointerDown, | |
62 onPointerUp: _handlePointerUp, | |
63 onPointerCancel: _handlePointerCancel, | |
64 children: [ | 60 children: [ |
65 super.render(), | 61 super.render(), |
66 new Container( | 62 new Container( |
67 style: _highlight ? _containerHighlightStyle : _containerStyle, | 63 style: _highlight ? _containerHighlightStyle : _containerStyle, |
68 children: [ | 64 children: [ |
69 new Container( | 65 new Container( |
70 style: checked ? _checkedStyle : _uncheckedStyle | 66 style: checked ? _checkedStyle : _uncheckedStyle |
71 ) | 67 ) |
72 ] | 68 ] |
73 ) | 69 ) |
74 ] | 70 ] |
75 ); | 71 )..events.listen('click', _handleClick); |
76 } | 72 } |
77 | 73 |
78 void _handleClick(sky.Event e) { | 74 void _handleClick(sky.Event e) { |
79 onChanged(!checked); | 75 onChanged(!checked); |
80 } | 76 } |
81 } | 77 } |
OLD | NEW |