From cc76b90450a27f36a373d9c2e346b184e63851a8 Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Tue, 16 Jun 2015 16:14:55 -0700 Subject: [PATCH] Add back/forward history to navigation R=abarth@chromium.org, abarth, hixie Review URL: https://codereview.chromium.org/1181773006. --- examples/widgets/navigation.dart | 59 +++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/examples/widgets/navigation.dart b/examples/widgets/navigation.dart index 86b1dfe4708..ca81a4fbd79 100644 --- a/examples/widgets/navigation.dart +++ b/examples/widgets/navigation.dart @@ -4,28 +4,69 @@ import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/navigator.dart'; +import 'package:sky/widgets/transition.dart'; import 'package:sky/widgets/raised_button.dart'; List routes = [ new Route( - name: 'safety', - builder: (navigator) => new RaisedButton( - child: new Text('PRESS FORWARD'), - onPressed: () => navigator.pushNamedRoute('adventure') + name: 'home', + builder: (navigator) => new Container( + padding: const EdgeDims.all(20.0), + decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)), + child: new Block([ + new Text("You are at home"), + new RaisedButton( + key: 'b', + child: new Text('GO SHOPPING'), + onPressed: () => navigator.pushNamed('shopping') + ), + new RaisedButton( + key: 'a', + child: new Text('START ADVENTURE'), + onPressed: () => navigator.pushNamed('adventure') + ) + ]) + ) + ), + new Route( + name: 'shopping', + builder: (navigator) => new Container( + padding: const EdgeDims.all(20.0), + decoration: new BoxDecoration(backgroundColor: const Color(0xFFBF5FFF)), + child: new Block([ + new Text("Village Shop"), + new RaisedButton( + key: 'a', + child: new Text('RETURN HOME'), + onPressed: () => navigator.back() + ), + new RaisedButton( + key: 'b', + child: new Text('GO TO DUNGEON'), + onPressed: () => navigator.push(routes[2]) + ) + ]) ) ), new Route( name: 'adventure', - builder: (navigator) => new RaisedButton( - child: new Text('NO WAIT! GO BACK!'), - onPressed: () => navigator.pushRoute(routes[0]) + builder: (navigator) => new Container( + padding: const EdgeDims.all(20.0), + decoration: new BoxDecoration(backgroundColor: const Color(0xFFDC143C)), + child: new Block([ + new Text("Monster's Lair"), + new RaisedButton( + child: new Text('NO WAIT! GO BACK!'), + onPressed: () => navigator.pop() + ) + ]) ) ) ]; class NavigationExampleApp extends App { - UINode build() { - return new Navigator(routes: routes); + Widget build() { + return new Flex([new Navigator(routes: routes)]); } }