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

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

Issue 1027813002: Introduce Scaffold to Sky framework (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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
« no previous file with comments | « no previous file | sky/framework/components/drawer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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';
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/components/popup_menu.dart';
14 import 'package:sky/framework/components/scaffold.dart';
14 import 'package:sky/framework/fn.dart'; 15 import 'package:sky/framework/fn.dart';
15 import 'package:sky/framework/theme/typography.dart' as typography; 16 import 'package:sky/framework/theme/typography.dart' as typography;
16 import 'stock_data.dart'; 17 import 'stock_data.dart';
17 import 'stock_list.dart'; 18 import 'stock_list.dart';
18 import 'stock_menu.dart'; 19 import 'stock_menu.dart';
19 20
20 class StocksApp extends App { 21 class StocksApp extends App {
21 22
22 DrawerController _drawerController = new DrawerController(); 23 DrawerController _drawerController = new DrawerController();
23 PopupMenuController _menuController; 24 PopupMenuController _menuController;
24 25
25 static Style _style = new Style('''
26 display: flex;
27 flex-direction: column;
28 height: -webkit-fill-available;
29 ${typography.typeface};
30 ${typography.black.body1};'''
31 );
32
33 static Style _iconStyle = new Style(''' 26 static Style _iconStyle = new Style('''
34 padding: 8px;''' 27 padding: 8px;'''
35 ); 28 );
36 29
37 static Style _titleStyle = new Style(''' 30 static Style _titleStyle = new Style('''
38 padding-left: 24px; 31 padding-left: 24px;
39 flex: 1; 32 flex: 1;
40 ${typography.white.title};''' 33 ${typography.white.title};'''
41 ); 34 );
42 35
43 static Style _stocklistHeight = new Style('''
44 flex: 1;'''
45 );
46
47 List<Stock> _sortedStocks; 36 List<Stock> _sortedStocks;
48 bool _isSearching = false; 37 bool _isSearching = false;
49 bool _isShowingMenu = false; 38 bool _isShowingMenu = false;
50 String _searchQuery; 39 String _searchQuery;
51 40
52 StocksApp() : super() { 41 StocksApp() : super() {
53 _sortedStocks = oracle.stocks; 42 _sortedStocks = oracle.stocks;
54 _sortedStocks.sort((a, b) => a.symbol.compareTo(b.symbol)); 43 _sortedStocks.sort((a, b) => a.symbol.compareTo(b.symbol));
55 } 44 }
56 45
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 ); 96 );
108 97
109 Node title; 98 Node title;
110 if (_isSearching) { 99 if (_isSearching) {
111 title = new Input(focused: true, placeholder: 'Search stocks', 100 title = new Input(focused: true, placeholder: 'Search stocks',
112 onChanged: _handleSearchQueryChanged); 101 onChanged: _handleSearchQueryChanged);
113 } else { 102 } else {
114 title = new Text('Stocks'); 103 title = new Text('Stocks');
115 } 104 }
116 105
117 var toolbar = new ActionBar( 106 var actionBar = new ActionBar(
118 children: [ 107 children: [
119 new EventTarget( 108 new EventTarget(
120 new Icon(key: 'menu', style: _iconStyle, 109 new Icon(key: 'menu', style: _iconStyle,
121 size: 24, 110 size: 24,
122 type: 'navigation/menu_white'), 111 type: 'navigation/menu_white'),
123 onGestureTap: _drawerController.toggle 112 onGestureTap: _drawerController.toggle
124 ), 113 ),
125 new Container( 114 new Container(
126 style: _titleStyle, 115 style: _titleStyle,
127 children: [title] 116 children: [title]
128 ), 117 ),
129 new EventTarget( 118 new EventTarget(
130 new Icon(key: 'search', style: _iconStyle, 119 new Icon(key: 'search', style: _iconStyle,
131 size: 24, 120 size: 24,
132 type: 'action/search_white'), 121 type: 'action/search_white'),
133 onGestureTap: _handleSearchClick 122 onGestureTap: _handleSearchClick
134 ), 123 ),
135 new EventTarget( 124 new EventTarget(
136 new Icon(key: 'more_white', style: _iconStyle, 125 new Icon(key: 'more_white', style: _iconStyle,
137 size: 24, 126 size: 24,
138 type: 'navigation/more_vert_white'), 127 type: 'navigation/more_vert_white'),
139 onGestureTap: _handleMenuClick 128 onGestureTap: _handleMenuClick
140 ) 129 )
141 ] 130 ]
142 ); 131 );
143 132
144 var list = new StyleNode( 133 List<Node> overlays = [];
145 new Stocklist(stocks: _sortedStocks, query: _searchQuery),
146 _stocklistHeight);
147
148 var fab = new FloatingActionButton(content: new Icon(
149 type: 'content/add_white', size: 24), level: 3);
150
151 var children = [
152 new Container(
153 key: 'Content',
154 style: _style,
155 children: [toolbar, list]
156 ),
157 fab,
158 drawer
159 ];
160 134
161 if (_menuController != null) { 135 if (_menuController != null) {
162 var menu = new EventTarget( 136 overlays.add(new EventTarget(
163 new StockMenu(controller: _menuController), 137 new StockMenu(controller: _menuController),
164 onGestureTap: (_) { 138 onGestureTap: (_) {
165 // TODO(abarth): We should close the menu when you tap away from the 139 // TODO(abarth): We should close the menu when you tap away from the
166 // menu rather than when you tap on the menu. 140 // menu rather than when you tap on the menu.
167 setState(() { 141 setState(() {
168 _menuController.close(); 142 _menuController.close();
169 _menuController = null; 143 _menuController = null;
170 }); 144 });
171 } 145 }
172 ); 146 ));
173 children.add(menu);
174 } 147 }
175 148
176 return new Container(key: 'StocksApp', children: children); 149 return new Scaffold(
150 actionBar: actionBar,
151 content: new Stocklist(stocks: _sortedStocks, query: _searchQuery),
152 fab: new FloatingActionButton(
153 content: new Icon(type: 'content/add_white', size: 24), level: 3),
154 drawer: drawer,
155 overlays: overlays
156 );
177 } 157 }
178 } 158 }
OLDNEW
« no previous file with comments | « no previous file | sky/framework/components/drawer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698