diff --git a/lib/api_handler.dart b/lib/api_handler.dart index 674c9bc..4e9e5cd 100644 --- a/lib/api_handler.dart +++ b/lib/api_handler.dart @@ -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(); diff --git a/lib/main.dart b/lib/main.dart index d9f056a..709247d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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), ), diff --git a/lib/transport_helper.dart b/lib/transport_helper.dart index 83fdc26..b4edd61 100644 --- a/lib/transport_helper.dart +++ b/lib/transport_helper.dart @@ -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,