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 import 'stock_menu.dart'; |
18 | 18 |
19 class StocksApp extends App { | 19 class StocksApp extends App { |
20 | 20 |
21 DrawerAnimation _drawerAnimation = new DrawerAnimation(); | 21 DrawerController _DrawerController = new DrawerController(); |
22 | 22 |
23 static Style _style = new Style(''' | 23 static Style _style = new Style(''' |
24 display: flex; | 24 display: flex; |
25 flex-direction: column; | 25 flex-direction: column; |
26 height: -webkit-fill-available; | 26 height: -webkit-fill-available; |
27 ${typography.typeface}; | 27 ${typography.typeface}; |
28 ${typography.black.body1};''' | 28 ${typography.black.body1};''' |
29 ); | 29 ); |
30 | 30 |
31 static Style _iconStyle = new Style(''' | 31 static Style _iconStyle = new Style(''' |
(...skipping 29 matching lines...) Expand all Loading... |
61 } | 61 } |
62 | 62 |
63 void _handleSearchQueryChanged(query) { | 63 void _handleSearchQueryChanged(query) { |
64 setState(() { | 64 setState(() { |
65 _searchQuery = query; | 65 _searchQuery = query; |
66 }); | 66 }); |
67 } | 67 } |
68 | 68 |
69 Node build() { | 69 Node build() { |
70 var drawer = new Drawer( | 70 var drawer = new Drawer( |
71 animation: _drawerAnimation, | 71 controller: _DrawerController, |
72 level: 3, | 72 level: 3, |
73 children: [ | 73 children: [ |
74 new DrawerHeader( | 74 new DrawerHeader( |
75 children: [new Text('Stocks')] | 75 children: [new Text('Stocks')] |
76 ), | 76 ), |
77 new MenuItem( | 77 new MenuItem( |
78 key: 'Inbox', | 78 key: 'Inbox', |
79 icon: 'content/inbox', | 79 icon: 'content/inbox', |
80 children: [new Text('Inbox')] | 80 children: [new Text('Inbox')] |
81 ), | 81 ), |
(...skipping 23 matching lines...) Expand all Loading... |
105 onChanged: _handleSearchQueryChanged); | 105 onChanged: _handleSearchQueryChanged); |
106 } else { | 106 } else { |
107 title = new Text('Stocks'); | 107 title = new Text('Stocks'); |
108 } | 108 } |
109 | 109 |
110 var toolbar = new ActionBar( | 110 var toolbar = new ActionBar( |
111 children: [ | 111 children: [ |
112 new Icon(key: 'menu', style: _iconStyle, | 112 new Icon(key: 'menu', style: _iconStyle, |
113 size: 24, | 113 size: 24, |
114 type: 'navigation/menu_white') | 114 type: 'navigation/menu_white') |
115 ..events.listen('gesturetap', _drawerAnimation.toggle), | 115 ..events.listen('gesturetap', _DrawerController.toggle), |
116 new Container( | 116 new Container( |
117 style: _titleStyle, | 117 style: _titleStyle, |
118 children: [title] | 118 children: [title] |
119 ), | 119 ), |
120 new Icon(key: 'search', style: _iconStyle, | 120 new Icon(key: 'search', style: _iconStyle, |
121 size: 24, | 121 size: 24, |
122 type: 'action/search_white') | 122 type: 'action/search_white') |
123 ..events.listen('gesturetap', _handleSearchClick), | 123 ..events.listen('gesturetap', _handleSearchClick), |
124 new Icon(key: 'more_white', style: _iconStyle, | 124 new Icon(key: 'more_white', style: _iconStyle, |
125 size: 24, | 125 size: 24, |
(...skipping 10 matching lines...) Expand all Loading... |
136 var children = [ | 136 var children = [ |
137 new Container( | 137 new Container( |
138 key: 'Content', | 138 key: 'Content', |
139 style: _style, | 139 style: _style, |
140 children: [toolbar, list] | 140 children: [toolbar, list] |
141 ), | 141 ), |
142 fab, | 142 fab, |
143 drawer | 143 drawer |
144 ]; | 144 ]; |
145 | 145 |
146 if (_isShowingMenu) | 146 if (_isShowingMenu) { |
147 children.add(new StockMenu()); | 147 children.add(new StockMenu()..events.listen('gesturetap', (_) { |
| 148 setState(() { |
| 149 _isShowingMenu = false; |
| 150 }); |
| 151 })); |
| 152 } |
148 | 153 |
149 return new Container(key: 'StocksApp', children: children); | 154 return new Container(key: 'StocksApp', children: children); |
150 } | 155 } |
151 } | 156 } |
OLD | NEW |