quite a few UX improvements
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:anyway/layouts/scaffold.dart';
|
||||
import 'package:anyway/modules/new_trip_button.dart';
|
||||
import 'package:anyway/structs/landmark.dart';
|
||||
import 'package:anyway/structs/preferences.dart';
|
||||
import 'package:anyway/structs/trip.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@@ -20,6 +21,14 @@ class _NewTripPreferencesPageState extends State<NewTripPreferencesPage> with Sc
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Ensure that the trip is "empty" save for the start landmark
|
||||
// This is necessary because users can swipe back to this page even after the trip has been created
|
||||
if (widget.trip.landmarks.length > 1) {
|
||||
Landmark start = widget.trip.landmarks.first;
|
||||
widget.trip.landmarks.clear();
|
||||
widget.trip.addLandmark(start);
|
||||
}
|
||||
|
||||
return mainScaffold(
|
||||
context,
|
||||
child: Scaffold(
|
||||
|
50
frontend/lib/pages/no_trips_page.dart
Normal file
50
frontend/lib/pages/no_trips_page.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
import 'package:anyway/pages/new_trip_location.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:anyway/layouts/scaffold.dart';
|
||||
class NoTripsPage extends StatefulWidget {
|
||||
const NoTripsPage({super.key});
|
||||
|
||||
@override
|
||||
State<NoTripsPage> createState() => _NoTripsPageState();
|
||||
}
|
||||
|
||||
class _NoTripsPageState extends State<NoTripsPage> with ScaffoldLayout {
|
||||
@override
|
||||
Widget build(BuildContext context) => mainScaffold(
|
||||
context,
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"No trips yet",
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
Text(
|
||||
"You can start a new trip by clicking the button below",
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const NewTripPage()
|
||||
)
|
||||
);
|
||||
},
|
||||
label: const Row(
|
||||
children: [
|
||||
Text("Start planning!"),
|
||||
Padding(padding: EdgeInsets.only(right: 8.0)),
|
||||
Icon(Icons.map_outlined)
|
||||
],
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
@@ -4,6 +4,7 @@ import 'package:anyway/constants.dart';
|
||||
import 'package:anyway/modules/onbarding_agreement_card.dart';
|
||||
import 'package:anyway/modules/onboarding_card.dart';
|
||||
import 'package:anyway/pages/new_trip_location.dart';
|
||||
import 'package:anyway/structs/agreement.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
@@ -121,11 +122,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
|
||||
);
|
||||
} else {
|
||||
// only allow the user to proceed if they have agreed to the terms and conditions
|
||||
Future<bool> hasAgreed = SharedPreferences.getInstance().then(
|
||||
(SharedPreferences prefs) {
|
||||
return prefs.getBool('TC_agree') ?? false;
|
||||
}
|
||||
);
|
||||
Future<bool> hasAgreed = getAgreement().then((agreement) => agreement.agreed);
|
||||
|
||||
return FutureBuilder(
|
||||
future: hasAgreed,
|
||||
@@ -157,8 +154,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
|
||||
);
|
||||
|
||||
void onAgreementChanged(bool value) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool('TC_agree', value);
|
||||
saveAgreement(value);
|
||||
// Update the state of the OnboardingPage
|
||||
setState(() {});
|
||||
}
|
||||
|
Reference in New Issue
Block a user