
This CL changes how events work in fn. Previously, event listeners were passed in as constructor arguments. Now Nodes hold an |events| object, which contains all the event registrations. When a Component renders, all its |events| are copied onto the Node it produces. When an Element syncs, it walks its |events| and adds them as event listeners on the underlying sky.Element. The net result of this change is increased flexibility in how events are registered. Now components don't need to enumerate all the possible events that they support. Instead, the parent component can listen for whatever events it likes. Also, I've cleaned up the association between DrawerAnimation and Drawer. Now the constructor for Drawer accepts an |animation| object and wires up its internal event handlers itself instead of requiring the constructor to do all the wiring. R=rafaelw@chromium.org Review URL: https://codereview.chromium.org/975863003
60 lines
1.2 KiB
Dart
60 lines
1.2 KiB
Dart
part of widgets;
|
|
|
|
class Radio extends ButtonBase {
|
|
|
|
Object value;
|
|
Object groupValue;
|
|
ValueChanged onChanged;
|
|
|
|
static Style _style = new Style('''
|
|
transform: translateX(0);
|
|
display: inline-block;
|
|
-webkit-user-select: none;
|
|
width: 14px;
|
|
height: 14px;
|
|
border-radius: 7px;
|
|
border: 1px solid blue;
|
|
margin: 0 5px;'''
|
|
);
|
|
|
|
static Style _highlightStyle = new Style('''
|
|
transform: translateX(0);
|
|
display: inline-block;
|
|
-webkit-user-select: none;
|
|
width: 14px;
|
|
height: 14px;
|
|
border-radius: 7px;
|
|
border: 1px solid blue;
|
|
margin: 0 5px;
|
|
background-color: orange;'''
|
|
);
|
|
|
|
static Style _dotStyle = new Style('''
|
|
-webkit-user-select: none;
|
|
width: 10px;
|
|
height: 10px;
|
|
border-radius: 5px;
|
|
background-color: black;
|
|
margin: 2px;'''
|
|
);
|
|
|
|
Radio({
|
|
Object key,
|
|
this.onChanged,
|
|
this.value,
|
|
this.groupValue
|
|
}) : super(key: key);
|
|
|
|
Node render() {
|
|
return new Container(
|
|
style: _highlight ? _highlightStyle : _style,
|
|
children: value == groupValue ?
|
|
[super.render(), new Container( style : _dotStyle )] : [super.render()]
|
|
)..events.listen('click', _handleClick);
|
|
}
|
|
|
|
void _handleClick(_) {
|
|
onChanged(value);
|
|
}
|
|
}
|