mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #1367 from abarth/update_navigation_example
Update navigation example
This commit is contained in:
commit
6ea83f11c8
@ -244,13 +244,11 @@ class FeedFragment extends StatefulComponent {
|
||||
});
|
||||
}
|
||||
|
||||
Anchor _snackBarAnchor = new Anchor();
|
||||
Widget buildSnackBar() {
|
||||
if (_snackBarStatus == AnimationStatus.dismissed)
|
||||
return null;
|
||||
return new SnackBar(
|
||||
showing: _isShowingSnackBar,
|
||||
anchor: _snackBarAnchor,
|
||||
content: new Text("Item deleted."),
|
||||
actions: [new SnackBarAction(label: "UNDO", onPressed: _handleUndo)],
|
||||
onDismissed: () { setState(() { _snackBarStatus = AnimationStatus.dismissed; }); }
|
||||
@ -267,11 +265,10 @@ class FeedFragment extends StatefulComponent {
|
||||
Widget buildFloatingActionButton() {
|
||||
switch (_fitnessMode) {
|
||||
case FitnessMode.feed:
|
||||
return _snackBarAnchor.build(
|
||||
new FloatingActionButton(
|
||||
child: new Icon(type: 'content/add', size: 24),
|
||||
onPressed: _handleActionButtonPressed
|
||||
));
|
||||
return new FloatingActionButton(
|
||||
child: new Icon(type: 'content/add', size: 24),
|
||||
onPressed: _handleActionButtonPressed
|
||||
);
|
||||
case FitnessMode.chart:
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -2,87 +2,65 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:sky/material.dart';
|
||||
import 'package:sky/src/fn3.dart';
|
||||
|
||||
List<Route> routes = [
|
||||
new Route(
|
||||
name: 'home',
|
||||
builder: (navigator, route) => new Container(
|
||||
padding: const EdgeDims.all(30.0),
|
||||
decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)),
|
||||
child: new Column([
|
||||
new Text("You are at home"),
|
||||
new RaisedButton(
|
||||
child: new Text('GO SHOPPING'),
|
||||
onPressed: () => navigator.pushNamed('shopping')
|
||||
),
|
||||
new RaisedButton(
|
||||
child: new Text('START ADVENTURE'),
|
||||
onPressed: () => navigator.pushNamed('adventure')
|
||||
)],
|
||||
justifyContent: FlexJustifyContent.center
|
||||
)
|
||||
final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
|
||||
'/': (NavigatorState navigator, Route route) => new Container(
|
||||
padding: const EdgeDims.all(30.0),
|
||||
decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)),
|
||||
child: new Column([
|
||||
new Text("You are at home"),
|
||||
new RaisedButton(
|
||||
child: new Text('GO SHOPPING'),
|
||||
onPressed: () => navigator.pushNamed('/shopping')
|
||||
),
|
||||
new RaisedButton(
|
||||
child: new Text('START ADVENTURE'),
|
||||
onPressed: () => navigator.pushNamed('/adventure')
|
||||
)],
|
||||
justifyContent: FlexJustifyContent.center
|
||||
)
|
||||
),
|
||||
new Route(
|
||||
name: 'shopping',
|
||||
builder: (navigator, route) => new Container(
|
||||
padding: const EdgeDims.all(20.0),
|
||||
decoration: new BoxDecoration(backgroundColor: const Color(0xFFBF5FFF)),
|
||||
child: new Column([
|
||||
new Text("Village Shop"),
|
||||
new RaisedButton(
|
||||
child: new Text('RETURN HOME'),
|
||||
onPressed: () => navigator.pop()
|
||||
),
|
||||
new RaisedButton(
|
||||
child: new Text('GO TO DUNGEON'),
|
||||
onPressed: () => navigator.push(routes[2])
|
||||
)],
|
||||
justifyContent: FlexJustifyContent.center
|
||||
)
|
||||
'/shopping': (NavigatorState navigator, Route route) => new Container(
|
||||
padding: const EdgeDims.all(20.0),
|
||||
decoration: new BoxDecoration(backgroundColor: const Color(0xFFBF5FFF)),
|
||||
child: new Column([
|
||||
new Text("Village Shop"),
|
||||
new RaisedButton(
|
||||
child: new Text('RETURN HOME'),
|
||||
onPressed: () => navigator.pop()
|
||||
),
|
||||
new RaisedButton(
|
||||
child: new Text('GO TO DUNGEON'),
|
||||
onPressed: () => navigator.pushNamed('/adventure')
|
||||
)],
|
||||
justifyContent: FlexJustifyContent.center
|
||||
)
|
||||
),
|
||||
new Route(
|
||||
name: 'adventure',
|
||||
builder: (navigator, route) => new Container(
|
||||
padding: const EdgeDims.all(20.0),
|
||||
decoration: new BoxDecoration(backgroundColor: const Color(0xFFDC143C)),
|
||||
child: new Column([
|
||||
new Text("Monster's Lair"),
|
||||
new RaisedButton(
|
||||
child: new Text('RUN!!!'),
|
||||
onPressed: () => navigator.pop()
|
||||
)],
|
||||
justifyContent: FlexJustifyContent.center
|
||||
)
|
||||
'/adventure': (NavigatorState navigator, Route route) => new Container(
|
||||
padding: const EdgeDims.all(20.0),
|
||||
decoration: new BoxDecoration(backgroundColor: const Color(0xFFDC143C)),
|
||||
child: new Column([
|
||||
new Text("Monster's Lair"),
|
||||
new RaisedButton(
|
||||
child: new Text('RUN!!!'),
|
||||
onPressed: () => navigator.pop()
|
||||
)],
|
||||
justifyContent: FlexJustifyContent.center
|
||||
)
|
||||
)
|
||||
];
|
||||
};
|
||||
|
||||
class NavigationExampleApp extends StatefulComponent {
|
||||
NavigationExampleAppState createState() => new NavigationExampleAppState();
|
||||
}
|
||||
|
||||
class NavigationExampleAppState extends State<NavigationExampleApp> {
|
||||
NavigatorHistory _history = new NavigatorHistory(routes);
|
||||
|
||||
void onBack() {
|
||||
if (_history.hasPrevious()) {
|
||||
setState(() {
|
||||
_history.pop();
|
||||
});
|
||||
} else {
|
||||
// TODO(abarth): Integrate with the system navigator.
|
||||
// super.onBack();
|
||||
}
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return new Row([new Navigator(_history)]);
|
||||
}
|
||||
}
|
||||
final ThemeData theme = new ThemeData(
|
||||
brightness: ThemeBrightness.light,
|
||||
primarySwatch: Colors.purple
|
||||
);
|
||||
|
||||
void main() {
|
||||
runApp(new NavigationExampleApp());
|
||||
runApp(new App(
|
||||
title: 'Navigation Example',
|
||||
theme: theme,
|
||||
routes: routes
|
||||
));
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ export 'fn3/ink_well.dart';
|
||||
export 'fn3/input.dart';
|
||||
export 'fn3/material.dart';
|
||||
export 'fn3/material_button.dart';
|
||||
export 'fn3/mimic.dart';
|
||||
export 'fn3/mixed_viewport.dart';
|
||||
export 'fn3/navigator.dart';
|
||||
export 'fn3/popup_menu.dart';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user