Help! I don’t know if it’s a compose thing or a ko...
# compose
m
Help! I don’t know if it’s a compose thing or a kotlin thing or whatever - but my composable preview is performing a hell of a round-error (Code in thread)
Copy code
data class CrossingInfo(
    val actualStreetName: String,
    val nextStreetName: String,
    val pictoFileName: String,
    val streetType: CrosswayStreetType,
    val metersToCrossing: Double,
    val secondsToCrossing: Double
)
Copy code
@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}")
        }
    }
}
Copy code
@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
    ))
}
That’s a bit TOO large, huh?
Funny thing is:
Copy code
import kotlin.math.roundToLong

fun main() {
    println(150.0.roundToLong())
}
prints
150
in play.kotlinlang.org
OK - forget about it… I found it… It is that large because the expected
150
is prefixed by a resource id… should have put `stringResource()`around