| 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/editing2/input.dart'; | 5 import 'package:sky/editing2/input.dart'; |
| 6 import 'package:sky/rendering/box.dart'; | 6 import 'package:sky/rendering/box.dart'; |
| 7 import 'package:sky/rendering/paragraph.dart'; | 7 import 'package:sky/rendering/paragraph.dart'; |
| 8 import 'package:sky/theme2/colors.dart' as colors; | 8 import 'package:sky/theme2/colors.dart' as colors; |
| 9 import 'package:sky/theme2/typography.dart' as typography; | 9 import 'package:sky/theme2/typography.dart' as typography; |
| 10 import 'package:sky/widgets/basic.dart'; | 10 import 'package:sky/widgets/basic.dart'; |
| 11 import 'package:sky/widgets/drawer.dart'; | 11 import 'package:sky/widgets/drawer.dart'; |
| 12 import 'package:sky/widgets/drawer_header.dart'; | 12 import 'package:sky/widgets/drawer_header.dart'; |
| 13 import 'package:sky/widgets/floating_action_button.dart'; | 13 import 'package:sky/widgets/floating_action_button.dart'; |
| 14 import 'package:sky/widgets/icon.dart'; | 14 import 'package:sky/widgets/icon.dart'; |
| 15 import 'package:sky/widgets/icon_button.dart'; | 15 import 'package:sky/widgets/icon_button.dart'; |
| 16 import 'package:sky/widgets/menu_divider.dart'; | 16 import 'package:sky/widgets/menu_divider.dart'; |
| 17 import 'package:sky/widgets/menu_item.dart'; | 17 import 'package:sky/widgets/menu_item.dart'; |
| 18 import 'package:sky/widgets/modal_overlay.dart'; | 18 import 'package:sky/widgets/modal_overlay.dart'; |
| 19 import 'package:sky/widgets/navigator.dart'; |
| 19 import 'package:sky/widgets/popup_menu.dart'; | 20 import 'package:sky/widgets/popup_menu.dart'; |
| 20 import 'package:sky/widgets/radio.dart'; | 21 import 'package:sky/widgets/radio.dart'; |
| 21 import 'package:sky/widgets/scaffold.dart'; | 22 import 'package:sky/widgets/scaffold.dart'; |
| 22 import 'package:sky/widgets/tool_bar.dart'; | 23 import 'package:sky/widgets/tool_bar.dart'; |
| 23 import 'package:sky/widgets/widget.dart'; | 24 import 'package:sky/widgets/widget.dart'; |
| 24 | 25 |
| 25 import 'stock_data.dart'; | 26 import 'stock_data.dart'; |
| 26 import 'stock_list.dart'; | 27 import 'stock_list.dart'; |
| 27 import 'stock_menu.dart'; | 28 import 'stock_menu.dart'; |
| 28 | 29 |
| 29 enum StockMode { optimistic, pessimistic } | 30 enum StockMode { optimistic, pessimistic } |
| 30 | 31 |
| 31 class StocksApp extends App { | 32 class StockHome extends Component { |
| 32 | 33 |
| 33 List<Stock> _stocks = []; | 34 StockHome(this._navigator) { |
| 34 | |
| 35 StocksApp({ RenderView renderViewOverride }) : super(renderViewOverride: rende
rViewOverride) { | |
| 36 // if (debug) | 35 // if (debug) |
| 37 // new Timer(new Duration(seconds: 1), dumpState); | 36 // new Timer(new Duration(seconds: 1), dumpState); |
| 38 new StockDataFetcher((StockData data) { | 37 new StockDataFetcher((StockData data) { |
| 39 setState(() { | 38 setState(() { |
| 40 data.appendTo(_stocks); | 39 data.appendTo(_stocks); |
| 41 }); | 40 }); |
| 42 }); | 41 }); |
| 43 _drawerController = new DrawerController(_handleDrawerStatusChanged); | 42 _drawerController = new DrawerController(_handleDrawerStatusChanged); |
| 44 } | 43 } |
| 45 | 44 |
| 45 List<Stock> _stocks = []; |
| 46 Navigator _navigator; |
| 47 |
| 46 bool _isSearching = false; | 48 bool _isSearching = false; |
| 47 String _searchQuery; | 49 String _searchQuery; |
| 48 | 50 |
| 49 void _handleSearchBegin(_) { | 51 void _handleSearchBegin(_) { |
| 50 setState(() { | 52 setState(() { |
| 51 _isSearching = true; | 53 _isSearching = true; |
| 52 }); | 54 }); |
| 53 } | 55 } |
| 54 | 56 |
| 55 void _handleSearchEnd(_) { | 57 void _handleSearchEnd(_) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 icon: 'action/thumb_down', | 137 icon: 'action/thumb_down', |
| 136 onGestureTap: (event) => _handleStockModeChange(StockMode.pessimistic)
, | 138 onGestureTap: (event) => _handleStockModeChange(StockMode.pessimistic)
, |
| 137 children: [ | 139 children: [ |
| 138 new Flexible(child: new Text('Pessimistic')), | 140 new Flexible(child: new Text('Pessimistic')), |
| 139 new Radio(key: 'pessimistic-radio', value: StockMode.pessimistic, gr
oupValue: _stockMode, onChanged: _handleStockModeChange) | 141 new Radio(key: 'pessimistic-radio', value: StockMode.pessimistic, gr
oupValue: _stockMode, onChanged: _handleStockModeChange) |
| 140 ]), | 142 ]), |
| 141 new MenuDivider(key: 'div2'), | 143 new MenuDivider(key: 'div2'), |
| 142 new MenuItem( | 144 new MenuItem( |
| 143 key: 'Settings', | 145 key: 'Settings', |
| 144 icon: 'action/settings', | 146 icon: 'action/settings', |
| 147 onGestureTap: (event) => _navigator.pushNamed('/settings'), |
| 145 children: [new Text('Settings')]), | 148 children: [new Text('Settings')]), |
| 146 new MenuItem( | 149 new MenuItem( |
| 147 key: 'Help & Feedback', | 150 key: 'Help & Feedback', |
| 148 icon: 'action/help', | 151 icon: 'action/help', |
| 149 children: [new Text('Help & Feedback')]) | 152 children: [new Text('Help & Feedback')]) |
| 150 ] | 153 ] |
| 151 ); | 154 ); |
| 152 } | 155 } |
| 153 | 156 |
| 154 Widget buildToolBar() { | 157 Widget buildToolBar() { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 floatingActionButton: new FloatingActionButton( | 206 floatingActionButton: new FloatingActionButton( |
| 204 child: new Icon(type: 'content/add_white', size: 24) | 207 child: new Icon(type: 'content/add_white', size: 24) |
| 205 ), | 208 ), |
| 206 drawer: _drawerShowing ? buildDrawer() : null | 209 drawer: _drawerShowing ? buildDrawer() : null |
| 207 ), | 210 ), |
| 208 ]; | 211 ]; |
| 209 addMenuToOverlays(overlays); | 212 addMenuToOverlays(overlays); |
| 210 return new Stack(overlays); | 213 return new Stack(overlays); |
| 211 } | 214 } |
| 212 } | 215 } |
| 213 | |
| 214 void main() { | |
| 215 print("starting stocks app!"); | |
| 216 App app = new StocksApp(); | |
| 217 WidgetAppView.appView.onFrame = () { | |
| 218 // uncomment this for debugging: | |
| 219 // WidgetAppView.appView.debugDumpRenderTree(); | |
| 220 }; | |
| 221 } | |
| OLD | NEW |