Rename EventListenerNode to Listener

The basic widgets are going to be used many, many times, so we want them to
have short, snappy names.

Also, give the Widget argument to Listener the name |child| for consistency.

TBR=ianh@google.com

Review URL: https://codereview.chromium.org/1193513007.
This commit is contained in:
Adam Barth 2015-06-17 07:39:24 -07:00
parent bc68bc5729
commit bc829ea123
13 changed files with 33 additions and 29 deletions

View File

@ -86,11 +86,11 @@ class Input extends Component {
children.add(new EditableText(value: _editableValue, focused: focused));
return new EventListenerNode(
return new Listener(
// style: _style,
// inlineStyle: focused ? _focusedInlineStyle : null,
new Stack(children),
onPointerDown: (sky.Event e) => keyboard.showByRequest()
child: new Stack(children),
onPointerDown: (_) => keyboard.showByRequest()
);
}

View File

@ -15,7 +15,7 @@ import 'widget.dart';
export '../rendering/box.dart' show BoxConstraints, BoxDecoration, Border, BorderSide, EdgeDims;
export '../rendering/flex.dart' show FlexDirection, FlexJustifyContent, FlexAlignItems;
export '../rendering/object.dart' show Point, Size, Rect, Color, Paint, Path;
export 'widget.dart' show Widget, Component, App, EventListenerNode, ParentDataNode;
export 'widget.dart' show Widget, Component, App, Listener, ParentDataNode;
// PAINTING NODES

View File

@ -31,8 +31,8 @@ abstract class ButtonBase extends Component {
}
Widget build() {
return new EventListenerNode(
buildContent(),
return new Listener(
child: buildContent(),
onPointerDown: _handlePointerDown,
onPointerUp: _handlePointerUp,
onPointerCancel: _handlePointerCancel

View File

@ -36,7 +36,10 @@ class Dialog extends Component {
children.add(content);
return new Stack([
new EventListenerNode(mask, onGestureTap: (_) => onDismiss()),
new Listener(
child: mask,
onGestureTap: (_) => onDismiss()
),
new Center(
child: new ConstrainedBox(
constraints: new BoxConstraints(minWidth: 280.0),

View File

@ -139,8 +139,8 @@ class Drawer extends AnimatedComponent {
double scaler = _position / _kWidth + 1;
Color maskColor = new Color.fromARGB((0x7F * scaler).floor(), 0, 0, 0);
var mask = new EventListenerNode(
new Container(decoration: new BoxDecoration(backgroundColor: maskColor)),
var mask = new Listener(
child: new Container(decoration: new BoxDecoration(backgroundColor: maskColor)),
onGestureTap: controller.handleMaskTap,
onGestureFlingStart: controller.handleFlingStart
);
@ -154,8 +154,8 @@ class Drawer extends AnimatedComponent {
child: new Block(children)
);
return new EventListenerNode(
new Stack([ mask, content ]),
return new Listener(
child: new Stack([ mask, content ]),
onPointerDown: controller.handlePointerDown,
onPointerMove: controller.handlePointerMove,
onPointerUp: controller.handlePointerUp,

View File

@ -16,8 +16,8 @@ class IconButton extends Component {
final GestureEventListener onGestureTap;
Widget build() {
return new EventListenerNode(
new Padding(
return new Listener(
child: new Padding(
child: new Icon(type: icon, size: 24),
padding: const EdgeDims.all(8.0)),
onGestureTap: onGestureTap);

View File

@ -41,8 +41,8 @@ abstract class MaterialButton extends ButtonBase {
padding: new EdgeDims.symmetric(horizontal: 8.0),
child: new Center(child: child) // TODO(ianh): figure out a way to compell the child to have gray text when disabled...
);
return new EventListenerNode(
new Container(
return new Listener(
child: new Container(
height: 36.0,
constraints: new BoxConstraints(minWidth: 88.0),
margin: new EdgeDims.all(8.0),

View File

@ -38,8 +38,8 @@ class MenuItem extends ButtonBase {
}
Widget buildContent() {
return new EventListenerNode(
new Container(
return new Listener(
child: new Container(
child: new InkWell(
child: new Flex([
new Padding(

View File

@ -20,8 +20,8 @@ class ModalOverlay extends Component {
final GestureEventListener onDismiss;
Widget build() {
return new EventListenerNode(
new Stack(children),
return new Listener(
child: new Stack(children),
onGestureTap: onDismiss);
}

View File

@ -37,8 +37,8 @@ class Radio extends ButtonBase {
const double kDiameter = 16.0;
const double kOuterRadius = kDiameter / 2;
const double kInnerRadius = 5.0;
return new EventListenerNode(
new Container(
return new Listener(
child: new Container(
margin: const EdgeDims.symmetric(horizontal: 5.0),
width: kDiameter,
height: kDiameter,

View File

@ -51,8 +51,8 @@ abstract class Scrollable extends Component {
Widget buildContent();
Widget build() {
return new EventListenerNode(
new Material(
return new Listener(
child: new Material(
child: buildContent(),
edge: MaterialEdge.canvas,
color: backgroundColor

View File

@ -58,8 +58,8 @@ abstract class Toggleable extends AnimatedComponent {
Curve get curveDown => easeOut;
Widget build() {
return new EventListenerNode(
new Container(
return new Listener(
child: new Container(
margin: margin,
width: size.width,
height: size.height,

View File

@ -187,9 +187,10 @@ typedef void GestureEventListener(sky.GestureEvent e);
typedef void PointerEventListener(sky.PointerEvent e);
typedef void EventListener(sky.Event e);
class EventListenerNode extends TagNode {
class Listener extends TagNode {
EventListenerNode(Widget content, {
Listener({
Widget child,
EventListener onWheel,
GestureEventListener onGestureFlingCancel,
GestureEventListener onGestureFlingStart,
@ -216,7 +217,7 @@ class EventListenerNode extends TagNode {
onPointerUp: onPointerUp,
custom: custom
),
super(content);
super(child);
final Map<String, sky.EventListener> listeners;
@ -757,7 +758,7 @@ class WidgetAppView extends AppView {
continue;
RenderObject targetRoot = target.root;
while (target != null && target.root == targetRoot) {
if (target is EventListenerNode)
if (target is EventListener)
target._handleEvent(event);
target = target._parent;
}