From fc5d7261eca96be27d16a75ddbf75badf5066094 Mon Sep 17 00:00:00 2001 From: Hixie Date: Tue, 16 Jun 2015 09:41:05 -0700 Subject: [PATCH] Make PopupMenuItem take a single child instead of an implicitly-flex list of children. TBR=abarth Review URL: https://codereview.chromium.org/1187463013. --- examples/stocks2/lib/stock_menu.dart | 6 +++--- sdk/lib/widgets/popup_menu.dart | 9 ++++----- sdk/lib/widgets/popup_menu_item.dart | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/stocks2/lib/stock_menu.dart b/examples/stocks2/lib/stock_menu.dart index bbf55f89c8d..2b9df0b8940 100644 --- a/examples/stocks2/lib/stock_menu.dart +++ b/examples/stocks2/lib/stock_menu.dart @@ -30,9 +30,9 @@ class StockMenu extends Component { child: new PopupMenu( controller: controller, items: [ - [new Text('Add stock')], - [new Text('Remove stock')], - [new Flexible(child: new Text('Autorefresh')), checkbox], + new Text('Add stock'), + new Text('Remove stock'), + new Flex([new Flexible(child: new Text('Autorefresh')), checkbox]), ], level: 4 ), diff --git a/sdk/lib/widgets/popup_menu.dart b/sdk/lib/widgets/popup_menu.dart index 8cb13d30c54..27a22bc7988 100644 --- a/sdk/lib/widgets/popup_menu.dart +++ b/sdk/lib/widgets/popup_menu.dart @@ -67,7 +67,7 @@ class PopupMenu extends AnimatedComponent { } PopupMenuController controller; - List> items; + List items; int level; void syncFields(PopupMenu source) { @@ -92,11 +92,10 @@ class PopupMenu extends AnimatedComponent { UINode build() { int i = 0; - List children = new List.from(items.map((List item) { + List children = new List.from(items.map((UINode item) { double opacity = _opacityFor(i); - // TODO(abarth): Using |i| for the key here seems wrong. - return new PopupMenuItem(key: (i++).toString(), - children: item + return new PopupMenuItem(key: '${key}-${item.key}', + child: item, opacity: opacity); })); diff --git a/sdk/lib/widgets/popup_menu_item.dart b/sdk/lib/widgets/popup_menu_item.dart index 9c2e8889809..d91e01a9c36 100644 --- a/sdk/lib/widgets/popup_menu_item.dart +++ b/sdk/lib/widgets/popup_menu_item.dart @@ -6,9 +6,9 @@ import 'basic.dart'; import 'ink_well.dart'; class PopupMenuItem extends Component { - PopupMenuItem({ String key, this.children, this.opacity}) : super(key: key); + PopupMenuItem({ String key, this.child, this.opacity}) : super(key: key); - final List children; + final UINode child; final double opacity; UINode build() { @@ -18,7 +18,7 @@ class PopupMenuItem extends Component { child: new Container( constraints: const BoxConstraints(minWidth: 112.0), padding: const EdgeDims.all(16.0), - child: new Flex(children) + child: child ) ) );