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

Side by Side Diff: sky/examples/stocks2/lib/stock_app.dart

Issue 1190793002: Rename UINode to Widget. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 | « sky/examples/raw/navigation.dart ('k') | sky/examples/stocks2/lib/stock_arrow.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/editing2/input.dart'; 5 import 'package:sky/editing2/input.dart';
6 import 'package:sky/rendering/box.dart'; 6 import 'package:sky/rendering/box.dart';
7 import 'package:sky/rendering/paragraph.dart'; 7 import 'package:sky/rendering/paragraph.dart';
8 import 'package:sky/theme2/colors.dart' as colors; 8 import 'package:sky/theme2/colors.dart' as colors;
9 import 'package:sky/theme2/typography.dart' as typography; 9 import 'package:sky/theme2/typography.dart' as typography;
10 import 'package:sky/widgets/basic.dart'; 10 import 'package:sky/widgets/basic.dart';
11 import 'package:sky/widgets/drawer.dart'; 11 import 'package:sky/widgets/drawer.dart';
12 import 'package:sky/widgets/drawer_header.dart'; 12 import 'package:sky/widgets/drawer_header.dart';
13 import 'package:sky/widgets/floating_action_button.dart'; 13 import 'package:sky/widgets/floating_action_button.dart';
14 import 'package:sky/widgets/icon.dart'; 14 import 'package:sky/widgets/icon.dart';
15 import 'package:sky/widgets/icon_button.dart'; 15 import 'package:sky/widgets/icon_button.dart';
16 import 'package:sky/widgets/menu_divider.dart'; 16 import 'package:sky/widgets/menu_divider.dart';
17 import 'package:sky/widgets/menu_item.dart'; 17 import 'package:sky/widgets/menu_item.dart';
18 import 'package:sky/widgets/modal_overlay.dart'; 18 import 'package:sky/widgets/modal_overlay.dart';
19 import 'package:sky/widgets/popup_menu.dart'; 19 import 'package:sky/widgets/popup_menu.dart';
20 import 'package:sky/widgets/radio.dart'; 20 import 'package:sky/widgets/radio.dart';
21 import 'package:sky/widgets/scaffold.dart'; 21 import 'package:sky/widgets/scaffold.dart';
22 import 'package:sky/widgets/tool_bar.dart'; 22 import 'package:sky/widgets/tool_bar.dart';
23 import 'package:sky/widgets/ui_node.dart'; 23 import 'package:sky/widgets/widget.dart';
24 24
25 import 'stock_data.dart'; 25 import 'stock_data.dart';
26 import 'stock_list.dart'; 26 import 'stock_list.dart';
27 import 'stock_menu.dart'; 27 import 'stock_menu.dart';
28 28
29 enum StockMode { optimistic, pessimistic } 29 enum StockMode { optimistic, pessimistic }
30 30
31 class StocksApp extends App { 31 class StocksApp extends App {
32 32
33 List<Stock> _stocks = []; 33 List<Stock> _stocks = [];
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 icon: 'action/settings', 144 icon: 'action/settings',
145 children: [new Text('Settings')]), 145 children: [new Text('Settings')]),
146 new MenuItem( 146 new MenuItem(
147 key: 'Help & Feedback', 147 key: 'Help & Feedback',
148 icon: 'action/help', 148 icon: 'action/help',
149 children: [new Text('Help & Feedback')]) 149 children: [new Text('Help & Feedback')])
150 ] 150 ]
151 ); 151 );
152 } 152 }
153 153
154 UINode buildToolBar() { 154 Widget buildToolBar() {
155 return new ToolBar( 155 return new ToolBar(
156 left: new IconButton( 156 left: new IconButton(
157 icon: 'navigation/menu_white', 157 icon: 'navigation/menu_white',
158 onGestureTap: (_) => _drawerController.toggle()), 158 onGestureTap: (_) => _drawerController.toggle()),
159 center: new Text('Stocks', style: typography.white.title), 159 center: new Text('Stocks', style: typography.white.title),
160 right: [ 160 right: [
161 new IconButton( 161 new IconButton(
162 icon: 'action/search_white', 162 icon: 'action/search_white',
163 onGestureTap: _handleSearchBegin), 163 onGestureTap: _handleSearchBegin),
164 new IconButton( 164 new IconButton(
165 icon: 'navigation/more_vert_white', 165 icon: 'navigation/more_vert_white',
166 onGestureTap: _handleMenuShow) 166 onGestureTap: _handleMenuShow)
167 ], 167 ],
168 backgroundColor: colors.Purple[500] 168 backgroundColor: colors.Purple[500]
169 ); 169 );
170 } 170 }
171 171
172 // TODO(abarth): Should we factor this into a SearchBar in the framework? 172 // TODO(abarth): Should we factor this into a SearchBar in the framework?
173 UINode buildSearchBar() { 173 Widget buildSearchBar() {
174 return new ToolBar( 174 return new ToolBar(
175 left: new IconButton( 175 left: new IconButton(
176 icon: 'navigation/arrow_back_grey600', 176 icon: 'navigation/arrow_back_grey600',
177 onGestureTap: _handleSearchEnd), 177 onGestureTap: _handleSearchEnd),
178 center: new Input( 178 center: new Input(
179 focused: true, 179 focused: true,
180 placeholder: 'Search stocks', 180 placeholder: 'Search stocks',
181 onChanged: _handleSearchQueryChanged), 181 onChanged: _handleSearchQueryChanged),
182 backgroundColor: colors.Grey[50] 182 backgroundColor: colors.Grey[50]
183 ); 183 );
184 } 184 }
185 185
186 void addMenuToOverlays(List<UINode> overlays) { 186 void addMenuToOverlays(List<Widget> overlays) {
187 if (_menuController == null) 187 if (_menuController == null)
188 return; 188 return;
189 overlays.add(new ModalOverlay( 189 overlays.add(new ModalOverlay(
190 children: [new StockMenu( 190 children: [new StockMenu(
191 controller: _menuController, 191 controller: _menuController,
192 autorefresh: _autorefresh, 192 autorefresh: _autorefresh,
193 onAutorefreshChanged: _handleAutorefreshChanged 193 onAutorefreshChanged: _handleAutorefreshChanged
194 )], 194 )],
195 onDismiss: _handleMenuHide)); 195 onDismiss: _handleMenuHide));
196 } 196 }
197 197
198 UINode build() { 198 Widget build() {
199 List<UINode> overlays = [ 199 List<Widget> overlays = [
200 new Scaffold( 200 new Scaffold(
201 toolbar: _isSearching ? buildSearchBar() : buildToolBar(), 201 toolbar: _isSearching ? buildSearchBar() : buildToolBar(),
202 body: new Stocklist(stocks: _stocks, query: _searchQuery), 202 body: new Stocklist(stocks: _stocks, query: _searchQuery),
203 floatingActionButton: new FloatingActionButton( 203 floatingActionButton: new FloatingActionButton(
204 child: new Icon(type: 'content/add_white', size: 24) 204 child: new Icon(type: 'content/add_white', size: 24)
205 ), 205 ),
206 drawer: _drawerShowing ? buildDrawer() : null 206 drawer: _drawerShowing ? buildDrawer() : null
207 ), 207 ),
208 ]; 208 ];
209 addMenuToOverlays(overlays); 209 addMenuToOverlays(overlays);
210 return new Stack(overlays); 210 return new Stack(overlays);
211 } 211 }
212 } 212 }
213 213
214 void main() { 214 void main() {
215 print("starting stocks app!"); 215 print("starting stocks app!");
216 App app = new StocksApp(); 216 App app = new StocksApp();
217 UINodeAppView.appView.onFrame = () { 217 WidgetAppView.appView.onFrame = () {
218 // uncomment this for debugging: 218 // uncomment this for debugging:
219 // UINodeAppView.appView.debugDumpRenderTree(); 219 // WidgetAppView.appView.debugDumpRenderTree();
220 }; 220 };
221 } 221 }
OLDNEW
« no previous file with comments | « sky/examples/raw/navigation.dart ('k') | sky/examples/stocks2/lib/stock_arrow.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698