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/input.dart'; | 10 import 'package:sky/framework/components/input.dart'; |
(...skipping 16 matching lines...) Expand all Loading... |
27 static Style _iconStyle = new Style(''' | 27 static Style _iconStyle = new Style(''' |
28 padding: 8px;''' | 28 padding: 8px;''' |
29 ); | 29 ); |
30 | 30 |
31 static Style _titleStyle = new Style(''' | 31 static Style _titleStyle = new Style(''' |
32 padding-left: 24px; | 32 padding-left: 24px; |
33 flex: 1; | 33 flex: 1; |
34 ${typography.white.title};''' | 34 ${typography.white.title};''' |
35 ); | 35 ); |
36 | 36 |
37 List<Stock> _sortedStocks = []; | 37 StockDataFetcher _stockDataFetcher; |
| 38 List<Stock> _stocks = []; |
38 bool _isSearching = false; | 39 bool _isSearching = false; |
39 bool _isShowingMenu = false; | 40 bool _isShowingMenu = false; |
40 String _searchQuery; | 41 String _searchQuery; |
41 | 42 |
42 StocksApp() : super() { | 43 StocksApp() : super() { |
43 fetchStockOracle().then((oracle) { | 44 _stockDataFetcher = new StockDataFetcher((StockData data) { |
44 setState(() { | 45 setState(() { |
45 _sortedStocks = oracle.stocks; | 46 data.appendTo(_stocks); |
46 trace('StocksApp::sortStocks', () { | |
47 _sortedStocks.sort((a, b) => a.symbol.compareTo(b.symbol)); | |
48 }); | |
49 }); | 47 }); |
50 }); | 48 }); |
51 } | 49 } |
52 | 50 |
53 void _handleSearchClick(_) { | 51 void _handleSearchClick(_) { |
54 setState(() { | 52 setState(() { |
55 _isSearching = !_isSearching; | 53 _isSearching = !_isSearching; |
56 }); | 54 }); |
57 } | 55 } |
58 | 56 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 setState(() { | 146 setState(() { |
149 _menuController.close(); | 147 _menuController.close(); |
150 _menuController = null; | 148 _menuController = null; |
151 }); | 149 }); |
152 } | 150 } |
153 )); | 151 )); |
154 } | 152 } |
155 | 153 |
156 return new Scaffold( | 154 return new Scaffold( |
157 actionBar: actionBar, | 155 actionBar: actionBar, |
158 content: new Stocklist(stocks: _sortedStocks, query: _searchQuery), | 156 content: new Stocklist(stocks: _stocks, query: _searchQuery), |
159 fab: new FloatingActionButton( | 157 fab: new FloatingActionButton( |
160 content: new Icon(type: 'content/add_white', size: 24), level: 3), | 158 content: new Icon(type: 'content/add_white', size: 24), level: 3), |
161 drawer: drawer, | 159 drawer: drawer, |
162 overlays: overlays | 160 overlays: overlays |
163 ); | 161 ); |
164 } | 162 } |
165 } | 163 } |
OLD | NEW |