Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:sky/editing/input.dart'; | 5 import 'package:sky/editing/input.dart'; |
| 6 import 'package:sky/animation/animation_performance.dart'; | 6 import 'package:sky/animation/animation_performance.dart'; |
| 7 import 'package:sky/widgets/animated_component.dart'; | 7 import 'package:sky/widgets/animated_component.dart'; |
| 8 import 'package:sky/widgets/animation_builder.dart'; | 8 import 'package:sky/widgets/animation_builder.dart'; |
| 9 import 'package:sky/theme/colors.dart' as colors; | 9 import 'package:sky/theme/colors.dart' as colors; |
| 10 import 'package:sky/widgets/basic.dart'; | 10 import 'package:sky/widgets/basic.dart'; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 import 'stock_list.dart'; | 30 import 'stock_list.dart'; |
| 31 import 'stock_menu.dart'; | 31 import 'stock_menu.dart'; |
| 32 import 'stock_types.dart'; | 32 import 'stock_types.dart'; |
| 33 | 33 |
| 34 typedef void ModeUpdater(StockMode mode); | 34 typedef void ModeUpdater(StockMode mode); |
| 35 | 35 |
| 36 const Duration _kSnackbarSlideDuration = const Duration(milliseconds: 200); | 36 const Duration _kSnackbarSlideDuration = const Duration(milliseconds: 200); |
| 37 | 37 |
| 38 class StockHome extends AnimatedComponent { | 38 class StockHome extends AnimatedComponent { |
| 39 | 39 |
| 40 StockHome(this.navigator, this.stocks, this.stockMode, this.modeUpdater) { | 40 StockHome(this.navigator, this.stocks, this.stockMode, this.modeUpdater); |
| 41 // if (debug) | |
| 42 // new Timer(new Duration(seconds: 1), dumpState); | |
| 43 _drawerController = new DrawerController(_handleDrawerStatusChanged); | |
| 44 } | |
| 45 | 41 |
| 46 Navigator navigator; | 42 Navigator navigator; |
| 47 List<Stock> stocks; | 43 List<Stock> stocks; |
| 48 StockMode stockMode; | 44 StockMode stockMode; |
| 49 ModeUpdater modeUpdater; | 45 ModeUpdater modeUpdater; |
| 50 | 46 |
| 51 void syncFields(StockHome source) { | 47 void syncFields(StockHome source) { |
| 52 navigator = source.navigator; | 48 navigator = source.navigator; |
| 53 stocks = source.stocks; | 49 stocks = source.stocks; |
| 54 stockMode = source.stockMode; | 50 stockMode = source.stockMode; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 81 _searchQuery = null; | 77 _searchQuery = null; |
| 82 }); | 78 }); |
| 83 } | 79 } |
| 84 | 80 |
| 85 void _handleSearchQueryChanged(String query) { | 81 void _handleSearchQueryChanged(String query) { |
| 86 setState(() { | 82 setState(() { |
| 87 _searchQuery = query; | 83 _searchQuery = query; |
| 88 }); | 84 }); |
| 89 } | 85 } |
| 90 | 86 |
| 91 DrawerController _drawerController; | |
| 92 bool _drawerShowing = false; | 87 bool _drawerShowing = false; |
| 93 | 88 |
| 94 void _handleDrawerStatusChanged(bool showing) { | |
| 95 if (!showing && navigator.currentRoute.name == "/drawer") { | |
| 96 navigator.pop(); | |
| 97 } | |
| 98 setState(() { | |
| 99 _drawerShowing = showing; | |
| 100 }); | |
| 101 } | |
| 102 | |
| 103 PopupMenuController _menuController; | 89 PopupMenuController _menuController; |
| 104 | 90 |
| 105 void _handleMenuShow() { | 91 void _handleMenuShow() { |
| 106 setState(() { | 92 setState(() { |
| 107 _menuController = new PopupMenuController(); | 93 _menuController = new PopupMenuController(); |
| 108 _menuController.open(); | 94 _menuController.open(); |
| 109 }); | 95 }); |
| 110 } | 96 } |
| 111 | 97 |
| 112 void _handleMenuHide() { | 98 void _handleMenuHide() { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 129 void _handleStockModeChange(StockMode value) { | 115 void _handleStockModeChange(StockMode value) { |
| 130 setState(() { | 116 setState(() { |
| 131 stockMode = value; | 117 stockMode = value; |
| 132 }); | 118 }); |
| 133 if (modeUpdater != null) | 119 if (modeUpdater != null) |
| 134 modeUpdater(value); | 120 modeUpdater(value); |
| 135 } | 121 } |
| 136 | 122 |
| 137 Drawer buildDrawer() { | 123 Drawer buildDrawer() { |
| 138 return new Drawer( | 124 return new Drawer( |
| 139 controller: _drawerController, | |
| 140 level: 3, | 125 level: 3, |
| 126 showing: _drawerShowing, | |
| 127 onStatusChange: _handleDrawerStatusChange, | |
| 128 navigator: navigator, | |
| 141 children: [ | 129 children: [ |
| 142 new DrawerHeader(children: [new Text('Stocks')]), | 130 new DrawerHeader(children: [new Text('Stocks')]), |
| 143 new MenuItem( | 131 new MenuItem( |
| 144 icon: 'action/assessment', | 132 icon: 'action/assessment', |
| 145 selected: true, | 133 selected: true, |
| 146 children: [new Text('Stock List')]), | 134 children: [new Text('Stock List')]), |
| 147 new MenuItem( | 135 new MenuItem( |
| 148 icon: 'action/account_balance', | 136 icon: 'action/account_balance', |
| 149 children: [new Text('Account Balance')]), | 137 children: [new Text('Account Balance')]), |
| 150 new MenuDivider(), | 138 new MenuDivider(), |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 167 icon: 'action/settings', | 155 icon: 'action/settings', |
| 168 onPressed: _handleShowSettings, | 156 onPressed: _handleShowSettings, |
| 169 children: [new Text('Settings')]), | 157 children: [new Text('Settings')]), |
| 170 new MenuItem( | 158 new MenuItem( |
| 171 icon: 'action/help', | 159 icon: 'action/help', |
| 172 children: [new Text('Help & Feedback')]) | 160 children: [new Text('Help & Feedback')]) |
| 173 ] | 161 ] |
| 174 ); | 162 ); |
| 175 } | 163 } |
| 176 | 164 |
| 165 void _handleDrawerStatusChange(bool showing) { | |
| 166 setState(() { | |
| 167 _drawerShowing = showing; | |
| 168 }); | |
| 169 } | |
| 170 | |
| 177 void _handleShowSettings() { | 171 void _handleShowSettings() { |
| 178 assert(navigator.currentRoute.name == '/drawer'); | |
| 179 navigator.pop(); | 172 navigator.pop(); |
| 180 assert(navigator.currentRoute.name == '/'); | |
| 181 navigator.pushNamed('/settings'); | 173 navigator.pushNamed('/settings'); |
| 182 } | 174 } |
| 183 | 175 |
| 184 void _handleOpenDrawer() { | 176 void _handleOpenDrawer() { |
| 185 _drawerController.open(); | 177 setState(() { |
| 186 navigator.pushState("/drawer", (_) { | 178 _drawerShowing = true; |
| 187 _drawerController.close(); | |
| 188 }); | 179 }); |
| 189 } | 180 } |
| 190 | 181 |
| 191 Widget buildToolBar() { | 182 Widget buildToolBar() { |
| 192 return new ToolBar( | 183 return new ToolBar( |
| 193 left: new IconButton( | 184 left: new IconButton( |
| 194 icon: "navigation/menu", | 185 icon: "navigation/menu", |
| 195 onPressed: _handleOpenDrawer), | 186 onPressed: _handleOpenDrawer), |
| 196 center: new Text('Stocks'), | 187 center: new Text('Stocks'), |
| 197 right: [ | 188 right: [ |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 onDismiss: _handleMenuHide)); | 305 onDismiss: _handleMenuHide)); |
| 315 } | 306 } |
| 316 | 307 |
| 317 Widget build() { | 308 Widget build() { |
| 318 List<Widget> overlays = [ | 309 List<Widget> overlays = [ |
| 319 new Scaffold( | 310 new Scaffold( |
| 320 toolbar: _isSearching ? buildSearchBar() : buildToolBar(), | 311 toolbar: _isSearching ? buildSearchBar() : buildToolBar(), |
| 321 body: buildTabNavigator(), | 312 body: buildTabNavigator(), |
| 322 snackBar: buildSnackBar(), | 313 snackBar: buildSnackBar(), |
| 323 floatingActionButton: buildFloatingActionButton(), | 314 floatingActionButton: buildFloatingActionButton(), |
| 324 drawer: _drawerShowing ? buildDrawer() : null | 315 drawer: buildDrawer() |
|
abarth-chromium
2015/07/14 16:55:10
You're building the drawer unconditionally.... It
| |
| 325 ), | 316 ), |
| 326 ]; | 317 ]; |
| 327 addMenuToOverlays(overlays); | 318 addMenuToOverlays(overlays); |
| 328 return new Stack(overlays); | 319 return new Stack(overlays); |
| 329 } | 320 } |
| 330 } | 321 } |
| OLD | NEW |