From 95d090bc5ac60e45bcf5705c01cc8f8756c7bcbe Mon Sep 17 00:00:00 2001 From: Hixie Date: Wed, 17 Jun 2015 15:10:42 -0700 Subject: [PATCH] Make the popup menu work again. This removes the requirement that things with the same type things have unique keys. Now, anything without a key is assumed to be interchangeable. R=abarth@chromium.org Review URL: https://codereview.chromium.org/1178723010. --- examples/stocks2/lib/stock_home.dart | 14 ++++-------- examples/stocks2/lib/stock_row.dart | 29 ++++++++++++++++-------- examples/stocks2/lib/stock_settings.dart | 3 +-- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/examples/stocks2/lib/stock_home.dart b/examples/stocks2/lib/stock_home.dart index e7b58d979a9..c7f2ba8001c 100644 --- a/examples/stocks2/lib/stock_home.dart +++ b/examples/stocks2/lib/stock_home.dart @@ -114,38 +114,32 @@ class StockHome extends Component { children: [ new DrawerHeader(children: [new Text('Stocks')]), new MenuItem( - key: 'Stock list', icon: 'action/assessment', children: [new Text('Stock List')]), new MenuItem( - key: 'Account Balance', icon: 'action/account_balance', children: [new Text('Account Balance')]), - new MenuDivider(key: 'div1'), + new MenuDivider(), new MenuItem( - key: 'Optimistic Menu Item', icon: 'action/thumb_up', onGestureTap: (event) => _handleStockModeChange(StockMode.optimistic), children: [ new Flexible(child: new Text('Optimistic')), - new Radio(key: 'optimistic-radio', value: StockMode.optimistic, groupValue: _stockMode, onChanged: _handleStockModeChange) + new Radio(value: StockMode.optimistic, groupValue: _stockMode, onChanged: _handleStockModeChange) ]), new MenuItem( - key: 'Pessimistic Menu Item', icon: 'action/thumb_down', onGestureTap: (event) => _handleStockModeChange(StockMode.pessimistic), children: [ new Flexible(child: new Text('Pessimistic')), - new Radio(key: 'pessimistic-radio', value: StockMode.pessimistic, groupValue: _stockMode, onChanged: _handleStockModeChange) + new Radio(value: StockMode.pessimistic, groupValue: _stockMode, onChanged: _handleStockModeChange) ]), - new MenuDivider(key: 'div2'), + new MenuDivider(), new MenuItem( - key: 'Settings', icon: 'action/settings', onGestureTap: (event) => _navigator.pushNamed('/settings'), children: [new Text('Settings')]), new MenuItem( - key: 'Help & Feedback', icon: 'action/help', children: [new Text('Help & Feedback')]) ] diff --git a/examples/stocks2/lib/stock_row.dart b/examples/stocks2/lib/stock_row.dart index 7e3ee7d163b..bd48c5f72b3 100644 --- a/examples/stocks2/lib/stock_row.dart +++ b/examples/stocks2/lib/stock_row.dart @@ -27,16 +27,25 @@ class StockRow extends Component { List children = [ new Container( - child: new StockArrow(percentChange: stock.percentChange), - margin: const EdgeDims.only(right: 5.0)), - new Flexible(child: new Text(stock.symbol), flex: 2, key: "symbol"), - // TODO(hansmuller): text-align: right - new Flexible(child: new Text(lastSale, - style: const TextStyle(textAlign: TextAlign.right)), - key: "lastSale"), - new Flexible(child: new Text(changeInPrice, - style: typography.black.caption.copyWith(textAlign: TextAlign.right)), - key: "changeInPrice") + child: new StockArrow(percentChange: stock.percentChange), + margin: const EdgeDims.only(right: 5.0) + ), + new Flexible( + child: new Text(stock.symbol), + flex: 2 + ), + new Flexible( + child: new Text( + lastSale, + style: const TextStyle(textAlign: TextAlign.right) + ) + ), + new Flexible( + child: new Text( + changeInPrice, + style: typography.black.caption.copyWith(textAlign: TextAlign.right) + ) + ) ]; // TODO(hansmuller): An explicit |height| shouldn't be needed diff --git a/examples/stocks2/lib/stock_settings.dart b/examples/stocks2/lib/stock_settings.dart index 1fdfdf8d246..3ca3aef5f38 100644 --- a/examples/stocks2/lib/stock_settings.dart +++ b/examples/stocks2/lib/stock_settings.dart @@ -41,12 +41,11 @@ class StockSettings extends Component { decoration: new BoxDecoration(backgroundColor: colors.Grey[50]), child: new Block([ new MenuItem( - key: 'Optimistic Setting', icon: 'action/thumb_up', onGestureTap: (event) => _handleAwesomeChanged(!_awesome), children: [ new Flexible(child: new Text('Everything is awesome')), - new Checkbox(key: 'awesome', value: _awesome, onChanged: _handleAwesomeChanged) + new Checkbox(value: _awesome, onChanged: _handleAwesomeChanged) ] ), ])