OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 import 'package:sky/widgets/basic.dart'; | 5 import 'package:sky/widgets/basic.dart'; |
6 import 'package:sky/widgets/navigator.dart'; | 6 import 'package:sky/widgets/navigator.dart'; |
7 import 'package:sky/widgets/transition.dart'; | 7 import 'package:sky/widgets/transition.dart'; |
8 import 'package:sky/widgets/raised_button.dart'; | 8 import 'package:sky/widgets/raised_button.dart'; |
9 | 9 |
10 List<Route> routes = [ | 10 List<Route> routes = [ |
11 new Route( | 11 new Route( |
12 name: 'home', | 12 name: 'home', |
13 builder: (navigator) => new Container( | 13 builder: (navigator) => new Container( |
14 padding: const EdgeDims.all(20.0), | 14 padding: const EdgeDims.all(20.0), |
15 decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)), | 15 decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)), |
16 child: new Block([ | 16 child: new Block([ |
17 new Text("You are at home"), | 17 new Text("You are at home"), |
18 new RaisedButton( | 18 new RaisedButton( |
19 key: 'b', | |
20 child: new Text('GO SHOPPING'), | 19 child: new Text('GO SHOPPING'), |
21 onPressed: () => navigator.pushNamed('shopping') | 20 onPressed: () => navigator.pushNamed('shopping') |
22 ), | 21 ), |
23 new RaisedButton( | 22 new RaisedButton( |
24 key: 'a', | |
25 child: new Text('START ADVENTURE'), | 23 child: new Text('START ADVENTURE'), |
26 onPressed: () => navigator.pushNamed('adventure') | 24 onPressed: () => navigator.pushNamed('adventure') |
27 ) | 25 ) |
28 ]) | 26 ]) |
29 ) | 27 ) |
30 ), | 28 ), |
31 new Route( | 29 new Route( |
32 name: 'shopping', | 30 name: 'shopping', |
33 builder: (navigator) => new Container( | 31 builder: (navigator) => new Container( |
34 padding: const EdgeDims.all(20.0), | 32 padding: const EdgeDims.all(20.0), |
35 decoration: new BoxDecoration(backgroundColor: const Color(0xFFBF5FFF)), | 33 decoration: new BoxDecoration(backgroundColor: const Color(0xFFBF5FFF)), |
36 child: new Block([ | 34 child: new Block([ |
37 new Text("Village Shop"), | 35 new Text("Village Shop"), |
38 new RaisedButton( | 36 new RaisedButton( |
39 key: 'a', | |
40 child: new Text('RETURN HOME'), | 37 child: new Text('RETURN HOME'), |
41 onPressed: () => navigator.back() | 38 onPressed: () => navigator.back() |
42 ), | 39 ), |
43 new RaisedButton( | 40 new RaisedButton( |
44 key: 'b', | |
45 child: new Text('GO TO DUNGEON'), | 41 child: new Text('GO TO DUNGEON'), |
46 onPressed: () => navigator.push(routes[2]) | 42 onPressed: () => navigator.push(routes[2]) |
47 ) | 43 ) |
48 ]) | 44 ]) |
49 ) | 45 ) |
50 ), | 46 ), |
51 new Route( | 47 new Route( |
52 name: 'adventure', | 48 name: 'adventure', |
53 builder: (navigator) => new Container( | 49 builder: (navigator) => new Container( |
54 padding: const EdgeDims.all(20.0), | 50 padding: const EdgeDims.all(20.0), |
(...skipping 13 matching lines...) Expand all Loading... |
68 NavigationState _navState = new NavigationState(routes); | 64 NavigationState _navState = new NavigationState(routes); |
69 | 65 |
70 Widget build() { | 66 Widget build() { |
71 return new Flex([new Navigator(_navState)]); | 67 return new Flex([new Navigator(_navState)]); |
72 } | 68 } |
73 } | 69 } |
74 | 70 |
75 void main() { | 71 void main() { |
76 runApp(new NavigationExampleApp()); | 72 runApp(new NavigationExampleApp()); |
77 } | 73 } |
OLD | NEW |