Commit 2460ce37 authored by Collin Jackson's avatar Collin Jackson

Refactor Navigator to put state in separate class, initial back button plumbing

R=abarth@chromium.org, abarth

Review URL: https://codereview.chromium.org/1195493002.
parent 40e7ecbf
......@@ -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);
}
}
......
......@@ -65,8 +65,10 @@ List<Route> routes = [
];
class NavigationExampleApp extends App {
NavigationState _navState = new NavigationState(routes);
Widget build() {
return new Flex([new Navigator(routes: routes)]);
return new Flex([new Navigator(_navState)]);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment