account for changed itineraries once landmarks are marked as done or deleted

This commit is contained in:
2025-02-16 12:41:06 +01:00
parent 56c55883ea
commit 6f2f86f936
6 changed files with 135 additions and 110 deletions

View File

@@ -29,9 +29,10 @@ final class Landmark extends LinkedListEntry<Landmark>{
final Duration? duration;
bool visited;
// Next node
// Next node is implicitly available through the LinkedListEntry mixin
// final Landmark? next;
final Duration? tripTime;
Duration? tripTime;
// the trip time depends on the next landmark, so it is not final
Landmark({

View File

@@ -75,8 +75,16 @@ class Trip with ChangeNotifier {
notifyListeners();
}
void removeLandmark(Landmark landmark) {
void removeLandmark (Landmark landmark) async {
Landmark? previous = landmark.previous;
Landmark? next = landmark.next;
landmarks.remove(landmark);
// removing the landmark means we need to recompute the time between the two adjoined landmarks
if (previous != null && next != null) {
// previous.next = next happens automatically since we are using a LinkedList
previous.tripTime = null;
// TODO
}
notifyListeners();
}