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/editing/input.dart'; | 5 import 'package:sky/editing/input.dart'; |
6 import 'package:sky/theme/colors.dart' as colors; | 6 import 'package:sky/theme/colors.dart' as colors; |
7 import 'package:sky/widgets/basic.dart'; | 7 import 'package:sky/widgets/basic.dart'; |
8 import 'package:sky/widgets/drawer.dart'; | 8 import 'package:sky/widgets/drawer.dart'; |
9 import 'package:sky/widgets/drawer_header.dart'; | 9 import 'package:sky/widgets/drawer_header.dart'; |
10 import 'package:sky/widgets/floating_action_button.dart'; | 10 import 'package:sky/widgets/floating_action_button.dart'; |
11 import 'package:sky/widgets/icon.dart'; | 11 import 'package:sky/widgets/icon.dart'; |
12 import 'package:sky/widgets/icon_button.dart'; | 12 import 'package:sky/widgets/icon_button.dart'; |
13 import 'package:sky/widgets/menu_divider.dart'; | 13 import 'package:sky/widgets/menu_divider.dart'; |
14 import 'package:sky/widgets/menu_item.dart'; | 14 import 'package:sky/widgets/menu_item.dart'; |
15 import 'package:sky/widgets/modal_overlay.dart'; | 15 import 'package:sky/widgets/modal_overlay.dart'; |
16 import 'package:sky/widgets/navigator.dart'; | 16 import 'package:sky/widgets/navigator.dart'; |
17 import 'package:sky/widgets/popup_menu.dart'; | 17 import 'package:sky/widgets/popup_menu.dart'; |
18 import 'package:sky/widgets/radio.dart'; | 18 import 'package:sky/widgets/radio.dart'; |
19 import 'package:sky/widgets/scaffold.dart'; | 19 import 'package:sky/widgets/scaffold.dart'; |
| 20 import 'package:sky/widgets/tabs.dart'; |
20 import 'package:sky/widgets/tool_bar.dart'; | 21 import 'package:sky/widgets/tool_bar.dart'; |
21 import 'package:sky/widgets/widget.dart'; | 22 import 'package:sky/widgets/widget.dart'; |
22 | 23 |
23 import 'stock_data.dart'; | 24 import 'stock_data.dart'; |
24 import 'stock_list.dart'; | 25 import 'stock_list.dart'; |
25 import 'stock_menu.dart'; | 26 import 'stock_menu.dart'; |
26 import 'stock_types.dart'; | 27 import 'stock_types.dart'; |
27 | 28 |
28 typedef void ModeUpdater(StockMode mode); | 29 typedef void ModeUpdater(StockMode mode); |
29 | 30 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 ] | 154 ] |
154 ); | 155 ); |
155 } | 156 } |
156 | 157 |
157 void _handleOpenDrawer() { | 158 void _handleOpenDrawer() { |
158 _drawerController.open(); | 159 _drawerController.open(); |
159 navigator.pushState("/drawer", (_) { | 160 navigator.pushState("/drawer", (_) { |
160 _drawerController.close(); | 161 _drawerController.close(); |
161 }); | 162 }); |
162 } | 163 } |
163 | 164 |
164 Widget buildToolBar() { | 165 Widget buildToolBar() { |
165 return new ToolBar( | 166 return new ToolBar( |
166 left: new IconButton( | 167 left: new IconButton( |
167 icon: 'navigation/menu_white', | 168 icon: 'navigation/menu_white', |
168 onPressed: _handleOpenDrawer), | 169 onPressed: _handleOpenDrawer), |
169 center: new Text('Stocks'), | 170 center: new Text('Stocks'), |
170 right: [ | 171 right: [ |
171 new IconButton( | 172 new IconButton( |
172 icon: 'action/search_white', | 173 icon: 'action/search_white', |
173 onPressed: _handleSearchBegin), | 174 onPressed: _handleSearchBegin), |
174 new IconButton( | 175 new IconButton( |
175 icon: 'navigation/more_vert_white', | 176 icon: 'navigation/more_vert_white', |
176 onPressed: _handleMenuShow) | 177 onPressed: _handleMenuShow) |
177 ] | 178 ] |
178 ); | 179 ); |
179 } | 180 } |
180 | 181 |
| 182 int selectedTabIndex = 0; |
| 183 List<String> portfolioSymbols = ["AAPL","FIZZ", "FIVE", "FLAT", "ZINC", "ZNGA"
]; |
| 184 |
| 185 Widget buildPortfolioStocklist() { |
| 186 return new Stocklist( |
| 187 stocks: stocks.where((s) => portfolioSymbols.contains(s.symbol)).toList(), |
| 188 query: _searchQuery |
| 189 ); |
| 190 } |
| 191 |
| 192 Widget buildTabNavigator() { |
| 193 List<TabNavigatorView> views = <TabNavigatorView>[ |
| 194 new TabNavigatorView( |
| 195 label: const TabLabel(text: 'MARKET'), |
| 196 builder: () => new Stocklist(stocks: stocks, query: _searchQuery) |
| 197 ), |
| 198 new TabNavigatorView( |
| 199 label: const TabLabel(text: 'PORTFOLIO'), |
| 200 builder: buildPortfolioStocklist |
| 201 ) |
| 202 ]; |
| 203 return new TabNavigator( |
| 204 views: views, |
| 205 selectedIndex: selectedTabIndex, |
| 206 onChanged: (tabIndex) { |
| 207 setState(() { selectedTabIndex = tabIndex; } ); |
| 208 } |
| 209 ); |
| 210 } |
| 211 |
181 // TODO(abarth): Should we factor this into a SearchBar in the framework? | 212 // TODO(abarth): Should we factor this into a SearchBar in the framework? |
182 Widget buildSearchBar() { | 213 Widget buildSearchBar() { |
183 return new ToolBar( | 214 return new ToolBar( |
184 left: new IconButton( | 215 left: new IconButton( |
185 icon: 'navigation/arrow_back_grey600', | 216 icon: 'navigation/arrow_back_grey600', |
186 onPressed: _handleSearchEnd), | 217 onPressed: _handleSearchEnd), |
187 center: new Input( | 218 center: new Input( |
188 focused: true, | 219 focused: true, |
189 placeholder: 'Search stocks', | 220 placeholder: 'Search stocks', |
190 onChanged: _handleSearchQueryChanged), | 221 onChanged: _handleSearchQueryChanged), |
(...skipping 10 matching lines...) Expand all Loading... |
201 autorefresh: _autorefresh, | 232 autorefresh: _autorefresh, |
202 onAutorefreshChanged: _handleAutorefreshChanged | 233 onAutorefreshChanged: _handleAutorefreshChanged |
203 )], | 234 )], |
204 onDismiss: _handleMenuHide)); | 235 onDismiss: _handleMenuHide)); |
205 } | 236 } |
206 | 237 |
207 Widget build() { | 238 Widget build() { |
208 List<Widget> overlays = [ | 239 List<Widget> overlays = [ |
209 new Scaffold( | 240 new Scaffold( |
210 toolbar: _isSearching ? buildSearchBar() : buildToolBar(), | 241 toolbar: _isSearching ? buildSearchBar() : buildToolBar(), |
211 body: new Stocklist(stocks: stocks, query: _searchQuery), | 242 body: buildTabNavigator(), |
212 floatingActionButton: new FloatingActionButton( | 243 floatingActionButton: new FloatingActionButton( |
213 child: new Icon(type: 'content/add_white', size: 24) | 244 child: new Icon(type: 'content/add_white', size: 24) |
214 ), | 245 ), |
215 drawer: _drawerShowing ? buildDrawer() : null | 246 drawer: _drawerShowing ? buildDrawer() : null |
216 ), | 247 ), |
217 ]; | 248 ]; |
218 addMenuToOverlays(overlays); | 249 addMenuToOverlays(overlays); |
219 return new Stack(overlays); | 250 return new Stack(overlays); |
220 } | 251 } |
221 } | 252 } |
OLD | NEW |