Mario Adam
06/13/2023, 2:20 PMMario Adam
06/13/2023, 2:21 PMdata class CrossingInfo(
val actualStreetName: String,
val nextStreetName: String,
val pictoFileName: String,
val streetType: CrosswayStreetType,
val metersToCrossing: Double,
val secondsToCrossing: Double
)
@Composable
fun CoiInfo(modifier: Modifier = Modifier, crossingInfo: CrossingInfo?) {
Column(modifier, verticalArrangement = Arrangement.spacedBy(4.dp)) {
if (crossingInfo?.metersToCrossing != null) {
Text("${crossingInfo.metersToCrossing.roundToLong()}${R.string.meterAbbreviation}")
}
}
}
@Preview(
showBackground = true, name = "Light mode"
)
@Preview(
showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES, name = "Dark mode"
)
@Composable
fun CoiInfoPreview() {
CoiInfo(crossingInfo = CrossingInfo(
"Some street",
"Some other street",
"coi_uturn",
CrosswayStreetType.UTURN,
150.0,
10.0
))
}
Mario Adam
06/13/2023, 2:22 PMMario Adam
06/13/2023, 2:22 PMimport kotlin.math.roundToLong
fun main() {
println(150.0.roundToLong())
}
prints 150
in play.kotlinlang.orgMario Adam
06/13/2023, 2:30 PM150
is prefixed by a resource id… should have put `stringResource()`around