Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate JourneyDetailCard #222

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.ksharma.krail.trip_planner.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -40,6 +41,7 @@ fun JourneyDetailCard(
platformNumber: Char,
totalTravelTime: String,
legList: ImmutableList<TimeTableState.JourneyCardInfo.Leg>,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
val density = LocalDensity.current
Expand All @@ -49,13 +51,16 @@ fun JourneyDetailCard(
Column(
modifier = modifier
.fillMaxWidth()
.background(KrailTheme.colors.surface)
.padding(vertical = 12.dp)
.clickable(role = Role.Button) { onClick() }
) {
FlowRow(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
horizontalArrangement = Arrangement.SpaceBetween
horizontalArrangement = Arrangement.SpaceBetween,
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
Text(
text = "In $timeToDeparture",
Expand All @@ -74,6 +79,7 @@ fun JourneyDetailCard(
.fillMaxWidth()
.padding(horizontal = 16.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
Row(
verticalAlignment = Alignment.CenterVertically,
Expand Down Expand Up @@ -192,6 +198,7 @@ private fun PreviewJourneyDetailCard() {
).toImmutableList()
),
).toImmutableList(),
onClick = {},
)
}
}
Expand Down Expand Up @@ -228,6 +235,7 @@ private fun PreviewJourneyDetailCardWalkBefore() {
).toImmutableList()
),
).toImmutableList(),
onClick = {},
)
}
}
Expand Down Expand Up @@ -264,6 +272,7 @@ private fun PreviewJourneyDetailCardWalkAfter() {
).toImmutableList()
),
).toImmutableList(),
onClick = {},
)
}
}
Expand Down Expand Up @@ -319,11 +328,12 @@ private fun PreviewMultiLegJourneyDetailCard() {
).toImmutableList()
)
).toImmutableList(),
onClick = {},
)
}
}


/*
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun JourneyDetailCard(
Expand Down Expand Up @@ -377,56 +387,4 @@ fun JourneyDetailCard(
}
}
}
}

// region Previews

//@ComponentPreviews
@Composable
private fun JourneyDetailCardPreview(modifier: Modifier = Modifier) {
KrailTheme {
JourneyDetailCard(
header = "in 5 mins on Platform 1 (10 min)",
journeyLegList = listOf(
TimeTableState.JourneyCardInfo.Leg(
transportModeLine = TransportModeLine(
transportMode = TransportMode.Bus(),
lineName = "600",
),
displayText = "Dessert via Rainy Road",
stopsInfo = "4 stops (12 min)",
stops = listOf(
TimeTableState.JourneyCardInfo.Stop(
name = "TownHall Station",
time = "8:25am",
),
TimeTableState.JourneyCardInfo.Stop(
name = "Central Station",
time = "8:25am"
),
).toImmutableList()
),
TimeTableState.JourneyCardInfo.Leg(
transportModeLine = TransportModeLine(
transportMode = TransportMode.Train(),
lineName = "T4",
),
displayText = "Dessert via Rainy Road",
stopsInfo = "4 stops (12 min)",
stops = listOf(
TimeTableState.JourneyCardInfo.Stop(
name = "TownHall Station",
time = "8:25am",
),
TimeTableState.JourneyCardInfo.Stop(
name = "Central Station",
time = "8:25am"
),
).toImmutableList()
),
)
)
}
}

// endregion
}*/
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package xyz.ksharma.krail.trip_planner.ui.components

import android.content.res.Configuration.UI_MODE_NIGHT_YES
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -16,11 +15,11 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import xyz.ksharma.krail.design.system.components.Text
Expand Down Expand Up @@ -53,6 +52,7 @@ fun JourneyLeg(
) {
FlowRow(
horizontalArrangement = Arrangement.spacedBy(12.dp),
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
TransportModeInfo(
letter = transportModeLine.transportMode.name.first(),
Expand All @@ -70,7 +70,8 @@ fun JourneyLeg(
}
FlowRow(
modifier = Modifier.padding(top = 8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp)
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
Row(
modifier = Modifier.align(Alignment.CenterVertically),
Expand All @@ -92,27 +93,30 @@ fun JourneyLeg(
Text(
text = departureTime,
style = KrailTheme.typography.bodyMedium,
color = Color(0xFF1A1A1A),
color = KrailTheme.colors.onSurface,
modifier = Modifier
.align(Alignment.CenterVertically)
.padding(start = 8.dp),
)
}
Row(
modifier = Modifier.align(Alignment.CenterVertically),
verticalAlignment = Alignment.CenterVertically
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
Text(
text = stopName,
style = KrailTheme.typography.titleSmall,
color = Color(0xFF1A1A1A),
color = KrailTheme.colors.onSurface,
modifier = Modifier.align(Alignment.CenterVertically),
)
if (isWheelchairAccessible) {
Image(
painter = painterResource(R.drawable.ic_a11y),
contentDescription = null,
colorFilter = ColorFilter.tint(color = Color(0xFF1A1A1A)),
colorFilter = ColorFilter.tint(
color = KrailTheme.colors.onSurface,
),
modifier = Modifier
.size(14.dp.toAdaptiveSize())
.align(Alignment.CenterVertically),
Expand All @@ -123,9 +127,8 @@ fun JourneyLeg(
}
}

@Preview(showBackground = true)
@Preview(showBackground = true, uiMode = UI_MODE_NIGHT_YES)
@Preview(showBackground = true, fontScale = 2f)
@PreviewLightDark
@Preview(fontScale = 2f)
@Composable
private fun PreviewJourneyLeg() {
KrailTheme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ fun TimeTableScreen(
exit = fadeOut() + shrinkOut(),
) {
JourneyDetailCard(
header = journey.timeText + journey.platformText.let { " on ${journey.platformText}" } + " (${journey.travelTime})",
journeyLegList = journey.legs,
timeToDeparture = journey.timeText,
platformNumber = journey.platformText ?: ' ',
totalTravelTime = journey.travelTime,
legList = journey.legs.toImmutableList(),
onClick = {
onEvent(TimeTableUiEvent.JourneyCardClicked(journey.journeyId))
},
Expand Down