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

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

Issue 1195493002: Refactor Navigator to put state in separate class, initial back button plumbing (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: abarth CR 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/widgets/navigation.dart » ('j') | sky/sdk/lib/app/view.dart » ('J')
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/box.dart'; 5 import 'package:sky/rendering/box.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_home.dart'; 10 import 'stock_home.dart';
11 import 'stock_settings.dart'; 11 import 'stock_settings.dart';
12 12
13 class StocksApp extends App { 13 class StocksApp extends App {
14 14
15 StocksApp({ RenderView renderViewOverride }) : super(renderViewOverride: rende rViewOverride); 15 StocksApp({ RenderView renderViewOverride }) : super(renderViewOverride: rende rViewOverride);
16 16
17 NavigationState _navState = new NavigationState([
18 new Route(name: '/', builder: (navigator) => new StockHome(navigator)),
19 new Route(name: '/settings', builder: (navigator) => new StockSettings(navig ator)),
20 ]);
21
22 void onBack() {
23 if (_navState.hasPrevious()) {
24 setState(() {
25 _navState.pop();
26 });
27 return;
28 }
29 print ("Should exit app here");
30 // TODO(jackson): Need a way to invoke default back behavior here
31 }
32
17 Widget build() { 33 Widget build() {
18 return new Navigator( 34 return new Navigator(_navState);
19 routes: [
20 new Route(
21 name: '/',
22 builder: (navigator) => new StockHome(navigator)
23 ),
24 new Route(
25 name: '/settings',
26 builder: (navigator) => new StockSettings(navigator)
27 ),
28 ]
29 );
30 } 35 }
31 } 36 }
32 37
33 void main() { 38 void main() {
34 print("starting stocks app!"); 39 print("starting stocks app!");
35 App app = new StocksApp(); 40 App app = new StocksApp();
36 WidgetAppView.appView.onFrame = () { 41 WidgetAppView.appView.onFrame = () {
37 // uncomment this for debugging: 42 // uncomment this for debugging:
38 // WidgetAppView.appView.debugDumpRenderTree(); 43 // WidgetAppView.appView.debugDumpRenderTree();
39 }; 44 };
40 } 45 }
OLDNEW
« no previous file with comments | « no previous file | sky/examples/widgets/navigation.dart » ('j') | sky/sdk/lib/app/view.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698