feat(departures): add direction info to departures

This commit is contained in:
fbachus
2026-07-24 18:53:05 +02:00
parent b0216e6a49
commit b6b4f27376
3 changed files with 13 additions and 2 deletions
+5 -1
View File
@@ -222,7 +222,11 @@ class ApiHandler {
(x) => Departure.fromJson(
// needed because I'm too lazy to write a second mostly identical
// constructor and a wrapper
_expandDeparturesJson(httpPackageJson, x, ["ref", "Product"]),
_expandDeparturesJson(httpPackageJson, x, [
"ref",
"Product",
"Directions",
]),
),
)
.cast<Departure>();
+1 -1
View File
@@ -302,7 +302,7 @@ class DepartureList extends StatelessWidget {
children: [
for (Departure departure in departureList)
ListTile(
title: Text(departure.vehicleName),
title: Text('${departure.vehicleName}: ${departure.direction}'),
subtitle: Text(departure.departureTime.toString()),
onTap: () => onTapped(departure),
),
+7
View File
@@ -780,6 +780,7 @@ class Departure {
int? id;
String ref;
String direction;
String vehicleId;
String vehicleName;
String stationId;
@@ -790,6 +791,7 @@ class Departure {
Departure({
this.id,
required this.ref,
required this.direction,
required this.vehicleId,
required this.vehicleName,
required this.stationId,
@@ -802,6 +804,7 @@ class Departure {
return {
"id": id,
"ref": ref,
"direction": direction,
"vehicle": vehicleId,
"vehiclename": vehicleName,
"station": stationId,
@@ -815,6 +818,7 @@ class Departure {
return Departure(
id: map["id"] as int,
ref: map["ref"] as String,
direction: map["direction"] as String,
vehicleId: map["vehicle"] as String,
vehicleName: map["vehiclename"] as String,
stationId: map["station"] as String,
@@ -869,6 +873,9 @@ class Departure {
// ["JourneyDetailRef"]["ref"] cannot be caught if ["JourneyDetailRef"]
// is non-existent
ref: json["ref"] ?? json["JourneyDetailRef"]["ref"] as String,
direction:
json["direction"] ??
json["Directions"]["Direction"][0]["value"], // this is not healthy
vehicleId: vehicle.id,
vehicleName: vehicle.name,
stationId: station.id,