functional datastructure. Needs to be able to write to storage as well
Some checks failed
Build and push docker image / Build (pull_request) Failing after 3m5s
Build and release APK / Build APK (pull_request) Successful in 7m24s
Build web / Build Web (pull_request) Successful in 3m36s

This commit is contained in:
2024-06-21 19:30:40 +02:00
parent 9a5ae95d97
commit db41528702
18 changed files with 346 additions and 210 deletions

View File

@@ -0,0 +1,52 @@
// import "package:fast_network_navigation/structs/landmark.dart";
// import 'package:http/http.dart' as http;
// Future<List<Landmark>> fetchLandmarks() async {
// // final response = await http
// // .get(Uri.parse('https://nav.kluster.moll.re/v1/destination/1'));
// // if (response.statusCode == 200) {
// // If the server did return a 200 OK response,
// // then parse the JSON.
// List<Landmark> landmarks = [
// // 48°5129.6″N 2°1740.2″E
// Landmark(
// name: "Eiffel Tower",
// location: [48.51296, 2.17402],
// type: LandmarkType(name: "Tower"),
// imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/Tour_Eiffel_Wikimedia_Commons.jpg/1037px-Tour_Eiffel_Wikimedia_Commons.jpg"
// ),
// Landmark(
// name: "Notre Dame Cathedral",
// location: [48.8530, 2.3498],
// type: LandmarkType(name: "Monument"),
// imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Notre-Dame_de_Paris%2C_4_October_2017.jpg/440px-Notre-Dame_de_Paris%2C_4_October_2017.jpg"
// ),
// Landmark(
// name: "Louvre palace",
// location: [48.8606, 2.3376],
// type: LandmarkType(name: "Museum"),
// imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/Louvre_Museum_Wikimedia_Commons.jpg/540px-Louvre_Museum_Wikimedia_Commons.jpg"
// ),
// Landmark(
// name: "Pont-des-arts",
// location: [48.5130, 2.2015],
// type: LandmarkType(name: "Bridge"),
// imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Pont_des_Arts%2C_6e_Arrondissement%2C_Paris_%28HDR%29_20140320_1.jpg/560px-Pont_des_Arts%2C_6e_Arrondissement%2C_Paris_%28HDR%29_20140320_1.jpg"),
// Landmark(
// name: "Panthéon",
// location: [48.5046, 2.2046],
// type: LandmarkType(name: "Monument"),
// imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Pantheon_of_Paris_007.JPG/1280px-Pantheon_of_Paris_007.JPG"
// ),
// ];
// // sleep 10 seconds
// await Future.delayed(Duration(seconds: 5));
// return landmarks;
// // } else {
// // // If the server did not return a 200 OK response,
// // // then throw an exception.
// // throw Exception('Failed to load destination');
// // }
// }

View File

