From b0216e6a497199b2a8eb985e4e4ee0beb72d0c3c Mon Sep 17 00:00:00 2001 From: fbachus Date: Fri, 24 Jul 2026 17:36:01 +0200 Subject: [PATCH] feat(ui): filter for station arrivals after start --- lib/api_handler.dart | 15 ++++++++++++--- lib/main.dart | 5 ++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/api_handler.dart b/lib/api_handler.dart index 3642a7d..674c9bc 100644 --- a/lib/api_handler.dart +++ b/lib/api_handler.dart @@ -202,6 +202,7 @@ class ApiHandler { int? fromIdx, String? toId, int? toIdx, + String? startStationId, }) async { String urlPath = '/api/fahrinfo/latest/journeyDetail'; Uri url = Uri.https(baseUrl, urlPath, { @@ -216,7 +217,7 @@ class ApiHandler { ); final httpPackageJson = json.decode(jsonResponse.body) as Map; - final DepartureList = httpPackageJson["Stops"]["Stop"] + Iterable DepartureList = httpPackageJson["Stops"]["Stop"] .map( (x) => Departure.fromJson( // needed because I'm too lazy to write a second mostly identical @@ -224,9 +225,17 @@ class ApiHandler { _expandDeparturesJson(httpPackageJson, x, ["ref", "Product"]), ), ) - .toList() .cast(); - 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(); } // workaround for the fact that json from tripDetail and DepartureBoard are diff --git a/lib/main.dart b/lib/main.dart index 9f822ca..d9f056a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -327,7 +327,10 @@ class _ChooseArrivalPageState extends State { Departure? _selectedDeparture; void loadArrivals(String ref) async { - departureList = await ApiHandler.tripDetail(ref); + departureList = await ApiHandler.tripDetail( + ref, + startStationId: widget.departure.stationId, + ); setState(() {}); }