So I made something working, for which I joined th...
# compose
t
So I made something working, for which I joined the output when using
Copy code
Rating(4.3F, 5)
Is there anything wrong with what I have done? Will I have performances issue? ­čś« Thanks for your help.
Copy code
@Composable
fun Rating(score: Float, maxScore: Int, modifier: Modifier = Modifier, tint: Color = Color.Yellow) {
    val shape = remember(score) {
        val rate = score - score.toInt()
        GenericShape { size ->
            lineTo(size.width * rate, 0f)
            lineTo(size.width * rate, size.height)
            lineTo(0f, size.height)
        }
    }
    val icon = vectorResource(id = R.drawable.ic_star)

    Row(modifier = modifier) {
        for (i in 0 until maxScore) {
            if (i + 1 < score) {
                Icon(
                    imageVector = icon,
                    tint = tint,
                )
            } else if (i < score) {
                Box {
                    Icon(
                        imageVector = icon,
                    )
                    Icon(
                        imageVector = icon,
                        tint = tint,
                        modifier = Modifier.clip(shape),
                    )
                }
            } else {
                Icon(
                    imageVector = icon,
                )
            }
        }
    }
}
ÔşÉ 8