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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/examples/widgets/navigation.dart » ('j') | sky/sdk/lib/app/view.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/stocks2/lib/stock_app.dart
diff --git a/sky/examples/stocks2/lib/stock_app.dart b/sky/examples/stocks2/lib/stock_app.dart
index 1c450b02682fb75f735bc53d954cc653f201783e..1586b173553641236dc98eba56414eb8b965827a 100644
--- a/sky/examples/stocks2/lib/stock_app.dart
+++ b/sky/examples/stocks2/lib/stock_app.dart
@@ -14,19 +14,24 @@ class StocksApp extends App {
StocksApp({ RenderView renderViewOverride }) : super(renderViewOverride: renderViewOverride);
+ NavigationState _navState = new NavigationState([
+ new Route(name: '/', builder: (navigator) => new StockHome(navigator)),
+ new Route(name: '/settings', builder: (navigator) => new StockSettings(navigator)),
+ ]);
+
+ void onBack() {
+ if (_navState.hasPrevious()) {
+ setState(() {
+ _navState.pop();
+ });
+ return;
+ }
+ print ("Should exit app here");
+ // TODO(jackson): Need a way to invoke default back behavior here
+ }
+
Widget build() {
- return new Navigator(
- routes: [
- new Route(
- name: '/',
- builder: (navigator) => new StockHome(navigator)
- ),
- new Route(
- name: '/settings',
- builder: (navigator) => new StockSettings(navigator)
- ),
- ]
- );
+ return new Navigator(_navState);
}
}
« 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