Kwik Rating Bar
fun KwikRatingBar(modifier: Modifier = Modifier, rating: Double = 0.0, stars: Int = 5, starsColor: Color = KwikColorYellow, starSize: Dp = 24.dp, spacing: Dp = 2.dp, showBadge: Boolean = true, badgeContainerColor: Color = determineRatingColor(rating), badgeContentColor: Color = Color.DarkGray, clickable: Boolean = false, onClick: (Int) -> Unit = {})
A rating bar that displays and optionally allows setting a rating using stars.
Parameters
modifier
The modifier to apply to this layout.
rating
The initial rating to display (0.0 when clickable mode is enabled).
stars
The total number of stars to display.
stars Color
The color of the filled stars.
star Size
The size of each star icon.
spacing
The spacing between stars.
show Badge
Whether to show a badge displaying the numerical rating.
badge Container Color
The background color of the badge, determined by rating by default.
badge Content Color
The text color of the badge.
clickable
Whether stars can be clicked to set a rating.
on Click
Callback function that receives the selected rating (1-5) when a star is clicked.
Example usage:
Display-only mode:
KwikRatingBar(
stars = 5,
rating = 4.5,
showBadge = true
)
Content copied to clipboard
Clickable mode:
var userRating by remember { mutableStateOf(0) }
KwikRatingBar(
stars = 5,
rating = userRating.toDouble(),
clickable = true,
onClick = { selectedRating ->
userRating = selectedRating
}
)
Content copied to clipboard