Giter Site home page Giter Site logo

compose-ratingbar's Introduction

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.3.4'
  //mavenCentral
  // implementation 'io.github.a914-gowtham:compose-ratingbar:1.2.3'

}

Usage

   import androidx.compose.runtime.*

   var rating: Float by remember { mutableStateOf(3.2f) }

   RatingBar(
       value = rating,
       style = RatingBarStyle.Fill(),
       onValueChange = {
           rating = it
       },
       onRatingChanged = {
           Log.d("TAG", "onRatingChanged: $it")
       }
   )

Other optional params:

  fun RatingBar(
      value: Float,
      modifier: Modifier = Modifier,
      numOfStars: Int = 5,
      size: Dp = 32.dp,
      spaceBetween: Dp = 6.dp,
      isIndicator: Boolean = false,
      stepSize: StepSize = StepSize.ONE,
      hideInactiveStars: Boolean = false,
      style: RatingBarStyle,
      onValueChange: (Float) -> Unit,
      onRatingChanged: (Float) -> Unit
)

More Customization✨

Icon can be changed using painterEmpty painterFilled params.

        RatingBar(
            value = rating,
            painterEmpty = painterResource(id = R.drawable.icon_empty),
            painterFilled = painterResource(id = R.drawable.icon_filled),
            onValueChange = {
                rating = it
            },
            onRatingChanged = {
                Log.d("TAG", "onRatingChanged: $it")
            }
        )

Library Info

  • Forked from compose-rating-bar
  • 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

compose-ratingbar's People

Contributors

a914-gowtham avatar victorkabata avatar orlandev avatar cybercoder-naj avatar fxeio avatar victorhvs avatar edward1988 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.