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

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")
            })
     }

Ratingbar composable function has 11 params with default value as shown below

fun RatingBar(
    modifier: Modifier = Modifier,
    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, 
    ratingBarStyle: RatingBarStyle=RatingBarStyle.Normal,
    onRatingChanged: (Float) -> Unit
)

Acknowledgement

Library Info

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