https://kotlinlang.org logo
#compose
Title
# compose
a

alorma

10/29/2020, 7:21 AM
Hi, is there
RatingBar
on Compose?
🚫 2
a

Adam Powell

10/29/2020, 1:45 PM
This should be straightforward enough to write if you need one but we do not plan to offer an official one at this time
a

alorma

10/29/2020, 2:37 PM
Thanks! (and thanks for not adding it officially)
g

Grigorii Yurkov

10/29/2020, 3:23 PM
I don't agree it's too easy to implement my own rating bar and therefore we don't need official one. Or maybe I don't know compose at a sufficient level 🤔
j

Jeisson Sáchica

10/29/2020, 4:28 PM
It is not that hard, I made one when following the movie app on Leland's stream. I could have used a premade vector and be much easier but I decided to do it with canvas to test the api and chanllenge myself. Here it is if you need it and feel free to play with it and modify it to your needs , I made it as two composables (one for the rating bar and one for each individual rating star). Also you are gonna need the extension function I created for the
Path
to actually draw the star and a fractional shape for clipping the empty and filled stars.
❤️ 1
It looks like this
👏 1
a

alorma

10/29/2020, 4:39 PM
Now, make a library for itt!
g

Grigorii Yurkov

10/29/2020, 4:40 PM
I argee, it's not so hard but it's hard enough to implement it in standard library. So every time I need rating bar I have to write my own or search for custom implementation?
a

alorma

10/29/2020, 4:44 PM
Yes, search for it or create a lib for that OpenSource rules!
j

Jeisson Sáchica

10/29/2020, 4:53 PM
I don't think this is a simple component that everyone needs it in the same way so I don't see it as an official component and especially at this early stage of compose where they have other priorities. The one I made does not have any user interaction and simply takes a rating
Float
and displays the stars so if you need to use it as an input thats your specific use case. I might make a basic library for it tho
a

Adam Powell

10/29/2020, 10:10 PM
That's really the biggest part of it: there's a huge difference between creating a RatingBar for your app, brand, and interaction model, and making one that is a styleable one true RatingBar for all, which is the bar that a standard/stock component needs to meet
I'm not sure I've seen two RatingBars in different top apps that behave alike; usage of
android.widget.RatingBar
dropped off sharply after around 2010, and the only user of it for many years was Android Market before they rebranded to Google Play
a

alorma

10/30/2020, 6:55 AM
we in fact use it in our app 😅
😄 1
26 Views