anyway/frontend/lib/utils/get_first_page.dart
Remy Moll 02133a4abe
Some checks failed
Run testing on the backend code / Build (pull_request) Failing after 4m43s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 25s
Build and release debug APK / Build APK (pull_request) Failing after 4m39s
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 3m30s
Run linting on the backend code / Build (pull_request) Successful in 28s
quite a few UX improvements
2025-03-23 20:00:24 +01:00

50 lines
1.6 KiB
Dart

import 'package:anyway/main.dart';
import 'package:anyway/pages/no_trips_page.dart';
import 'package:anyway/structs/agreement.dart';
import 'package:flutter/material.dart';
import 'package:anyway/structs/trip.dart';
import 'package:anyway/pages/current_trip.dart';
import 'package:anyway/pages/onboarding.dart';
Widget getFirstPage() {
// check if the user has already seen the onboarding and agreed to the terms of service
return FutureBuilder(
future: getAgreement(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasData) {
Agreement agrement = snapshot.data!;
if (agrement.agreed) {
return FutureBuilder(
future: savedTrips.loadTrips(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasData) {
List<Trip> trips = snapshot.data!;
if (trips.length > 0) {
return TripPage(trip: trips[0]);
} else {
return NoTripsPage();
}
} else {
return Center(child: CircularProgressIndicator());
}
} else {
return Center(child: CircularProgressIndicator());
}
},
);
} else {
return OnboardingPage();
}
} else {
return OnboardingPage();
}
} else {
return OnboardingPage();
}
},
);
}