Skip to content

a914-gowtham/compose-ratingbar

Repository files navigation

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.0.1'
}

Usage

    var value: Float by rememberSaveable { mutableStateOf(3.2f) }  //initial rating value is 3.2 here
    Column(){
       RatingBar(value = value,onRatingChanged = {
                value=it
                Log.d("TAG", "onRatingChanged: $it")
            })
     }

It has 10 params with default value as shown below

fun RatingBar(
    value: Float = 0f,
    numStars: Int = 5, size: Dp = 26.dp, padding: Dp = 2.dp,
    isIndicator: Boolean = false, activeColor: Color = Color(0xffffd740),
    inactiveColor: Color = Color(0xffffecb3),
    stepSize: StepSize = StepSize.ONE, onRatingChanged: (Float) -> Unit,
    ratingBarStyle: RatingBarStyle=RatingBarStyle.Normal
)

Library Info

  • Current version of the library only supports Stepsize 1f and 0.5f