account for changed itineraries once landmarks are marked as done or deleted

This commit is contained in:
2025-02-16 12:41:06 +01:00
parent 56c55883ea
commit 6f2f86f936
6 changed files with 135 additions and 110 deletions

View File

@@ -1,4 +1,5 @@
import 'package:anyway/constants.dart';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:auto_size_text/auto_size_text.dart';
@@ -37,7 +38,10 @@ class _CurrentTripLoadingIndicatorState extends State<CurrentTripLoadingIndicato
// As a gimmick, and a way to show that the app is still working, show a few loading dots
const Align(
alignment: Alignment.bottomCenter,
child: StatusText(),
child: Padding(
padding: EdgeInsets.only(bottom: 12),
child: StatusText(),
)
)
],
);
@@ -81,19 +85,19 @@ Widget loadingText(Trip trip) => FutureBuilder(
Widget greeter;
if (snapshot.hasData) {
greeter = AnimatedGradientText(
text: 'Creating your trip to ${snapshot.data}...',
greeter = AnimatedDotsText(
baseText: 'Creating your trip to ${snapshot.data}',
style: greeterStyle,
);
} else if (snapshot.hasError) {
// the exact error is shown in the central part of the trip overview. No need to show it here
greeter = AnimatedGradientText(
text: 'Error while loading trip.',
greeter = Text(
'Error while loading trip.',
style: greeterStyle,
);
} else {
greeter = AnimatedGradientText(
text: 'Creating your trip...',
greeter = AnimatedDotsText(
baseText: 'Creating your trip',
style: greeterStyle,
);
}
@@ -101,61 +105,44 @@ Widget loadingText(Trip trip) => FutureBuilder(
}
);
class AnimatedGradientText extends StatefulWidget {
final String text;
class AnimatedDotsText extends StatefulWidget {
final String baseText;
final TextStyle style;
const AnimatedGradientText({
const AnimatedDotsText({
Key? key,
required this.text,
required this.baseText,
required this.style,
}) : super(key: key);
@override
_AnimatedGradientTextState createState() => _AnimatedGradientTextState();
_AnimatedDotsTextState createState() => _AnimatedDotsTextState();
}
class _AnimatedGradientTextState extends State<AnimatedGradientText> with SingleTickerProviderStateMixin {
late AnimationController _controller;
class _AnimatedDotsTextState extends State<AnimatedDotsText> {
int dotCount = 0;
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 1),
vsync: this,
)..repeat();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
Timer.periodic(const Duration(seconds: 1), (timer) {
if (mounted) {
setState(() {
dotCount = (dotCount + 1) % 4;
// show up to 3 dots
});
} else {
timer.cancel();
}
});
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return ShaderMask(
shaderCallback: (bounds) {
return LinearGradient(
colors: [GRADIENT_START, GRADIENT_END, GRADIENT_START],
stops: [
_controller.value - 1.0,
_controller.value,
_controller.value + 1.0,
],
tileMode: TileMode.mirror,
).createShader(bounds);
},
child: Text(
widget.text,
style: widget.style,
),
);
},
String dots = '.' * dotCount;
return Text(
'${widget.baseText}$dots',
style: widget.style,
);
}
}