Compose-Ratingbar
A ratingbar for jetpack compose
Download
Add in project build.gradle:
repositories {
maven { url 'https://jitpack.io' }
}
// App build.gradle
dependencies {
implementation 'com.github.a914-gowtham:compose-ratingbar:1.1.1'
//mavenCentral
// implementation 'io.github.a914-gowtham:compose-ratingbar:1.1.1'
}
Usage
import androidx.compose.runtime.*
var rating: Float by remember { mutableStateOf(initialRating) }
RatingBar(
value = rating,
config = RatingBarConfig()
.style(RatingBarStyle.HighLighted),
onValueChange = {
rating = it
},
onRatingChanged = {
Log.d("TAG", "onRatingChanged: $it")
}
)
Ratingbar composable function has 13 params with default value as shown below:
fun RatingBar(
value: Float,
modifier: Modifier = Modifier,
config: RatingBarConfig = RatingBarConfig(),
onValueChange: (Float) -> Unit,
onRatingChanged: (Float) -> Unit
)
Library Info
- Current version of the library only supports Stepsize 1f and 0.5f when click or drag. However, Initial Rating value could be any float value like 3.8 etc.
Show some ❤ and support
Give a ⭐️ if this project helped you!