From 88801aa85009d25f7240469fdf277dced28f9ae4 Mon Sep 17 00:00:00 2001 From: Karan Sharma <55722391+ksharma-xyz@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:26:21 +1100 Subject: [PATCH] fix stopname for last leg (#227) --- .../krail/trip_planner/ui/components/JourneyDetailCard.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 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..abfb476f 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 @@ -80,7 +80,7 @@ fun JourneyDetailCard( verticalArrangement = Arrangement.spacedBy(4.dp), ) { Text( - text = "In $timeToDeparture", + text = timeToDeparture, style = KrailTheme.typography.titleLarge, color = legList.first().transportModeLine.transportMode.colorCode.hexToComposeColor() ) @@ -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), )