Chromium Code Reviews| Index: sky/sdk/example/stocks/lib/stock_home.dart |
| diff --git a/sky/sdk/example/stocks/lib/stock_home.dart b/sky/sdk/example/stocks/lib/stock_home.dart |
| index 7d5679cea8fbca6d43168607680afa52c19f1be2..0d11c3e0c85d338b0efa5d521242575cdd1569f1 100644 |
| --- a/sky/sdk/example/stocks/lib/stock_home.dart |
| +++ b/sky/sdk/example/stocks/lib/stock_home.dart |
| @@ -37,11 +37,7 @@ const Duration _kSnackbarSlideDuration = const Duration(milliseconds: 200); |
| class StockHome extends AnimatedComponent { |
| - StockHome(this.navigator, this.stocks, this.stockMode, this.modeUpdater) { |
| - // if (debug) |
| - // new Timer(new Duration(seconds: 1), dumpState); |
| - _drawerController = new DrawerController(_handleDrawerStatusChanged); |
| - } |
| + StockHome(this.navigator, this.stocks, this.stockMode, this.modeUpdater); |
| Navigator navigator; |
| List<Stock> stocks; |
| @@ -88,18 +84,8 @@ class StockHome extends AnimatedComponent { |
| }); |
| } |
| - DrawerController _drawerController; |
| bool _drawerShowing = false; |
| - void _handleDrawerStatusChanged(bool showing) { |
| - if (!showing && navigator.currentRoute.name == "/drawer") { |
| - navigator.pop(); |
| - } |
| - setState(() { |
| - _drawerShowing = showing; |
| - }); |
| - } |
| - |
| PopupMenuController _menuController; |
| void _handleMenuShow() { |
| @@ -136,8 +122,10 @@ class StockHome extends AnimatedComponent { |
| Drawer buildDrawer() { |
| return new Drawer( |
| - controller: _drawerController, |
| level: 3, |
| + showing: _drawerShowing, |
| + onStatusChange: _handleDrawerStatusChange, |
| + navigator: navigator, |
| children: [ |
| new DrawerHeader(children: [new Text('Stocks')]), |
| new MenuItem( |
| @@ -174,17 +162,20 @@ class StockHome extends AnimatedComponent { |
| ); |
| } |
| + void _handleDrawerStatusChange(bool showing) { |
| + setState(() { |
| + _drawerShowing = showing; |
| + }); |
| + } |
| + |
| void _handleShowSettings() { |
| - assert(navigator.currentRoute.name == '/drawer'); |
| navigator.pop(); |
| - assert(navigator.currentRoute.name == '/'); |
| navigator.pushNamed('/settings'); |
| } |
| void _handleOpenDrawer() { |
| - _drawerController.open(); |
| - navigator.pushState("/drawer", (_) { |
| - _drawerController.close(); |
| + setState(() { |
| + _drawerShowing = true; |
| }); |
| } |
| @@ -321,7 +312,7 @@ class StockHome extends AnimatedComponent { |
| body: buildTabNavigator(), |
| snackBar: buildSnackBar(), |
| floatingActionButton: buildFloatingActionButton(), |
| - drawer: _drawerShowing ? buildDrawer() : null |
|
abarth-chromium
2015/07/14 16:55:10
You're building the drawer unconditionally.... It
|
| + drawer: buildDrawer() |
| ), |
| ]; |
| addMenuToOverlays(overlays); |