feat(ui): filter for station arrivals after start

This commit is contained in:
fbachus
2026-07-24 17:36:01 +02:00
parent 1c0616fa86
commit b0216e6a49
2 changed files with 16 additions and 4 deletions
+12 -3
View File
@@ -202,6 +202,7 @@ class ApiHandler {
int? fromIdx, int? fromIdx,
String? toId, String? toId,
int? toIdx, int? toIdx,
String? startStationId,
}) async { }) async {
String urlPath = '/api/fahrinfo/latest/journeyDetail'; String urlPath = '/api/fahrinfo/latest/journeyDetail';
Uri url = Uri.https(baseUrl, urlPath, { Uri url = Uri.https(baseUrl, urlPath, {
@@ -216,7 +217,7 @@ class ApiHandler {
); );
final httpPackageJson = final httpPackageJson =
json.decode(jsonResponse.body) as Map<String, dynamic>; json.decode(jsonResponse.body) as Map<String, dynamic>;
final DepartureList = httpPackageJson["Stops"]["Stop"] Iterable<Departure> DepartureList = httpPackageJson["Stops"]["Stop"]
.map( .map(
(x) => Departure.fromJson( (x) => Departure.fromJson(
// needed because I'm too lazy to write a second mostly identical // needed because I'm too lazy to write a second mostly identical
@@ -224,9 +225,17 @@ class ApiHandler {
_expandDeparturesJson(httpPackageJson, x, ["ref", "Product"]), _expandDeparturesJson(httpPackageJson, x, ["ref", "Product"]),
), ),
) )
.toList()
.cast<Departure>(); .cast<Departure>();
return DepartureList;
// preferably this happens always?
if (startStationId != null) {
// show Stations after the one we are at
return DepartureList.skipWhile(
(x) => x.stationId != startStationId,
).skip(1).toList();
}
return DepartureList.toList().cast<Departure>();
} }
// workaround for the fact that json from tripDetail and DepartureBoard are // workaround for the fact that json from tripDetail and DepartureBoard are
+4 -1
View File
@@ -327,7 +327,10 @@ class _ChooseArrivalPageState extends State<ChooseArrivalPage> {
Departure? _selectedDeparture; Departure? _selectedDeparture;
void loadArrivals(String ref) async { void loadArrivals(String ref) async {
departureList = await ApiHandler.tripDetail(ref); departureList = await ApiHandler.tripDetail(
ref,
startStationId: widget.departure.stationId,
);
setState(() {}); setState(() {});
} }