OLD | NEW |
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 } |
OLD | NEW |