Commit 6ea83f11 authored by Adam Barth's avatar Adam Barth

Merge pull request #1367 from abarth/update_navigation_example

Update navigation example
parents fb58141d 1424f351
...@@ -244,13 +244,11 @@ class FeedFragment extends StatefulComponent { ...@@ -244,13 +244,11 @@ class FeedFragment extends StatefulComponent {
}); });
} }
Anchor _snackBarAnchor = new Anchor();
Widget buildSnackBar() { Widget buildSnackBar() {
if (_snackBarStatus == AnimationStatus.dismissed) if (_snackBarStatus == AnimationStatus.dismissed)
return null; return null;
return new SnackBar( return new SnackBar(
showing: _isShowingSnackBar, showing: _isShowingSnackBar,
anchor: _snackBarAnchor,
content: new Text("Item deleted."), content: new Text("Item deleted."),
actions: [new SnackBarAction(label: "UNDO", onPressed: _handleUndo)], actions: [new SnackBarAction(label: "UNDO", onPressed: _handleUndo)],
onDismissed: () { setState(() { _snackBarStatus = AnimationStatus.dismissed; }); } onDismissed: () { setState(() { _snackBarStatus = AnimationStatus.dismissed; }); }
...@@ -267,11 +265,10 @@ class FeedFragment extends StatefulComponent { ...@@ -267,11 +265,10 @@ class FeedFragment extends StatefulComponent {
Widget buildFloatingActionButton() { Widget buildFloatingActionButton() {
switch (_fitnessMode) { switch (_fitnessMode) {
case FitnessMode.feed: case FitnessMode.feed:
return _snackBarAnchor.build( return new FloatingActionButton(
new FloatingActionButton(
child: new Icon(type: 'content/add', size: 24), child: new Icon(type: 'content/add', size: 24),
onPressed: _handleActionButtonPressed onPressed: _handleActionButtonPressed
)); );
case FitnessMode.chart: case FitnessMode.chart:
return null; return null;
} }
......
...@@ -2,31 +2,27 @@ ...@@ -2,31 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:sky/material.dart';
import 'package:sky/src/fn3.dart'; import 'package:sky/src/fn3.dart';
List<Route> routes = [ final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
new Route( '/': (NavigatorState navigator, Route route) => new Container(
name: 'home',
builder: (navigator, route) => new Container(
padding: const EdgeDims.all(30.0), padding: const EdgeDims.all(30.0),
decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)), decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)),
child: new Column([ child: new Column([
new Text("You are at home"), new Text("You are at home"),
new RaisedButton( new RaisedButton(
child: new Text('GO SHOPPING'), child: new Text('GO SHOPPING'),
onPressed: () => navigator.pushNamed('shopping') onPressed: () => navigator.pushNamed('/shopping')
), ),
new RaisedButton( new RaisedButton(
child: new Text('START ADVENTURE'), child: new Text('START ADVENTURE'),
onPressed: () => navigator.pushNamed('adventure') onPressed: () => navigator.pushNamed('/adventure')
)], )],
justifyContent: FlexJustifyContent.center justifyContent: FlexJustifyContent.center
) )
)
), ),
new Route( '/shopping': (NavigatorState navigator, Route route) => new Container(
name: 'shopping',
builder: (navigator, route) => new Container(
padding: const EdgeDims.all(20.0), padding: const EdgeDims.all(20.0),
decoration: new BoxDecoration(backgroundColor: const Color(0xFFBF5FFF)), decoration: new BoxDecoration(backgroundColor: const Color(0xFFBF5FFF)),
child: new Column([ child: new Column([
...@@ -37,15 +33,12 @@ List<Route> routes = [ ...@@ -37,15 +33,12 @@ List<Route> routes = [
), ),
new RaisedButton( new RaisedButton(
child: new Text('GO TO DUNGEON'), child: new Text('GO TO DUNGEON'),
onPressed: () => navigator.push(routes[2]) onPressed: () => navigator.pushNamed('/adventure')
)], )],
justifyContent: FlexJustifyContent.center justifyContent: FlexJustifyContent.center
) )
)
), ),
new Route( '/adventure': (NavigatorState navigator, Route route) => new Container(
name: 'adventure',
builder: (navigator, route) => new Container(
padding: const EdgeDims.all(20.0), padding: const EdgeDims.all(20.0),
decoration: new BoxDecoration(backgroundColor: const Color(0xFFDC143C)), decoration: new BoxDecoration(backgroundColor: const Color(0xFFDC143C)),
child: new Column([ child: new Column([
...@@ -57,32 +50,17 @@ List<Route> routes = [ ...@@ -57,32 +50,17 @@ List<Route> routes = [
justifyContent: FlexJustifyContent.center justifyContent: FlexJustifyContent.center
) )
) )
) };
];
class NavigationExampleApp extends StatefulComponent {
NavigationExampleAppState createState() => new NavigationExampleAppState();
}
class NavigationExampleAppState extends State<NavigationExampleApp> {
NavigatorHistory _history = new NavigatorHistory(routes);
void onBack() { final ThemeData theme = new ThemeData(
if (_history.hasPrevious()) { brightness: ThemeBrightness.light,
setState(() { primarySwatch: Colors.purple
_history.pop(); );
});
} else {
// TODO(abarth): Integrate with the system navigator.
// super.onBack();
}
}
Widget build(BuildContext context) {
return new Row([new Navigator(_history)]);
}
}
void main() { void main() {
runApp(new NavigationExampleApp()); runApp(new App(
title: 'Navigation Example',
theme: theme,
routes: routes
));
} }
...@@ -32,6 +32,7 @@ export 'fn3/ink_well.dart'; ...@@ -32,6 +32,7 @@ export 'fn3/ink_well.dart';
export 'fn3/input.dart'; export 'fn3/input.dart';
export 'fn3/material.dart'; export 'fn3/material.dart';
export 'fn3/material_button.dart'; export 'fn3/material_button.dart';
export 'fn3/mimic.dart';
export 'fn3/mixed_viewport.dart'; export 'fn3/mixed_viewport.dart';
export 'fn3/navigator.dart'; export 'fn3/navigator.dart';
export 'fn3/popup_menu.dart'; export 'fn3/popup_menu.dart';
......
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