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

UI: Refactor JourneyCard clickable area and simplify stops display #254

Merged
merged 1 commit into from
Oct 26, 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
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -100,12 +99,6 @@ fun JourneyCard(
Modifier
},
)
.clickable(
role = Role.Button,
onClick = onClick,
interactionSource = remember { MutableInteractionSource() },
indication = null,
)
.padding(
vertical = 8.dp,
horizontal = if (cardState == JourneyCardState.DEFAULT) 12.dp else 0.dp,
Expand All @@ -121,7 +114,12 @@ fun JourneyCard(
themeColor = themeColor,
transportModeList = transportModeList,
platformNumber = platformNumber,
modifier = Modifier,
modifier = Modifier.clickable(
role = Role.Button,
onClick = onClick,
interactionSource = remember { MutableInteractionSource() },
indication = null,
),
)

else -> JourneyCardContent(
Expand All @@ -132,7 +130,12 @@ fun JourneyCard(
iconSize = iconSize,
totalTravelTime = totalTravelTime,
legList = legList,
modifier = Modifier,
modifier = Modifier.clickable(
role = Role.Button,
onClick = onClick,
interactionSource = remember { MutableInteractionSource() },
indication = null,
),
)
}
}
Expand Down Expand Up @@ -298,7 +301,7 @@ fun JourneyCardContent(

@OptIn(ExperimentalLayoutApi::class)
@Composable
fun ColumnScope.DefaultJourneyCardContent(
fun DefaultJourneyCardContent(
timeToDeparture: String,
originTime: String,
destinationTime: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ fun LegView(
.copy(alpha = 0.1f),
shape = RoundedCornerShape(12.dp),
)
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
onClick = { displayNonProminentStops = !displayNonProminentStops },
role = Role.Button,
)
.padding(vertical = 12.dp, horizontal = 12.dp),
) {
FlowRow(
Expand Down Expand Up @@ -128,27 +134,17 @@ fun LegView(
color = timelineColor,
strokeWidth = strokeWidth,
)
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
onClick = { displayNonProminentStops = !displayNonProminentStops },
role = Role.Button,
)
.padding(start = 16.dp, top = 12.dp),
) {
if (stops.size > 2) {
val context = LocalContext.current
StopsRow(
// Need to pass count twice - https://developer.android.com/guide/topics/resources/string-resource#Plurals
stops = if (displayNonProminentStops) {
"Hide stops"
} else {
context.resources.getQuantityString(
R.plurals.stops,
stops.size - 2,
stops.size - 2,
)
},
stops = context.resources.getQuantityString(
R.plurals.stops,
stops.size - 2,
stops.size - 2,
),
line = transportModeLine,
)
} else {
Expand Down
4 changes: 2 additions & 2 deletions feature/trip-planner/ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<string name="to_text_field_placeholder">To Destination</string>
<string name="time_table_screen_title">Time Table</string>
<plurals name="stops">
<item quantity="one">Show %d stop</item>
<item quantity="other">Show %d stops</item>
<item quantity="one">%d stop</item>
<item quantity="other">%d stops</item>
</plurals>
</resources>