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/components/action_bar.dart'; | 5 import 'package:sky/framework/components/action_bar.dart'; |
6 import 'package:sky/framework/components/drawer.dart'; | 6 import 'package:sky/framework/components/drawer.dart'; |
7 import 'package:sky/framework/components/drawer_header.dart'; | 7 import 'package:sky/framework/components/drawer_header.dart'; |
8 import 'package:sky/framework/components/floating_action_button.dart'; | 8 import 'package:sky/framework/components/floating_action_button.dart'; |
9 import 'package:sky/framework/components/icon.dart'; | 9 import 'package:sky/framework/components/icon.dart'; |
10 import 'package:sky/framework/components/icon_button.dart'; | 10 import 'package:sky/framework/components/icon_button.dart'; |
11 import 'package:sky/framework/components/input.dart'; | 11 import 'package:sky/framework/components/input.dart'; |
12 import 'package:sky/framework/components/menu_divider.dart'; | 12 import 'package:sky/framework/components/menu_divider.dart'; |
13 import 'package:sky/framework/components/menu_item.dart'; | 13 import 'package:sky/framework/components/menu_item.dart'; |
14 import 'package:sky/framework/components/modal_overlay.dart'; | 14 import 'package:sky/framework/components/modal_overlay.dart'; |
15 import 'package:sky/framework/components/popup_menu.dart'; | 15 import 'package:sky/framework/components/popup_menu.dart'; |
16 import 'package:sky/framework/components/scaffold.dart'; | 16 import 'package:sky/framework/components/scaffold.dart'; |
17 import 'package:sky/framework/fn.dart'; | 17 import 'package:sky/framework/fn.dart'; |
18 import 'package:sky/framework/theme/typography.dart' as typography; | 18 import 'package:sky/framework/theme/typography.dart' as typography; |
19 import 'package:sky/framework/theme/colors.dart'; | 19 import 'package:sky/framework/theme/colors.dart'; |
20 import 'stock_data.dart'; | 20 import 'stock_data.dart'; |
21 import 'stock_list.dart'; | 21 import 'stock_list.dart'; |
22 import 'stock_menu.dart'; | 22 import 'stock_menu.dart'; |
23 | 23 |
| 24 import 'dart:async'; |
| 25 import 'package:sky/framework/layout.dart'; |
| 26 |
| 27 const bool debug = false; // set to true to dump the DOM for debugging purposes |
| 28 |
24 class StocksApp extends App { | 29 class StocksApp extends App { |
25 DrawerController _drawerController = new DrawerController(); | 30 DrawerController _drawerController = new DrawerController(); |
26 PopupMenuController _menuController; | 31 PopupMenuController _menuController; |
27 | 32 |
28 static final Style _actionBarStyle = new Style(''' | 33 static final Style _actionBarStyle = new Style(''' |
29 background-color: ${Purple[500]};'''); | 34 background-color: ${Purple[500]};'''); |
30 | 35 |
31 static final Style _searchBarStyle = new Style(''' | 36 static final Style _searchBarStyle = new Style(''' |
32 background-color: ${Grey[50]};'''); | 37 background-color: ${Grey[50]};'''); |
33 | 38 |
34 static final Style _titleStyle = new Style(''' | 39 static final Style _titleStyle = new Style(''' |
35 ${typography.white.title};'''); | 40 ${typography.white.title};'''); |
36 | 41 |
37 List<Stock> _stocks = []; | 42 List<Stock> _stocks = []; |
38 bool _isSearching = false; | 43 bool _isSearching = false; |
39 String _searchQuery; | 44 String _searchQuery; |
40 | 45 |
41 StocksApp() : super() { | 46 StocksApp() : super() { |
| 47 if (debug) |
| 48 new Timer(new Duration(seconds: 1), dumpState); |
42 new StockDataFetcher((StockData data) { | 49 new StockDataFetcher((StockData data) { |
43 setState(() { | 50 setState(() { |
44 data.appendTo(_stocks); | 51 data.appendTo(_stocks); |
45 }); | 52 }); |
46 }); | 53 }); |
47 } | 54 } |
48 | 55 |
49 void _handleSearchBegin(_) { | 56 void _handleSearchBegin(_) { |
50 setState(() { | 57 setState(() { |
51 _isSearching = true; | 58 _isSearching = true; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 return new Scaffold( | 165 return new Scaffold( |
159 header: _isSearching ? buildSearchBar() : buildActionBar(), | 166 header: _isSearching ? buildSearchBar() : buildActionBar(), |
160 content: new Stocklist(stocks: _stocks, query: _searchQuery), | 167 content: new Stocklist(stocks: _stocks, query: _searchQuery), |
161 fab: new FloatingActionButton( | 168 fab: new FloatingActionButton( |
162 content: new Icon(type: 'content/add_white', size: 24), level: 3), | 169 content: new Icon(type: 'content/add_white', size: 24), level: 3), |
163 drawer: buildDrawer(), | 170 drawer: buildDrawer(), |
164 overlays: overlays | 171 overlays: overlays |
165 ); | 172 ); |
166 } | 173 } |
167 } | 174 } |
OLD | NEW |