-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: Add SavedTripCard component (#79)
- Loading branch information
1 parent
94343e0
commit 649e811
Showing
3 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
...design-system/src/main/kotlin/xyz/ksharma/krail/design/system/components/SavedTripCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package xyz.ksharma.krail.design.system.components | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
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.ColorFilter | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.res.vectorResource | ||
import androidx.compose.ui.semantics.Role | ||
import androidx.compose.ui.semantics.semantics | ||
import androidx.compose.ui.unit.dp | ||
import xyz.ksharma.krail.design.system.components.foundation.Text | ||
import xyz.ksharma.krail.design.system.model.TransportModeType | ||
import xyz.ksharma.krail.design.system.preview.ComponentPreviews | ||
import xyz.ksharma.krail.design.system.theme.KrailTheme | ||
import xyz.ksharma.krail.design.system.R as DSR | ||
|
||
@Composable | ||
fun SavedTripCard( | ||
transportModeType: TransportModeType, | ||
origin: String, | ||
destination: String, | ||
modifier: Modifier = Modifier, | ||
onStarClick: () -> Unit = {}, | ||
onCardClick: () -> Unit = {}, | ||
) { | ||
Row( | ||
modifier = modifier | ||
.clip(RoundedCornerShape(12.dp)) | ||
.background(color = KrailTheme.colors.secondaryContainer) | ||
.clickable(role = Role.Button, onClickLabel = "Open Trip Details", onClick = onCardClick) | ||
.padding(12.dp), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
|
||
TransportModeIcon( | ||
transportModeType = transportModeType, | ||
) | ||
|
||
Column( | ||
modifier = Modifier | ||
.padding(horizontal = 16.dp) | ||
.weight(1f) | ||
) { | ||
Text(text = origin, style = KrailTheme.typography.bodyMedium) | ||
Text(text = destination, style = KrailTheme.typography.bodyMedium) | ||
} | ||
|
||
Box( | ||
modifier = Modifier | ||
.size(32.dp) | ||
.clip(CircleShape) | ||
.clickable( | ||
onClickLabel = "Remove Saved Trip", | ||
role = Role.RadioButton, | ||
onClick = onStarClick, | ||
) | ||
.semantics(mergeDescendants = true) {}, | ||
contentAlignment = Alignment.Center, | ||
) { | ||
Image( | ||
imageVector = ImageVector.vectorResource(DSR.drawable.star), | ||
contentDescription = "Save Trip", | ||
colorFilter = ColorFilter.tint(KrailTheme.colors.secondary), | ||
) | ||
} | ||
} | ||
} | ||
|
||
// region Previews | ||
|
||
@ComponentPreviews | ||
@Composable | ||
private fun SavedTripCardPreview() { | ||
KrailTheme { | ||
SavedTripCard( | ||
transportModeType = TransportModeType.Train, | ||
origin = "Edmondson Park Station", | ||
destination = "Harris Park Station", | ||
) | ||
} | ||
} | ||
|
||
// endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M12,17.77L18.18,21.5L16.54,14.47L22,9.74L14.81,9.13L12,2.5L9.19,9.13L2,9.74L7.46,14.47L5.82,21.5L12,17.77Z" /> | ||
</vector> |