| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 void _handleDrawerStatusChanged(bool showing) { | 94 void _handleDrawerStatusChanged(bool showing) { |
| 95 if (!showing && navigator.currentRoute.name == "/drawer") { | 95 if (!showing && navigator.currentRoute.name == "/drawer") { |
| 96 navigator.pop(); | 96 navigator.pop(); |
| 97 } | 97 } |
| 98 setState(() { | 98 setState(() { |
| 99 _drawerShowing = showing; | 99 _drawerShowing = showing; |
| 100 }); | 100 }); |
| 101 } | 101 } |
| 102 | 102 |
| 103 PopupMenuController _menuController; | 103 bool _menuShowing = false; |
| 104 PopupMenuStatus _menuStatus = PopupMenuStatus.inactive; |
| 104 | 105 |
| 105 void _handleMenuShow() { | 106 void _handleMenuShow() { |
| 106 setState(() { | 107 setState(() { |
| 107 _menuController = new PopupMenuController(); | 108 _menuShowing = true; |
| 108 _menuController.open(); | 109 _menuStatus = PopupMenuStatus.active; |
| 109 }); | 110 }); |
| 110 } | 111 } |
| 111 | 112 |
| 112 void _handleMenuHide() { | 113 void _handleMenuHide() { |
| 113 setState(() { | 114 setState(() { |
| 114 _menuController.close().then((_) { | 115 _menuShowing = false; |
| 115 setState(() { | |
| 116 _menuController = null; | |
| 117 }); | |
| 118 }); | |
| 119 }); | 116 }); |
| 120 } | 117 } |
| 121 | 118 |
| 119 void _handleMenuStatusChanged(PopupMenuStatus status) { |
| 120 setState(() { |
| 121 _menuStatus = status; |
| 122 }); |
| 123 } |
| 124 |
| 122 bool _autorefresh = false; | 125 bool _autorefresh = false; |
| 123 void _handleAutorefreshChanged(bool value) { | 126 void _handleAutorefreshChanged(bool value) { |
| 124 setState(() { | 127 setState(() { |
| 125 _autorefresh = value; | 128 _autorefresh = value; |
| 126 }); | 129 }); |
| 127 } | 130 } |
| 128 | 131 |
| 129 void _handleStockModeChange(StockMode value) { | 132 void _handleStockModeChange(StockMode value) { |
| 130 setState(() { | 133 setState(() { |
| 131 stockMode = value; | 134 stockMode = value; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 child: new Icon(type: 'content/add', size: 24), | 299 child: new Icon(type: 'content/add', size: 24), |
| 297 backgroundColor: colors.RedAccent[200], | 300 backgroundColor: colors.RedAccent[200], |
| 298 onPressed: _handleStockPurchased | 301 onPressed: _handleStockPurchased |
| 299 ); | 302 ); |
| 300 if (_snackbarTransform != null) | 303 if (_snackbarTransform != null) |
| 301 widget = _snackbarTransform.build(widget); | 304 widget = _snackbarTransform.build(widget); |
| 302 return widget; | 305 return widget; |
| 303 } | 306 } |
| 304 | 307 |
| 305 void addMenuToOverlays(List<Widget> overlays) { | 308 void addMenuToOverlays(List<Widget> overlays) { |
| 306 if (_menuController == null) | 309 if (_menuStatus == PopupMenuStatus.inactive) |
| 307 return; | 310 return; |
| 308 overlays.add(new ModalOverlay( | 311 overlays.add(new ModalOverlay( |
| 309 children: [new StockMenu( | 312 children: [new StockMenu( |
| 310 controller: _menuController, | 313 showing: _menuShowing, |
| 314 onStatusChanged: _handleMenuStatusChanged, |
| 311 autorefresh: _autorefresh, | 315 autorefresh: _autorefresh, |
| 312 onAutorefreshChanged: _handleAutorefreshChanged | 316 onAutorefreshChanged: _handleAutorefreshChanged |
| 313 )], | 317 )], |
| 314 onDismiss: _handleMenuHide)); | 318 onDismiss: _handleMenuHide)); |
| 315 } | 319 } |
| 316 | 320 |
| 317 Widget build() { | 321 Widget build() { |
| 318 List<Widget> overlays = [ | 322 List<Widget> overlays = [ |
| 319 new Scaffold( | 323 new Scaffold( |
| 320 toolbar: _isSearching ? buildSearchBar() : buildToolBar(), | 324 toolbar: _isSearching ? buildSearchBar() : buildToolBar(), |
| 321 body: buildTabNavigator(), | 325 body: buildTabNavigator(), |
| 322 snackBar: buildSnackBar(), | 326 snackBar: buildSnackBar(), |
| 323 floatingActionButton: buildFloatingActionButton(), | 327 floatingActionButton: buildFloatingActionButton(), |
| 324 drawer: _drawerShowing ? buildDrawer() : null | 328 drawer: _drawerShowing ? buildDrawer() : null |
| 325 ), | 329 ), |
| 326 ]; | 330 ]; |
| 327 addMenuToOverlays(overlays); | 331 addMenuToOverlays(overlays); |
| 328 return new Stack(overlays); | 332 return new Stack(overlays); |
| 329 } | 333 } |
| 330 } | 334 } |
| OLD | NEW |