KPRatingBar

fun KPRatingBar(rating: Float, size: RatingBarSize, modifier: Modifier = Modifier, itemCount: Int = 5, reviewCount: String? = null, showRating: Boolean = false, showCameraIcon: Boolean = false, itemSize: Dp = size.starIconSize, spaceBetween: Dp = 2.dp, icon: ImageVector = KPIcons.Fill.Star, filledColor: Color = KPDesign.colors.colorStar, emptyColor: Color = KPDesign.colors.colorBorder, onRatingClick: (rate: Int) -> Unit? = null)

A composable function that renders a rating bar with customizable styles and parameters.

This KPRatingBar function provides a flexible way to display a rating with stars, optionally showing the rating value, a review count, and a camera icon. The stars can be customized in terms of size, spacing, and colors. The function uses a Canvas to draw the stars and supports vector images for the star icons.

Parameters

rating

The current rating value to be displayed. It is a Float value representing the rating.

size

The size and style to be applied to the rating bar, defined by the RatingBarSize sealed interface.

modifier

The modifier to apply to the rating bar for layout adjustments and styling.

itemCount

The number of stars to be displayed in the rating bar.

reviewCount

An optional parameter to display the count of reviews as a String.

showRating

A Boolean indicating whether to show the rating value text.

showCameraIcon

A Boolean indicating whether to show a camera icon at the end of the rating bar.

itemSize

The size of each star in the rating bar.

spaceBetween

The space between each star in the rating bar.

icon

The resource of the image vector to use for the stars.

emptyColor

The color of the empty stars.

filledColor

The color of the filled stars.

onRatingClick

An optional function to rate, returns clicked star index plus one as Int.