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

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

Issue 1191153002: Make back button control drawer in stocks app (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix analyzer warnings 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
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/rendering/sky_binding.dart'; 5 import 'package:sky/rendering/sky_binding.dart';
6 import 'package:sky/widgets/basic.dart'; 6 import 'package:sky/widgets/basic.dart';
7 import 'package:sky/widgets/navigator.dart'; 7 import 'package:sky/widgets/navigator.dart';
8 import 'package:sky/widgets/widget.dart'; 8 import 'package:sky/widgets/widget.dart';
9 9
10 import 'stock_data.dart';
10 import 'stock_home.dart'; 11 import 'stock_home.dart';
11 import 'stock_settings.dart'; 12 import 'stock_settings.dart';
12 13
13 class StocksApp extends App { 14 class StocksApp extends App {
14 15
15 NavigationState _navState = new NavigationState([ 16 StocksApp() {
16 new Route(name: '/', builder: (navigator) => new StockHome(navigator)), 17 new StockDataFetcher((StockData data) {
17 new Route(name: '/settings', builder: (navigator) => new StockSettings(navig ator)), 18 setState(() {
18 ]); 19 data.appendTo(_stocks);
20 });
abarth-chromium 2015/06/18 22:23:59 Technically we should do this stock fetcher stuff
21 });
22 _navState = new NavigationState([
abarth-chromium 2015/06/18 22:23:59 s/_navState/_navigationState/ Please use complete
23 new Route(
24 name: '/',
25 builder: (navigator, route) => new StockHome(navigator, route, _stocks)
26 ),
27 new Route(
28 name: '/settings',
29 builder: (navigator, route) => new StockSettings(navigator)
30 ),
31 ]);
32 }
33
34 final List<Stock> _stocks = [];
35 NavigationState _navState;
19 36
20 void onBack() { 37 void onBack() {
21 if (_navState.hasPrevious()) { 38 setState(() {
22 setState(() { 39 _navState.pop();
23 _navState.pop(); 40 });
24 });
25 return;
26 }
27 print ("Should exit app here");
28 // TODO(jackson): Need a way to invoke default back behavior here 41 // TODO(jackson): Need a way to invoke default back behavior here
29 } 42 }
30 43
31 Widget build() { 44 Widget build() {
32 return new Navigator(_navState); 45 return new Navigator(_navState);
33 } 46 }
34 } 47 }
35 48
36 void main() { 49 void main() {
37 print("starting stocks app!"); 50 print("starting stocks app!");
38 runApp(new StocksApp()); 51 runApp(new StocksApp());
39 SkyBinding.instance.onFrame = () { 52 SkyBinding.instance.onFrame = () {
40 // uncomment this for debugging: 53 // uncomment this for debugging:
41 // SkyBinding.instance.debugDumpRenderTree(); 54 // SkyBinding.instance.debugDumpRenderTree();
42 }; 55 };
43 } 56 }
OLDNEW
« no previous file with comments | « no previous file | sky/examples/stocks2/lib/stock_home.dart » ('j') | sky/examples/stocks2/lib/stock_home.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698