@@ -1,52 +0,0 @@
import "package:fast_network_navigation/structs/landmark.dart";
import 'package:http/http.dart' as http;
Future<List<Landmark>> fetchLandmarks() async {
// final response = await http
// .get(Uri.parse('https://nav.kluster.moll.re/v1/destination/1'));
// if (response.statusCode == 200) {
// If the server did return a 200 OK response,
// then parse the JSON.
List<Landmark> landmarks = [
// 48°5129.6″N 2°1740.2″E
Landmark(
name: "Eiffel Tower",
location: [48.51296, 2.17402],
type: LandmarkType(name: "Tower"),
imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/Tour_Eiffel_Wikimedia_Commons.jpg/1037px-Tour_Eiffel_Wikimedia_Commons.jpg"
),
Landmark(
name: "Notre Dame Cathedral",
location: [48.8530, 2.3498],
type: LandmarkType(name: "Monument"),
imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Notre-Dame_de_Paris%2C_4_October_2017.jpg/440px-Notre-Dame_de_Paris%2C_4_October_2017.jpg"
),
Landmark(
name: "Louvre palace",
location: [48.8606, 2.3376],
type: LandmarkType(name: "Museum"),
imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/Louvre_Museum_Wikimedia_Commons.jpg/540px-Louvre_Museum_Wikimedia_Commons.jpg"
),
Landmark(
name: "Pont-des-arts",
location: [48.5130, 2.2015],
type: LandmarkType(name: "Bridge"),
imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Pont_des_Arts%2C_6e_Arrondissement%2C_Paris_%28HDR%29_20140320_1.jpg/560px-Pont_des_Arts%2C_6e_Arrondissement%2C_Paris_%28HDR%29_20140320_1.jpg"),
Landmark(
name: "Panthéon",
location: [48.5046, 2.2046],
type: LandmarkType(name: "Monument"),
imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Pantheon_of_Paris_007.JPG/1280px-Pantheon_of_Paris_007.JPG"
),
];
// sleep 10 seconds
await Future.delayed(Duration(seconds: 5));
return landmarks;
// } else {
// // If the server did not return a 200 OK response,
// // then throw an exception.
// throw Exception('Failed to load destination');
// }
}

View File

@@ -1,37 +0,0 @@
import 'dart:convert';
import 'package:fast_network_navigation/structs/trip.dart';
import 'package:fast_network_navigation/structs/landmark.dart';
import 'package:shared_preferences/shared_preferences.dart';
Future<List<Trip>> loadTrips() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
Set<String> keys = prefs.getKeys();
List<Trip> itineraries = [];
for (String key in keys) {
if (key.startsWith("itinerary_")) {
String json = prefs.getString(key)!;
itineraries.add(Trip.fromJson(jsonDecode(json)));
}
}
itineraries.add(Trip(uuid: "1", cityName: "Paris", landmarks: [
Landmark(name: "Landmark 1", location: [48.85, 2.35], type: LandmarkType(name: "Type 1")),
Landmark(name: "Landmark 2", location: [48.86, 2.36], type: LandmarkType(name: "Type 2")),
Landmark(name: "Landmark 3", location: [48.75, 2.3], type: LandmarkType(name: "Type 3")),
Landmark(name: "Landmark 4", location: [48.9, 2.4], type: LandmarkType(name: "Type 4")),
Landmark(name: "Landmark 5", location: [48.91, 2.45], type: LandmarkType(name: "Type 5")),
]));
itineraries.add(Trip(uuid: "2", cityName: "Vienna", landmarks: []));
itineraries.add(Trip(uuid: "3", cityName: "London", landmarks: []));
itineraries.add(Trip(uuid: "4", cityName: "Madrid", landmarks: []));
itineraries.add(Trip(uuid: "5", cityName: "Tokyo", landmarks: []));
itineraries.add(Trip(uuid: "6", cityName: "New York", landmarks: []));
itineraries.add(Trip(uuid: "7", cityName: "Los Angeles", landmarks: []));
itineraries.add(Trip(uuid: "8", cityName: "Zurich", landmarks: []));
itineraries.add(Trip(uuid: "9", cityName: "Orschwiller", landmarks: []));
await Future.delayed(Duration(seconds: 3));
return itineraries;
}

View File

@@ -0,0 +1,44 @@
import 'dart:collection';
import 'package:fast_network_navigation/structs/linked_landmarks.dart';
import 'package:fast_network_navigation/structs/trip.dart';
import 'package:fast_network_navigation/structs/landmark.dart';
import 'package:shared_preferences/shared_preferences.dart';
Future<List<Trip>> loadTrips() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
List<Trip> trips = [];
Set<String> keys = prefs.getKeys();
for (String key in keys) {
if (key.startsWith('trip_')) {
String uuid = key.replaceFirst('trip_', '');
trips.add(Trip.fromPrefs(prefs, uuid));
}
}
if (trips.isEmpty) {
String now = DateTime.now().toString();
trips.add(
Trip(uuid: '1', cityName: 'Paris (generated $now)', landmarks: LinkedList<Landmark>())
);
// Trip(uuid: "1", cityName: "Paris", landmarks: [
// Landmark(name: "Landmark 1", location: [48.85, 2.35], type: LandmarkType(name: "Type 1")),
// Landmark(name: "Landmark 2", location: [48.86, 2.36], type: LandmarkType(name: "Type 2")),
// Landmark(name: "Landmark 3", location: [48.75, 2.3], type: LandmarkType(name: "Type 3")),
// Landmark(name: "Landmark 4", location: [48.9, 2.4], type: LandmarkType(name: "Type 4")),
// Landmark(name: "Landmark 5", location: [48.91, 2.45], type: LandmarkType(name: "Type 5")),
// ]));
// trips.add(Trip(uuid: "2", cityName: "Vienna", landmarks: []));
// trips.add(Trip(uuid: "3", cityName: "London", landmarks: []));
// trips.add(Trip(uuid: "4", cityName: "Madrid", landmarks: []));
// trips.add(Trip(uuid: "5", cityName: "Tokyo", landmarks: []));
// trips.add(Trip(uuid: "6", cityName: "New York", landmarks: []));
// trips.add(Trip(uuid: "7", cityName: "Los Angeles", landmarks: []));
// trips.add(Trip(uuid: "8", cityName: "Zurich", landmarks: []));
// trips.add(Trip(uuid: "9", cityName: "Orschwiller", landmarks: []));
}
return trips;
}