Optimize SimpleRatingWidget

This commit is contained in:
tarsin committed 2023-02-25 23:19:09 +08:00
1 parent 624a20c9bf
commit fa4d35487c
1 file changed
+3 -2
@@ -11,13 +11,14 @@ import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import com.hippo.ehviewer.R
private val colorYellow800 = Color(0xfff9a825)
@Composable
fun SimpleRatingWidget(rating: Float) {
val r = (rating * 2).toInt().coerceAtLeast(0).coerceAtMost(10)
val r = (rating * 2).toInt().coerceIn(0, 10)
val fullStar = r.floorDiv(2)
val halfStar = r % 2
val outlineStar = 5 - fullStar - halfStar
val colorYellow800 = Color(0xfff9a825)
Row {
repeat(fullStar) {
Icon(