fatemeh-afshari / compose-ratingbar

A ratingbar composable for jetpack compose :rocket::star2:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compose-Ratingbar

A ratingbar for jetpack compose

Maven Central

Download

Add in project build.gradle:

repositories {
    maven { url 'https://jitpack.io' }
}

// App build.gradle
dependencies {
   implementation 'com.github.a914-gowtham:compose-ratingbar:1.2.3'
  //mavenCentral
  // implementation 'io.github.a914-gowtham:compose-ratingbar:1.2.3'

}

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 can be customized using RatingBarConfig class as shown below:

        RatingBarConfig()
                .activeColor(Color.Yellow)
                .hideInactiveStars(true)
                .inactiveColor(Color.LightGray)
                .stepSize(StepSize.HALF)
                .numStars(10)
                .isIndicator(true)
                .size(24.dp)
                .padding(6.dp)
                .style(RatingBarStyle.HighLighted)

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!

Buy Me A Coffee

About

A ratingbar composable for jetpack compose :rocket::star2:

License:MIT License


Languages

Language:Kotlin 100.0%