Chromium Code Reviews| 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'; |
| 11 import 'package:sky/framework/components/menu_divider.dart'; | 11 import 'package:sky/framework/components/menu_divider.dart'; |
| 12 import 'package:sky/framework/components/menu_item.dart'; | 12 import 'package:sky/framework/components/menu_item.dart'; |
| 13 import 'package:sky/framework/fn.dart'; | 13 import 'package:sky/framework/fn.dart'; |
| 14 import 'package:sky/framework/theme/typography.dart' as typography; | 14 import 'package:sky/framework/theme/typography.dart' as typography; |
| 15 import 'stock_data.dart'; | 15 import 'stock_data.dart'; |
| 16 import 'stock_list.dart'; | 16 import 'stock_list.dart'; |
| 17 import 'stock_menu.dart'; | |
| 17 | 18 |
| 18 class StocksApp extends App { | 19 class StocksApp extends App { |
| 19 | 20 |
| 20 DrawerAnimation _drawerAnimation = new DrawerAnimation(); | 21 DrawerAnimation _drawerAnimation = new DrawerAnimation(); |
| 21 | 22 |
| 22 static Style _style = new Style(''' | 23 static Style _style = new Style(''' |
| 23 display: flex; | 24 display: flex; |
| 24 flex-direction: column; | 25 flex-direction: column; |
| 25 height: -webkit-fill-available; | 26 height: -webkit-fill-available; |
| 26 ${typography.typeface}; | 27 ${typography.typeface}; |
| 27 ${typography.black.body1};''' | 28 ${typography.black.body1};''' |
| 28 ); | 29 ); |
| 29 | 30 |
| 30 static Style _iconStyle = new Style(''' | 31 static Style _iconStyle = new Style(''' |
| 31 padding: 8px;''' | 32 padding: 8px;''' |
| 32 ); | 33 ); |
| 33 | 34 |
| 34 static Style _titleStyle = new Style(''' | 35 static Style _titleStyle = new Style(''' |
| 35 padding-left: 24px; | 36 padding-left: 24px; |
| 36 flex: 1; | 37 flex: 1; |
| 37 ${typography.white.title};''' | 38 ${typography.white.title};''' |
| 38 ); | 39 ); |
| 39 | 40 |
| 40 List<Stock> _sortedStocks; | 41 List<Stock> _sortedStocks; |
| 41 bool _isSearching = false; | 42 bool _isSearching = false; |
| 43 bool _isShowingMenu = false; | |
| 42 String _searchQuery; | 44 String _searchQuery; |
| 43 | 45 |
| 44 StocksApp() : super() { | 46 StocksApp() : super() { |
| 45 _sortedStocks = oracle.stocks; | 47 _sortedStocks = oracle.stocks; |
| 46 _sortedStocks.sort((a, b) => a.symbol.compareTo(b.symbol)); | 48 _sortedStocks.sort((a, b) => a.symbol.compareTo(b.symbol)); |
| 47 } | 49 } |
| 48 | 50 |
| 49 void _handleSearchClick(_) { | 51 void _handleSearchClick(_) { |
| 50 setState(() { | 52 setState(() { |
| 51 _isSearching = !_isSearching; | 53 _isSearching = !_isSearching; |
| 52 }); | 54 }); |
| 53 } | 55 } |
| 54 | 56 |
| 57 void _handleMenuClick(_) { | |
| 58 print("_handleMenuClick"); | |
|
ojan
2015/03/18 02:09:39
Did you mean to leave this in?
abarth-chromium
2015/03/18 02:19:58
Nope!
| |
| 59 setState(() { | |
| 60 _isShowingMenu = !_isShowingMenu; | |
| 61 }); | |
| 62 } | |
| 63 | |
| 55 void _handleSearchQueryChanged(query) { | 64 void _handleSearchQueryChanged(query) { |
| 56 setState(() { | 65 setState(() { |
| 57 _searchQuery = query; | 66 _searchQuery = query; |
| 58 }); | 67 }); |
| 59 } | 68 } |
| 60 | 69 |
| 61 Node build() { | 70 Node build() { |
| 62 var drawer = new Drawer( | 71 var drawer = new Drawer( |
| 63 animation: _drawerAnimation, | 72 animation: _drawerAnimation, |
| 64 level: 3, | 73 level: 3, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 style: _titleStyle, | 118 style: _titleStyle, |
| 110 children: [title] | 119 children: [title] |
| 111 ), | 120 ), |
| 112 new Icon(key: 'search', style: _iconStyle, | 121 new Icon(key: 'search', style: _iconStyle, |
| 113 size: 24, | 122 size: 24, |
| 114 type: 'action/search_white') | 123 type: 'action/search_white') |
| 115 ..events.listen('gesturetap', _handleSearchClick), | 124 ..events.listen('gesturetap', _handleSearchClick), |
| 116 new Icon(key: 'more_white', style: _iconStyle, | 125 new Icon(key: 'more_white', style: _iconStyle, |
| 117 size: 24, | 126 size: 24, |
| 118 type: 'navigation/more_vert_white') | 127 type: 'navigation/more_vert_white') |
| 128 ..events.listen('gesturetap', _handleMenuClick), | |
| 119 ] | 129 ] |
| 120 ); | 130 ); |
| 121 | 131 |
| 122 var list = new Stocklist(stocks: _sortedStocks, query: _searchQuery); | 132 var list = new Stocklist(stocks: _sortedStocks, query: _searchQuery); |
| 123 | 133 |
| 124 var fab = new FloatingActionButton(content: new Icon( | 134 var fab = new FloatingActionButton(content: new Icon( |
| 125 type: 'content/add_white', size: 24), level: 3); | 135 type: 'content/add_white', size: 24), level: 3); |
| 126 | 136 |
| 127 return new Container( | 137 var children = [ |
| 128 key: 'StocksApp', | 138 new Container( |
| 129 children: [ | 139 key: 'Content', |
| 130 new Container( | 140 style: _style, |
| 131 key: 'Content', | 141 children: [toolbar, list] |
| 132 style: _style, | 142 ), |
| 133 children: [toolbar, list] | 143 fab, |
| 134 ), | 144 drawer |
| 135 fab, | 145 ]; |
| 136 drawer, | 146 |
| 137 ] | 147 if (_isShowingMenu) |
| 138 ); | 148 children.add(new StockMenu()); |
| 149 | |
| 150 return new Container(key: 'StocksApp', children: children); | |
| 139 } | 151 } |
| 140 } | 152 } |
| OLD | NEW |