Fix rating calculate

This commit is contained in:
tarsin committed 2023-03-09 18:07:30 +08:00
1 parent 23eede12fc
commit 1a7214c75b
1 file changed
+2 -2
@@ -10,13 +10,13 @@ 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
import kotlin.math.roundToInt
private val colorYellow800 = Color(0xfff9a825)
@Composable
fun SimpleRatingWidget(rating: Float) {
val r = ceil(rating * 2).toInt().coerceIn(0, 10)
val r = (rating * 2).roundToInt().coerceIn(0, 10)
val fullStar = r / 2
val halfStar = r % 2
val outlineStar = 5 - fullStar - halfStar