location picker and ui fixes
All checks were successful
Build and release APK / Build APK (pull_request) Successful in 5m25s
All checks were successful
Build and release APK / Build APK (pull_request) Successful in 5m25s
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
import 'dart:collection';
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:anyway/structs/landmark.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -75,8 +76,11 @@ class Trip with ChangeNotifier {
|
||||
String? content = prefs.getString('trip_$uuid');
|
||||
Map<String, dynamic> json = jsonDecode(content!);
|
||||
Trip trip = Trip.fromJson(json);
|
||||
String? firstUUID = json['entry_uuid'];
|
||||
readLandmarks(trip.landmarks, prefs, firstUUID);
|
||||
String? firstUUID = json['first_landmark_uuid'];
|
||||
log('Loading trip $uuid with first landmark $firstUUID');
|
||||
LinkedList<Landmark> landmarks = readLandmarks(prefs, firstUUID);
|
||||
trip.landmarks = landmarks;
|
||||
// notifyListeners();
|
||||
return trip;
|
||||
}
|
||||
|
||||
@@ -90,6 +94,7 @@ class Trip with ChangeNotifier {
|
||||
|
||||
void toPrefs(SharedPreferences prefs){
|
||||
Map<String, dynamic> json = toJson();
|
||||
log('Saving trip $uuid : $json');
|
||||
prefs.setString('trip_$uuid', jsonEncode(json));
|
||||
for (Landmark landmark in landmarks) {
|
||||
landmarkToPrefs(prefs, landmark, landmark.next);
|
||||
@@ -99,12 +104,14 @@ class Trip with ChangeNotifier {
|
||||
|
||||
|
||||
// Helper
|
||||
readLandmarks(LinkedList<Landmark> landmarks, SharedPreferences prefs, String? firstUUID) {
|
||||
LinkedList<Landmark> readLandmarks(SharedPreferences prefs, String? firstUUID) {
|
||||
LinkedList<Landmark> landmarks = LinkedList<Landmark>();
|
||||
while (firstUUID != null) {
|
||||
var (head, nextUUID) = getLandmarkFromPrefs(prefs, firstUUID);
|
||||
landmarks.add(head);
|
||||
firstUUID = nextUUID;
|
||||
}
|
||||
return landmarks;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user