Hi, is there `RatingBar` on Compose?
# compose
a
Hi, is there
RatingBar
on Compose?
🚫 2
a
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
Thanks! (and thanks for not adding it officially)
g
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
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
Now, make a library for itt!
g
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
Yes, search for it or create a lib for that OpenSource rules!
j
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
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
we in fact use it in our app 😅
😄 1