Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: sky/examples/stocks-fn/lib/stock_app.dart

Issue 1038533002: Load data for StocksApp incrementally (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: remove spurious diff Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « sky/examples/stocks-fn/data/stock_data_9.json ('k') | sky/examples/stocks-fn/lib/stock_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698