Public Access
feat(departures): add direction info to departures
This commit is contained in:
@@ -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
@@ -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),
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user