Beginning to use different contexts
This commit is contained in:
		| @@ -16,6 +16,8 @@ Future<List<Landmark>> fetchLandmarks() async { | ||||
|       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")), | ||||
|     ]; | ||||
|     // sleep 10 seconds | ||||
|     await Future.delayed(Duration(seconds: 10)); | ||||
|     return landmarks; | ||||
|   // } else { | ||||
|   //   // If the server did not return a 200 OK response, | ||||
|   | ||||
							
								
								
									
										37
									
								
								frontend/lib/utils/get_trips.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								frontend/lib/utils/get_trips.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| 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; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user