Commit a54f7cf2 authored by Collin Jackson's avatar Collin Jackson

Fix bug when having more than 2 routes

parent e075988f
...@@ -46,7 +46,13 @@ const Duration _kTransitionDuration = const Duration(milliseconds: 200); ...@@ -46,7 +46,13 @@ const Duration _kTransitionDuration = const Duration(milliseconds: 200);
const Point _kTransitionStartPoint = const Point(0.0, 100.0); const Point _kTransitionStartPoint = const Point(0.0, 100.0);
enum TransitionDirection { forward, reverse } enum TransitionDirection { forward, reverse }
class Transition extends AnimatedComponent { class Transition extends AnimatedComponent {
Transition({ this.content, this.direction, this.onDismissed, this.interactive }); Transition({
String key,
this.content,
this.direction,
this.onDismissed,
this.interactive
}) : super(key: key);
Widget content; Widget content;
TransitionDirection direction; TransitionDirection direction;
bool interactive; bool interactive;
...@@ -206,6 +212,7 @@ class Navigator extends StatefulComponent { ...@@ -206,6 +212,7 @@ class Navigator extends StatefulComponent {
Widget build() { Widget build() {
List<Widget> visibleRoutes = new List<Widget>(); List<Widget> visibleRoutes = new List<Widget>();
for (int i = 0; i < state.history.length; i++) { for (int i = 0; i < state.history.length; i++) {
// TODO(jackson): Avoid building routes that are not visible
HistoryEntry historyEntry = state.history[i]; HistoryEntry historyEntry = state.history[i];
Widget content = historyEntry.route.build(this, historyEntry.route); Widget content = historyEntry.route.build(this, historyEntry.route);
if (i == 0) { if (i == 0) {
...@@ -214,7 +221,8 @@ class Navigator extends StatefulComponent { ...@@ -214,7 +221,8 @@ class Navigator extends StatefulComponent {
} }
if (content == null) if (content == null)
continue; continue;
Transition transition = new Transition(content: content) String key = historyEntry.route.key;
Transition transition = new Transition(content: content, key: key)
..direction = (i <= state.historyIndex) ? TransitionDirection.forward : TransitionDirection.reverse ..direction = (i <= state.historyIndex) ? TransitionDirection.forward : TransitionDirection.reverse
..interactive = (i == state.historyIndex) ..interactive = (i == state.historyIndex)
..onDismissed = () { ..onDismissed = () {
......
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