quite a few UX improvements

This commit is contained in:
2025-03-23 20:00:24 +01:00
parent 4ad867e609
commit e148c851e1
12 changed files with 166 additions and 60 deletions

View File

@@ -140,9 +140,10 @@ class _AnimatedDotsTextState extends State<AnimatedDotsText> {
@override
Widget build(BuildContext context) {
String dots = '.' * dotCount;
return Text(
return AutoSizeText(
'${widget.baseText}$dots',
style: widget.style,
maxLines: 2,
);
}
}

View File

@@ -15,8 +15,9 @@ class CurrentTripSummary extends StatefulWidget {
class _CurrentTripSummaryState extends State<CurrentTripSummary> {
@override
Widget build(BuildContext context) {
return Padding(
Widget build(BuildContext context) => ListenableBuilder(
listenable: widget.trip,
builder: (context, child) => Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -25,18 +26,18 @@ class _CurrentTripSummaryState extends State<CurrentTripSummary> {
children: [
const Icon(Icons.flag, size: 20),
const Padding(padding: EdgeInsets.only(right: 10)),
Text('Stops: ${widget.trip.landmarks.length}', style: Theme.of(context).textTheme.bodyLarge),
Text('${widget.trip.landmarks.length} stops', style: Theme.of(context).textTheme.bodyLarge),
]
),
Row(
children: [
const Icon(Icons.hourglass_bottom_rounded, size: 20),
const Padding(padding: EdgeInsets.only(right: 10)),
Text('Duration: ${widget.trip.totalTime} minutes', style: Theme.of(context).textTheme.bodyLarge),
Text('${widget.trip.totalTime.inHours}h ${widget.trip.totalTime.inMinutes.remainder(60)}min', style: Theme.of(context).textTheme.bodyLarge),
]
),
],
)
);
}
)
);
}

View File

@@ -78,6 +78,7 @@ class _NewTripMapState extends State<NewTripMap> {
widget.trip.addListener(updateTripDetails);
Future<SharedPreferences> preferences = SharedPreferences.getInstance();
return FutureBuilder(
future: preferences,
builder: (context, snapshot) {

View File

@@ -1,3 +1,4 @@
import 'package:anyway/structs/agreement.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
@@ -26,7 +27,6 @@ class OnboardingAgreementCard extends StatefulWidget {
}
class _OnboardingAgreementCardState extends State<OnboardingAgreementCard> {
bool agreed = false;
@override
Widget build(BuildContext context) {
return Padding(
@@ -39,21 +39,42 @@ class _OnboardingAgreementCardState extends State<OnboardingAgreementCard> {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Checkbox(
value: agreed,
onChanged: (value) {
setState(() {
agreed = value!;
widget.onAgreementChanged(value);
});
// The checkbox of the agreement
FutureBuilder(
future: getAgreement(),
builder: (context, snapshot) {
bool agreed = false;
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasData) {
Agreement agreement = snapshot.data!;
agreed = agreement.agreed;
} else {
agreed = false;
}
} else {
agreed = false;
}
return Checkbox(
value: agreed,
onChanged: (value) {
setState(() {
widget.onAgreementChanged(value!);
});
saveAgreement(value!);
},
);
},
),
// The text of the agreement
Text(
"I agree to the ",
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Colors.white,
),
),
// The clickable text of the agreement that shows the agreement text
GestureDetector(
onTap: () {
// show a dialog with the agreement text

View File

@@ -48,7 +48,7 @@ class _StepBetweenLandmarksState extends State<StepBetweenLandmarks> {
children: [
const Icon(Icons.directions_walk),
Text(
time == null ? "" : "About $time min",
time == null ? "" : "$time min",
style: const TextStyle(fontSize: 10)
),
],