mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add back/forward history to navigation
R=abarth@chromium.org, abarth, hixie Review URL: https://codereview.chromium.org/1181773006.
This commit is contained in:
parent
db90d5f046
commit
cc76b90450
@ -4,28 +4,69 @@
|
|||||||
|
|
||||||
import 'package:sky/widgets/basic.dart';
|
import 'package:sky/widgets/basic.dart';
|
||||||
import 'package:sky/widgets/navigator.dart';
|
import 'package:sky/widgets/navigator.dart';
|
||||||
|
import 'package:sky/widgets/transition.dart';
|
||||||
import 'package:sky/widgets/raised_button.dart';
|
import 'package:sky/widgets/raised_button.dart';
|
||||||
|
|
||||||
List<Route> routes = [
|
List<Route> routes = [
|
||||||
new Route(
|
new Route(
|
||||||
name: 'safety',
|
name: 'home',
|
||||||
builder: (navigator) => new RaisedButton(
|
builder: (navigator) => new Container(
|
||||||
child: new Text('PRESS FORWARD'),
|
padding: const EdgeDims.all(20.0),
|
||||||
onPressed: () => navigator.pushNamedRoute('adventure')
|
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(
|
new Route(
|
||||||
name: 'adventure',
|
name: 'adventure',
|
||||||
builder: (navigator) => new RaisedButton(
|
builder: (navigator) => new Container(
|
||||||
child: new Text('NO WAIT! GO BACK!'),
|
padding: const EdgeDims.all(20.0),
|
||||||
onPressed: () => navigator.pushRoute(routes[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 {
|
class NavigationExampleApp extends App {
|
||||||
UINode build() {
|
Widget build() {
|
||||||
return new Navigator(routes: routes);
|
return new Flex([new Navigator(routes: routes)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user