| 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/framework/components2/tool_bar.dart'; | 5 import 'package:sky/framework/components2/tool_bar.dart'; |
| 6 // import 'package:sky/framework/components2/drawer.dart'; | 6 import 'package:sky/framework/components2/drawer.dart'; |
| 7 // import 'package:sky/framework/components2/drawer_header.dart'; | 7 // import 'package:sky/framework/components2/drawer_header.dart'; |
| 8 // import 'package:sky/framework/components2/floating_action_button.dart'; | 8 // import 'package:sky/framework/components2/floating_action_button.dart'; |
| 9 // import 'package:sky/framework/components2/icon.dart'; | 9 // import 'package:sky/framework/components2/icon.dart'; |
| 10 import 'package:sky/framework/components2/icon_button.dart'; | 10 import 'package:sky/framework/components2/icon_button.dart'; |
| 11 // import 'package:sky/framework/components2/input.dart'; | 11 // import 'package:sky/framework/components2/input.dart'; |
| 12 // import 'package:sky/framework/components2/menu_divider.dart'; | 12 // import 'package:sky/framework/components2/menu_divider.dart'; |
| 13 // import 'package:sky/framework/components2/menu_item.dart'; | 13 // import 'package:sky/framework/components2/menu_item.dart'; |
| 14 // import 'package:sky/framework/components2/modal_overlay.dart'; | 14 // import 'package:sky/framework/components2/modal_overlay.dart'; |
| 15 // import 'package:sky/framework/components2/popup_menu.dart'; | 15 // import 'package:sky/framework/components2/popup_menu.dart'; |
| 16 // import 'package:sky/framework/components2/radio.dart'; | 16 // import 'package:sky/framework/components2/radio.dart'; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 39 List<Stock> _stocks = []; | 39 List<Stock> _stocks = []; |
| 40 | 40 |
| 41 StocksApp() : super() { | 41 StocksApp() : super() { |
| 42 // if (debug) | 42 // if (debug) |
| 43 // new Timer(new Duration(seconds: 1), dumpState); | 43 // new Timer(new Duration(seconds: 1), dumpState); |
| 44 new StockDataFetcher((StockData data) { | 44 new StockDataFetcher((StockData data) { |
| 45 setState(() { | 45 setState(() { |
| 46 data.appendTo(_stocks); | 46 data.appendTo(_stocks); |
| 47 }); | 47 }); |
| 48 }); | 48 }); |
| 49 // _drawerController = new DrawerController(_handleDrawerStatusChanged); | 49 _drawerController = new DrawerController(_handleDrawerStatusChanged); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool _isSearching = false; | 52 bool _isSearching = false; |
| 53 String _searchQuery; | 53 String _searchQuery; |
| 54 | 54 |
| 55 void _handleSearchBegin(_) { | 55 void _handleSearchBegin(_) { |
| 56 setState(() { | 56 setState(() { |
| 57 _isSearching = true; | 57 _isSearching = true; |
| 58 }); | 58 }); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void _handleSearchEnd(_) { | 61 void _handleSearchEnd(_) { |
| 62 setState(() { | 62 setState(() { |
| 63 _isSearching = false; | 63 _isSearching = false; |
| 64 _searchQuery = null; | 64 _searchQuery = null; |
| 65 }); | 65 }); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void _handleSearchQueryChanged(String query) { | 68 void _handleSearchQueryChanged(String query) { |
| 69 setState(() { | 69 setState(() { |
| 70 _searchQuery = query; | 70 _searchQuery = query; |
| 71 }); | 71 }); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // DrawerController _drawerController; | 74 DrawerController _drawerController; |
| 75 bool _drawerShowing = false; | 75 bool _drawerShowing = false; |
| 76 | 76 |
| 77 void _handleDrawerStatusChanged(bool showing) { | 77 void _handleDrawerStatusChanged(bool showing) { |
| 78 setState(() { | 78 setState(() { |
| 79 _drawerShowing = showing; | 79 _drawerShowing = showing; |
| 80 }); | 80 }); |
| 81 } | 81 } |
| 82 | 82 |
| 83 // PopupMenuController _menuController; | 83 // PopupMenuController _menuController; |
| 84 | 84 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 108 | 108 |
| 109 StockMode _stockMode = StockMode.Optimistic; | 109 StockMode _stockMode = StockMode.Optimistic; |
| 110 void _handleStockModeChange(StockMode value) { | 110 void _handleStockModeChange(StockMode value) { |
| 111 setState(() { | 111 setState(() { |
| 112 _stockMode = value; | 112 _stockMode = value; |
| 113 }); | 113 }); |
| 114 } | 114 } |
| 115 | 115 |
| 116 // static FlexBoxParentData _flex1 = new FlexBoxParentData()..flex = 1; | 116 // static FlexBoxParentData _flex1 = new FlexBoxParentData()..flex = 1; |
| 117 | 117 |
| 118 // Drawer buildDrawer() { | 118 Drawer buildDrawer() { |
| 119 // return new Drawer( | 119 return new Drawer( |
| 120 // controller: _drawerController, | 120 controller: _drawerController, |
| 121 // level: 3, | 121 level: 3 |
| 122 // , |
| 122 // children: [ | 123 // children: [ |
| 123 // new DrawerHeader(children: [new Text('Stocks')]), | 124 // new DrawerHeader(children: [new Text('Stocks')]), |
| 124 // new MenuItem( | 125 // new MenuItem( |
| 125 // key: 'Stock list', | 126 // key: 'Stock list', |
| 126 // icon: 'action/assessment', | 127 // icon: 'action/assessment', |
| 127 // children: [new Text('Stock List')]), | 128 // children: [new Text('Stock List')]), |
| 128 // new MenuItem( | 129 // new MenuItem( |
| 129 // key: 'Account Balance', | 130 // key: 'Account Balance', |
| 130 // icon: 'action/account_balance', | 131 // icon: 'action/account_balance', |
| 131 // children: [new Text('Account Balance')]), | 132 // children: [new Text('Account Balance')]), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 148 // ]), | 149 // ]), |
| 149 // new MenuDivider(key: 'div2'), | 150 // new MenuDivider(key: 'div2'), |
| 150 // new MenuItem( | 151 // new MenuItem( |
| 151 // key: 'Settings', | 152 // key: 'Settings', |
| 152 // icon: 'action/settings', | 153 // icon: 'action/settings', |
| 153 // children: [new Text('Settings')]), | 154 // children: [new Text('Settings')]), |
| 154 // new MenuItem( | 155 // new MenuItem( |
| 155 // key: 'Help & Feedback', | 156 // key: 'Help & Feedback', |
| 156 // icon: 'action/help', | 157 // icon: 'action/help', |
| 157 // children: [new Text('Help & Feedback')]) | 158 // children: [new Text('Help & Feedback')]) |
| 158 // ] | 159 // ] |
| 159 // ); | 160 ); |
| 160 // } | 161 } |
| 161 | 162 |
| 162 UINode buildToolBar() { | 163 UINode buildToolBar() { |
| 163 return new ToolBar( | 164 return new ToolBar( |
| 164 left: new IconButton( | 165 left: new IconButton( |
| 165 icon: 'navigation/menu_white', | 166 icon: 'navigation/menu_white', |
| 166 onGestureTap: (_) => true), // _drawerController.toggle), | 167 onGestureTap: (_) => _drawerController.toggle), |
| 167 center: new Text('Stocks'), | 168 center: new Text('Stocks'), |
| 168 right: [ | 169 right: [ |
| 169 new IconButton( | 170 new IconButton( |
| 170 icon: 'action/search_white', | 171 icon: 'action/search_white', |
| 171 onGestureTap: _handleSearchBegin), | 172 onGestureTap: _handleSearchBegin), |
| 172 new IconButton( | 173 new IconButton( |
| 173 icon: 'navigation/more_vert_white', | 174 icon: 'navigation/more_vert_white', |
| 174 onGestureTap: _handleMenuShow) | 175 onGestureTap: _handleMenuShow) |
| 175 ], | 176 ], |
| 176 backgroundColor: colorFromCSSHexColorString(Purple[500]) | 177 backgroundColor: colorFromCSSHexColorString(Purple[500]) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 199 // controller: _menuController, | 200 // controller: _menuController, |
| 200 // autorefresh: _autorefresh, | 201 // autorefresh: _autorefresh, |
| 201 // onAutorefreshChanged: _handleAutorefreshChanged | 202 // onAutorefreshChanged: _handleAutorefreshChanged |
| 202 // )], | 203 // )], |
| 203 // onDismiss: _handleMenuHide)); | 204 // onDismiss: _handleMenuHide)); |
| 204 } | 205 } |
| 205 | 206 |
| 206 UINode build() { | 207 UINode build() { |
| 207 List<UINode> overlays = [ | 208 List<UINode> overlays = [ |
| 208 new Scaffold( | 209 new Scaffold( |
| 209 toolbar: _isSearching ? buildSearchBar() : buildToolBar() | 210 toolbar: _isSearching ? buildSearchBar() : buildToolBar(), |
| 210 // , | |
| 211 // body: new Stocklist(stocks: _stocks, query: _searchQuery), | 211 // body: new Stocklist(stocks: _stocks, query: _searchQuery), |
| 212 // floatingActionButton: new FloatingActionButton( | 212 // floatingActionButton: new FloatingActionButton( |
| 213 // content: new Icon(type: 'content/add_white', size: 24), | 213 // content: new Icon(type: 'content/add_white', size: 24), |
| 214 // level: 3), | 214 // level: 3), |
| 215 // drawer: _drawerShowing ? buildDrawer() : null | 215 drawer: _drawerShowing ? buildDrawer() : null |
| 216 ), | 216 ), |
| 217 ]; | 217 ]; |
| 218 addMenuToOverlays(overlays); | 218 addMenuToOverlays(overlays); |
| 219 return new StackContainer(children: overlays); | 219 return new StackContainer(children: overlays); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 void main() { | 223 void main() { |
| 224 print("starting stocks app!"); | 224 print("starting stocks app!"); |
| 225 new StocksApp(); | 225 new StocksApp(); |
| 226 } | 226 } |
| OLD | NEW |