handles errors in a more use friendly way
Some checks failed
Build and deploy the backend to staging / Deploy to staging (pull_request) Has been cancelled
Build and deploy the backend to staging / Build and push image (pull_request) Has been cancelled
Run linting on the backend code / Build (pull_request) Has been cancelled

This commit is contained in:
2025-04-06 19:27:26 +02:00
parent 8ef60104f0
commit 720e4d1c17
15 changed files with 527 additions and 51 deletions

View File

@@ -16,22 +16,27 @@ class CurrentTripErrorMessage extends StatefulWidget {
class _CurrentTripErrorMessageState extends State<CurrentTripErrorMessage> {
@override
Widget build(BuildContext context) => Center(
child: Row(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error_outline,
color: Colors.red,
size: 50,
),
const Padding(
padding: EdgeInsets.only(left: 10),
Text(
"😢",
style: TextStyle(
fontSize: 40,
),
),
const SizedBox(height: 10),
AutoSizeText(
'Error: ${widget.trip.errorDescription}',
maxLines: 3,
// at this point the trip is guaranteed to have an error message
widget.trip.errorDescription!,
maxLines: 30,
style: Theme.of(context).textTheme.bodyMedium,
textAlign: TextAlign.center,
),
],
)
),
);
}

View File

@@ -1,3 +1,5 @@
import 'package:anyway/pages/current_trip.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:anyway/constants.dart';
@@ -34,15 +36,27 @@ class _CurrentTripPanelState extends State<CurrentTripPanel> {
listenable: widget.trip,
builder: (context, child) {
if (widget.trip.uuid == 'error') {
return Align(
alignment: Alignment.topCenter,
child: SizedBox(
return ListView(
controller: widget.controller,
padding: const EdgeInsets.only(top: 10, left: 10, right: 10, bottom: 30),
children: [
SizedBox(
// reuse the exact same height as the panel has when collapsed
// this way the greeter will be centered when the panel is collapsed
height: MediaQuery.of(context).size.height * TRIP_PANEL_MIN_HEIGHT,
child: CurrentTripErrorMessage(trip: widget.trip)
// note that we need to account for the padding above
height: MediaQuery.of(context).size.height * TRIP_PANEL_MIN_HEIGHT - 10,
child: Center(child:
AutoSizeText(
maxLines: 1,
'Error',
style: greeterStyle
)
),
),
);
CurrentTripErrorMessage(trip: widget.trip),
],
);
} else if (widget.trip.uuid == 'pending') {
return Align(
alignment: Alignment.topCenter,