more pleasant progress handling, although somewhat flawed
This commit is contained in:
@@ -27,7 +27,7 @@ final class Landmark extends LinkedListEntry<Landmark>{
|
||||
String? imageURL; // not final because it can be patched
|
||||
final String? description;
|
||||
final Duration? duration;
|
||||
final bool? visited;
|
||||
bool visited;
|
||||
|
||||
// Next node
|
||||
// final Landmark? next;
|
||||
@@ -46,7 +46,7 @@ final class Landmark extends LinkedListEntry<Landmark>{
|
||||
this.imageURL,
|
||||
this.description,
|
||||
this.duration,
|
||||
this.visited,
|
||||
this.visited = false,
|
||||
|
||||
// this.next,
|
||||
this.tripTime,
|
||||
@@ -71,7 +71,7 @@ final class Landmark extends LinkedListEntry<Landmark>{
|
||||
final imageURL = json['image_url'] as String?;
|
||||
final description = json['description'] as String?;
|
||||
var duration = Duration(minutes: json['duration'] ?? 0) as Duration?;
|
||||
final visited = json['visited'] as bool?;
|
||||
final visited = json['visited'] ?? false as bool;
|
||||
var tripTime = Duration(minutes: json['time_to_reach_next'] ?? 0) as Duration?;
|
||||
|
||||
return Landmark(
|
||||
|
@@ -52,6 +52,7 @@ class Trip with ChangeNotifier {
|
||||
totalTime = json['total_time'];
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void addLandmark(Landmark landmark) {
|
||||
landmarks.add(landmark);
|
||||
notifyListeners();
|
||||
@@ -66,12 +67,16 @@ class Trip with ChangeNotifier {
|
||||
landmarks.remove(landmark);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
void updateError(String error) {
|
||||
errorDescription = error;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void notifyUpdate(){
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
factory Trip.fromPrefs(SharedPreferences prefs, String uuid) {
|
||||
String? content = prefs.getString('trip_$uuid');
|
||||
Map<String, dynamic> json = jsonDecode(content!);
|
||||
@@ -80,7 +85,6 @@ class Trip with ChangeNotifier {
|
||||
log('Loading trip $uuid with first landmark $firstUUID');
|
||||
LinkedList<Landmark> landmarks = readLandmarks(prefs, firstUUID);
|
||||
trip.landmarks = landmarks;
|
||||
// notifyListeners();
|
||||
return trip;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user