Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Fix history collisions #77

Merged
merged 1 commit into from
Jul 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions sky/sdk/lib/widgets/navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ class Transition extends AnimatedComponent {
}

class HistoryEntry {
HistoryEntry(this.route);
HistoryEntry({ this.route, this.key });
final RouteBase route;
final int key;
// TODO(jackson): Keep track of the requested transition
}

Expand All @@ -142,11 +143,12 @@ class NavigationState {
if (route.name != null)
namedRoutes[route.name] = route;
}
history.add(new HistoryEntry(routes[0]));
history.add(new HistoryEntry(route: routes[0], key: _lastKey++));
}

List<HistoryEntry> history = new List<HistoryEntry>();
int historyIndex = 0;
int _lastKey = 0;
Map<String, RouteBase> namedRoutes = new Map<String, RouteBase>();

RouteBase get currentRoute => history[historyIndex].route;
Expand All @@ -159,7 +161,7 @@ class NavigationState {
}

void push(RouteBase route) {
HistoryEntry historyEntry = new HistoryEntry(route);
HistoryEntry historyEntry = new HistoryEntry(route: route, key: _lastKey++);
history.insert(historyIndex + 1, historyEntry);
historyIndex++;
}
Expand Down Expand Up @@ -224,9 +226,8 @@ class Navigator extends StatefulComponent {
}
if (content == null)
continue;
String key = historyEntry.route.key;
Transition transition = new Transition(
key: key,
key: historyEntry.key.toString(),
content: content,
direction: (i <= state.historyIndex) ? TransitionDirection.forward : TransitionDirection.reverse,
interactive: (i == state.historyIndex),
Expand Down