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

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: abarth feedback 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 | « no previous file | sky/examples/stocks2/lib/stock_home.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/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 _navigationState = new NavigationState([
17 new Route(name: '/settings', builder: (navigator) => new StockSettings(navig ator)), 18 new Route(
18 ]); 19 name: '/',
20 builder: (navigator, route) => new StockHome(navigator, route, _stocks)
21 ),
22 new Route(
23 name: '/settings',
24 builder: (navigator, route) => new StockSettings(navigator)
25 ),
26 ]);
27 }
28
29 void didMount() {
30 new StockDataFetcher((StockData data) {
31 setState(() {
32 data.appendTo(_stocks);
33 });
34 });
35 }
36
37 final List<Stock> _stocks = [];
38 NavigationState _navigationState;
19 39
20 void onBack() { 40 void onBack() {
21 if (_navState.hasPrevious()) { 41 setState(() {
22 setState(() { 42 _navigationState.pop();
23 _navState.pop(); 43 });
24 });
25 return;
26 }
27 print ("Should exit app here");
28 // TODO(jackson): Need a way to invoke default back behavior here 44 // TODO(jackson): Need a way to invoke default back behavior here
29 } 45 }
30 46
31 Widget build() { 47 Widget build() {
32 return new Navigator(_navState); 48 return new Navigator(_navigationState);
33 } 49 }
34 } 50 }
35 51
36 void main() { 52 void main() {
37 print("starting stocks app!"); 53 print("starting stocks app!");
38 runApp(new StocksApp()); 54 runApp(new StocksApp());
39 SkyBinding.instance.onFrame = () { 55 SkyBinding.instance.onFrame = () {
40 // uncomment this for debugging: 56 // uncomment this for debugging:
41 // SkyBinding.instance.debugDumpRenderTree(); 57 // SkyBinding.instance.debugDumpRenderTree();
42 }; 58 };
43 } 59 }
OLDNEW
« no previous file with comments | « no previous file | sky/examples/stocks2/lib/stock_home.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698