| 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 'basic.dart'; | 5 import 'basic.dart'; |
| 6 | 6 |
| 7 typedef Widget Builder(Navigator navigator, RouteBase route); | 7 typedef Widget Builder(Navigator navigator, RouteBase route); |
| 8 | 8 |
| 9 abstract class RouteBase { | 9 abstract class RouteBase { |
| 10 RouteBase({ this.name }); | 10 RouteBase({ this.name }); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 void pop() { | 68 void pop() { |
| 69 if (historyIndex > 0) { | 69 if (historyIndex > 0) { |
| 70 history[historyIndex].popState(); | 70 history[historyIndex].popState(); |
| 71 history.removeLast(); | 71 history.removeLast(); |
| 72 historyIndex--; | 72 historyIndex--; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 class Navigator extends Component { | 77 class Navigator extends StatefulComponent { |
| 78 | 78 |
| 79 Navigator(this.state, { String key }) : super(key: key, stateful: true); | 79 Navigator(this.state, { String key }) : super(key: key); |
| 80 | 80 |
| 81 NavigationState state; | 81 NavigationState state; |
| 82 | 82 |
| 83 void syncFields(Navigator source) { | 83 void syncFields(Navigator source) { |
| 84 state = source.state; | 84 state = source.state; |
| 85 } | 85 } |
| 86 | 86 |
| 87 RouteBase get currentRoute => state.currentRoute; | 87 RouteBase get currentRoute => state.currentRoute; |
| 88 | 88 |
| 89 void pushState(String name, Function callback) { | 89 void pushState(String name, Function callback) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 110 void pop() { | 110 void pop() { |
| 111 setState(() { | 111 setState(() { |
| 112 state.pop(); | 112 state.pop(); |
| 113 }); | 113 }); |
| 114 } | 114 } |
| 115 | 115 |
| 116 Widget build() { | 116 Widget build() { |
| 117 return state.currentRoute.build(this, state.currentRoute); | 117 return state.currentRoute.build(this, state.currentRoute); |
| 118 } | 118 } |
| 119 } | 119 } |
| OLD | NEW |