| 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/components/popup_menu.dart'; |
| 13 import 'package:sky/framework/fn.dart'; | 14 import 'package:sky/framework/fn.dart'; |
| 14 import 'package:sky/framework/theme/typography.dart' as typography; | 15 import 'package:sky/framework/theme/typography.dart' as typography; |
| 15 import 'stock_data.dart'; | 16 import 'stock_data.dart'; |
| 16 import 'stock_list.dart'; | 17 import 'stock_list.dart'; |
| 17 import 'stock_menu.dart'; | 18 import 'stock_menu.dart'; |
| 18 | 19 |
| 19 class StocksApp extends App { | 20 class StocksApp extends App { |
| 20 | 21 |
| 21 DrawerController _DrawerController = new DrawerController(); | 22 DrawerController _drawerController = new DrawerController(); |
| 23 PopupMenuController _menuController = new PopupMenuController(); |
| 22 | 24 |
| 23 static Style _style = new Style(''' | 25 static Style _style = new Style(''' |
| 24 display: flex; | 26 display: flex; |
| 25 flex-direction: column; | 27 flex-direction: column; |
| 26 height: -webkit-fill-available; | 28 height: -webkit-fill-available; |
| 27 ${typography.typeface}; | 29 ${typography.typeface}; |
| 28 ${typography.black.body1};''' | 30 ${typography.black.body1};''' |
| 29 ); | 31 ); |
| 30 | 32 |
| 31 static Style _iconStyle = new Style(''' | 33 static Style _iconStyle = new Style(''' |
| (...skipping 17 matching lines...) Expand all Loading... |
| 49 } | 51 } |
| 50 | 52 |
| 51 void _handleSearchClick(_) { | 53 void _handleSearchClick(_) { |
| 52 setState(() { | 54 setState(() { |
| 53 _isSearching = !_isSearching; | 55 _isSearching = !_isSearching; |
| 54 }); | 56 }); |
| 55 } | 57 } |
| 56 | 58 |
| 57 void _handleMenuClick(_) { | 59 void _handleMenuClick(_) { |
| 58 setState(() { | 60 setState(() { |
| 59 _isShowingMenu = !_isShowingMenu; | 61 _menuController.open(); |
| 60 }); | 62 }); |
| 61 } | 63 } |
| 62 | 64 |
| 63 void _handleSearchQueryChanged(query) { | 65 void _handleSearchQueryChanged(query) { |
| 64 setState(() { | 66 setState(() { |
| 65 _searchQuery = query; | 67 _searchQuery = query; |
| 66 }); | 68 }); |
| 67 } | 69 } |
| 68 | 70 |
| 69 Node build() { | 71 Node build() { |
| 70 var drawer = new Drawer( | 72 var drawer = new Drawer( |
| 71 controller: _DrawerController, | 73 controller: _drawerController, |
| 72 level: 3, | 74 level: 3, |
| 73 children: [ | 75 children: [ |
| 74 new DrawerHeader( | 76 new DrawerHeader( |
| 75 children: [new Text('Stocks')] | 77 children: [new Text('Stocks')] |
| 76 ), | 78 ), |
| 77 new MenuItem( | 79 new MenuItem( |
| 78 key: 'Inbox', | 80 key: 'Inbox', |
| 79 icon: 'content/inbox', | 81 icon: 'content/inbox', |
| 80 children: [new Text('Inbox')] | 82 children: [new Text('Inbox')] |
| 81 ), | 83 ), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 105 onChanged: _handleSearchQueryChanged); | 107 onChanged: _handleSearchQueryChanged); |
| 106 } else { | 108 } else { |
| 107 title = new Text('Stocks'); | 109 title = new Text('Stocks'); |
| 108 } | 110 } |
| 109 | 111 |
| 110 var toolbar = new ActionBar( | 112 var toolbar = new ActionBar( |
| 111 children: [ | 113 children: [ |
| 112 new Icon(key: 'menu', style: _iconStyle, | 114 new Icon(key: 'menu', style: _iconStyle, |
| 113 size: 24, | 115 size: 24, |
| 114 type: 'navigation/menu_white') | 116 type: 'navigation/menu_white') |
| 115 ..events.listen('gesturetap', _DrawerController.toggle), | 117 ..events.listen('gesturetap', _drawerController.toggle), |
| 116 new Container( | 118 new Container( |
| 117 style: _titleStyle, | 119 style: _titleStyle, |
| 118 children: [title] | 120 children: [title] |
| 119 ), | 121 ), |
| 120 new Icon(key: 'search', style: _iconStyle, | 122 new Icon(key: 'search', style: _iconStyle, |
| 121 size: 24, | 123 size: 24, |
| 122 type: 'action/search_white') | 124 type: 'action/search_white') |
| 123 ..events.listen('gesturetap', _handleSearchClick), | 125 ..events.listen('gesturetap', _handleSearchClick), |
| 124 new Icon(key: 'more_white', style: _iconStyle, | 126 new Icon(key: 'more_white', style: _iconStyle, |
| 125 size: 24, | 127 size: 24, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 136 var children = [ | 138 var children = [ |
| 137 new Container( | 139 new Container( |
| 138 key: 'Content', | 140 key: 'Content', |
| 139 style: _style, | 141 style: _style, |
| 140 children: [toolbar, list] | 142 children: [toolbar, list] |
| 141 ), | 143 ), |
| 142 fab, | 144 fab, |
| 143 drawer | 145 drawer |
| 144 ]; | 146 ]; |
| 145 | 147 |
| 146 if (_isShowingMenu) { | 148 if (_menuController.isOpen) { |
| 147 children.add(new StockMenu()..events.listen('gesturetap', (_) { | 149 children.add(new StockMenu(controller: _menuController) |
| 150 ..events.listen('gesturetap', (_) { |
| 151 // TODO(abarth): We should close the menu when you tap away from the |
| 152 // menu rather than when you tap on the menu. |
| 148 setState(() { | 153 setState(() { |
| 149 _isShowingMenu = false; | 154 _menuController.close(); |
| 150 }); | 155 }); |
| 151 })); | 156 })); |
| 152 } | 157 } |
| 153 | 158 |
| 154 return new Container(key: 'StocksApp', children: children); | 159 return new Container(key: 'StocksApp', children: children); |
| 155 } | 160 } |
| 156 } | 161 } |
| OLD | NEW |