Fix rating calculate

This commit is contained in:
tarsin committed 2023-02-25 23:47:10 +08:00
1 parent 83dc47c3b5
commit 957ecf0fe1
1 file changed
+3 -2
@@ -10,13 +10,14 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import com.hippo.ehviewer.R
import kotlin.math.ceil
private val colorYellow800 = Color(0xfff9a825)
@Composable
fun SimpleRatingWidget(rating: Float) {
val r = (rating * 2).toInt().coerceIn(0, 10)
val fullStar = r.floorDiv(2)
val r = ceil(rating * 2).toInt().coerceIn(0, 10)
val fullStar = r / 2
val halfStar = r % 2
val outlineStar = 5 - fullStar - halfStar
Row {