Some checks failed
Build and release APK / Build APK (pull_request) Has been cancelled
60 lines
1.7 KiB
Dart
60 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:auto_size_text/auto_size_text.dart';
|
|
|
|
import 'package:anyway/structs/trip.dart';
|
|
import 'package:anyway/pages/current_trip.dart';
|
|
|
|
class CurrentTripLoadingIndicator extends StatefulWidget {
|
|
final Trip trip;
|
|
const CurrentTripLoadingIndicator({
|
|
super.key,
|
|
required this.trip,
|
|
});
|
|
|
|
@override
|
|
State<CurrentTripLoadingIndicator> createState() => _CurrentTripLoadingIndicatorState();
|
|
}
|
|
|
|
class _CurrentTripLoadingIndicatorState extends State<CurrentTripLoadingIndicator> {
|
|
@override
|
|
Widget build(BuildContext context) => Center(
|
|
child: FutureBuilder(
|
|
future: widget.trip.cityName,
|
|
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
|
|
Widget greeter;
|
|
Widget loadingIndicator = const Padding(
|
|
padding: EdgeInsets.only(top: 10),
|
|
child: CircularProgressIndicator()
|
|
);
|
|
|
|
if (snapshot.hasData) {
|
|
greeter = AutoSizeText(
|
|
maxLines: 1,
|
|
'Generating 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 = AutoSizeText(
|
|
maxLines: 1,
|
|
'Error while loading trip.',
|
|
style: greeterStyle,
|
|
);
|
|
} else {
|
|
greeter = AutoSizeText(
|
|
maxLines: 1,
|
|
'Generating your trip...',
|
|
style: greeterStyle,
|
|
);
|
|
}
|
|
return Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
greeter,
|
|
loadingIndicator,
|
|
],
|
|
);
|
|
}
|
|
)
|
|
);
|
|
} |