better help and onboarding
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	
This commit is contained in:
		
							
								
								
									
										27
									
								
								frontend/lib/utils/get_first_page.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								frontend/lib/utils/get_first_page.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| import 'package:anyway/pages/current_trip.dart'; | ||||
| import 'package:anyway/pages/onboarding.dart'; | ||||
| import 'package:anyway/structs/trip.dart'; | ||||
| import 'package:anyway/utils/load_trips.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
|  | ||||
| Widget getFirstPage() { | ||||
|   Future<List<Trip>> trips = loadTrips(); | ||||
|   // test if there are any active trips | ||||
|   // if there are, return the trip list | ||||
|   // if there are not, return the onboarding page | ||||
|   return FutureBuilder( | ||||
|     future: trips, | ||||
|     builder: (context, snapshot) { | ||||
|       if (snapshot.hasData) { | ||||
|         List<Trip> availableTrips = snapshot.data!; | ||||
|         if (availableTrips.isNotEmpty) { | ||||
|           return TripPage(trip: availableTrips[0]); | ||||
|         } else { | ||||
|           return OnboardingPage(); | ||||
|         } | ||||
|       } else { | ||||
|         return CircularProgressIndicator(); | ||||
|       } | ||||
|     } | ||||
|   ); | ||||
| } | ||||
| @@ -1,7 +1,4 @@ | ||||
| import 'dart:collection'; | ||||
|  | ||||
| import 'package:anyway/structs/trip.dart'; | ||||
| import 'package:anyway/structs/landmark.dart'; | ||||
| import 'package:shared_preferences/shared_preferences.dart'; | ||||
|  | ||||
| Future<List<Trip>> loadTrips() async { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user