trip loading (from device storage) much improved
All checks were successful
Build and release APK / Build APK (pull_request) Successful in 5m18s
All checks were successful
Build and release APK / Build APK (pull_request) Successful in 5m18s
This commit is contained in:
@@ -42,7 +42,25 @@ class _BasePageState extends State<BasePage> {
|
||||
|
||||
|
||||
if (widget.mainScreen == "map") {
|
||||
currentView = TripPage(trip: widget.trip ?? getFirstTrip(trips));
|
||||
if (widget.trip != null) {
|
||||
currentView = TripPage(trip: widget.trip!);
|
||||
} else {
|
||||
currentView = FutureBuilder(
|
||||
future: trips,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
List<Trip> availableTrips = snapshot.data!;
|
||||
if (availableTrips.isNotEmpty) {
|
||||
return TripPage(trip: availableTrips[0]);
|
||||
} else {
|
||||
return Text("Wow, so empty!");
|
||||
}
|
||||
} else {
|
||||
return const Text("loading...");
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
} else if (widget.mainScreen == "tutorial") {
|
||||
currentView = TutorialPage();
|
||||
} else if (widget.mainScreen == "profile") {
|
||||
@@ -134,72 +152,3 @@ class _BasePageState extends State<BasePage> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// This function is used to get the first trip from a list of trips
|
||||
// TODO: Implement this function
|
||||
Trip getFirstTrip(Future<List<Trip>> trips) {
|
||||
Trip t1 = Trip(uuid: '1', landmarks: LinkedList<Landmark>());
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: '0',
|
||||
name: "Start",
|
||||
location: [48.85, 2.32],
|
||||
type: start,
|
||||
),
|
||||
);
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: '1',
|
||||
name: "Eiffel Tower",
|
||||
location: [48.859, 2.295],
|
||||
type: sightseeing,
|
||||
imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/Tour_Eiffel_Wikimedia_Commons.jpg/1037px-Tour_Eiffel_Wikimedia_Commons.jpg"
|
||||
),
|
||||
);
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "2",
|
||||
name: "Notre Dame Cathedral",
|
||||
location: [48.8530, 2.3498],
|
||||
type: sightseeing,
|
||||
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"
|
||||
),
|
||||
);
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "3",
|
||||
name: "Louvre palace",
|
||||
location: [48.8606, 2.3376],
|
||||
type: sightseeing,
|
||||
imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/Louvre_Museum_Wikimedia_Commons.jpg/540px-Louvre_Museum_Wikimedia_Commons.jpg"
|
||||
),
|
||||
);
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "4",
|
||||
name: "Pont-des-arts",
|
||||
location: [48.8585, 2.3376],
|
||||
type: sightseeing,
|
||||
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"
|
||||
),
|
||||
);
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "5",
|
||||
name: "Panthéon",
|
||||
location: [48.847, 2.347],
|
||||
type: sightseeing,
|
||||
imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Pantheon_of_Paris_007.JPG/1280px-Pantheon_of_Paris_007.JPG"
|
||||
),
|
||||
);
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "6",
|
||||
name: "Galeries Lafayette",
|
||||
location: [48.87, 2.32],
|
||||
type: shopping,
|
||||
imageURL: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/de/GaleriesLafayetteNuit.jpg/220px-GaleriesLafayetteNuit.jpg"
|
||||
),
|
||||
);
|
||||
return t1;
|
||||
}
|
@@ -16,8 +16,6 @@ class TripsOverview extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _TripsOverviewState extends State<TripsOverview> {
|
||||
// final Future<List<Trip>> _trips = loadTrips();
|
||||
|
||||
|
||||
Widget listBuild (BuildContext context, AsyncSnapshot<List<Trip>> snapshot) {
|
||||
List<Widget> children;
|
||||
@@ -65,6 +63,7 @@ class _TripsOverviewState extends State<TripsOverview> {
|
||||
|
||||
return ListView(
|
||||
children: children,
|
||||
padding: const EdgeInsets.only(top: 0),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -15,105 +15,5 @@ Future<List<Trip>> loadTrips() async {
|
||||
trips.add(Trip.fromPrefs(prefs, uuid));
|
||||
}
|
||||
}
|
||||
|
||||
if (trips.isEmpty) {
|
||||
Trip t1 = Trip(uuid: '1', landmarks: LinkedList<Landmark>());
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: '1',
|
||||
name: "Eiffel Tower",
|
||||
location: [48.859, 2.295],
|
||||
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"
|
||||
),
|
||||
);
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "2",
|
||||
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"
|
||||
),
|
||||
);
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "3",
|
||||
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"
|
||||
),
|
||||
);
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "4",
|
||||
name: "Pont-des-arts",
|
||||
location: [48.8585, 2.3376],
|
||||
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"
|
||||
),
|
||||
);
|
||||
t1.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "5",
|
||||
name: "Panthéon",
|
||||
location: [48.847, 2.347],
|
||||
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"
|
||||
),
|
||||
);
|
||||
trips.add(t1);
|
||||
|
||||
|
||||
Trip t2 = Trip(uuid: '2', landmarks: LinkedList<Landmark>());
|
||||
|
||||
t2.landmarks.add(
|
||||
Landmark(
|
||||
uuid: '21',
|
||||
name: "St. Charles's Church",
|
||||
location: [48.1924563,16.3334399],
|
||||
type: LandmarkType(name: "Monument"),
|
||||
imageURL: "https://lh5.googleusercontent.com/p/AF1QipNNmA76Ps71NCL9rOOFoyheCEOyXWdHcUgQx9jd=w408-h305-k-no"
|
||||
),
|
||||
);
|
||||
t2.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "22",
|
||||
name: "Vienna State Opera",
|
||||
location: [48.1949124,16.3483292],
|
||||
type: LandmarkType(name: "Culture"),
|
||||
imageURL: "https://lh5.googleusercontent.com/p/AF1QipMOx398kcoeDXFruSHNsb4lmZtdT8vibtK0cLi-=w408-h306-k-no"
|
||||
),
|
||||
);
|
||||
t2.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "23",
|
||||
name: "Belvedere-Schlossgarten",
|
||||
location: [48.1956427,16.3711521],
|
||||
type: LandmarkType(name: "Nature"),
|
||||
imageURL: "https://lh5.googleusercontent.com/p/AF1QipNcI5LImH2Qdzx0GmF-5CY1wRKINFZ7HkahPEy1=w408-h306-k-no"
|
||||
),
|
||||
);
|
||||
t2.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "24",
|
||||
name: "Kunsthistorisches Museum Wien",
|
||||
location: [48.2047501,16.3581904],
|
||||
type: LandmarkType(name: "Museum"),
|
||||
imageURL: "https://lh5.googleusercontent.com/p/AF1QipPuDu-kCCowO4TcawjziE8AhDVAANagVtRYBjlv=w408-h450-k-no"
|
||||
),
|
||||
);
|
||||
t2.landmarks.add(
|
||||
Landmark(
|
||||
uuid: "25",
|
||||
name: "Salztorbrücke",
|
||||
location: [48.2132382,16.369051],
|
||||
type: LandmarkType(name: "Bridge"),
|
||||
),
|
||||
);
|
||||
trips.add(t2);
|
||||
|
||||
}
|
||||
return trips;
|
||||
}
|
||||
|
Reference in New Issue
Block a user