From cb93cd829c23b6b569196f60df14f88b434b136f Mon Sep 17 00:00:00 2001 From: Karan Sharma <55722391+ksharma-xyz@users.noreply.github.com> Date: Sun, 20 Oct 2024 11:17:47 +1100 Subject: [PATCH] fix stopname for last leg --- .../krail/trip_planner/ui/components/JourneyDetailCard.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/feature/trip-planner/ui/src/main/kotlin/xyz/ksharma/krail/trip_planner/ui/components/JourneyDetailCard.kt b/feature/trip-planner/ui/src/main/kotlin/xyz/ksharma/krail/trip_planner/ui/components/JourneyDetailCard.kt index dcafbee7..82299980 100644 --- a/feature/trip-planner/ui/src/main/kotlin/xyz/ksharma/krail/trip_planner/ui/components/JourneyDetailCard.kt +++ b/feature/trip-planner/ui/src/main/kotlin/xyz/ksharma/krail/trip_planner/ui/components/JourneyDetailCard.kt @@ -142,7 +142,7 @@ fun JourneyDetailCard( .height(8.dp) ) - legList.forEach { leg -> + legList.forEachIndexed { index, leg -> if (leg.walkInterchange?.position == TimeTableState.JourneyCardInfo.WalkPosition.BEFORE) { leg.walkInterchange?.duration?.let { duration -> WalkingLeg( @@ -171,8 +171,8 @@ fun JourneyDetailCard( JourneyLeg( transportModeLine = leg.transportModeLine, stopsInfo = leg.stopsInfo, - departureTime = leg.stops.first().time, - stopName = leg.stops.first().name, + departureTime = if (index == legList.lastIndex) leg.stops.last().time else leg.stops.first().time, + stopName = if (index == legList.lastIndex) leg.stops.last().name else leg.stops.first().name, isWheelchairAccessible = false, modifier = Modifier.padding(start = 8.dp, end = 8.dp), )