Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request (possibly just for advice): A star slider with half-star values #27

Closed
NCrusher74 opened this issue Jan 17, 2021 · 1 comment
Closed

Comments

@NCrusher74
Copy link

NCrusher74 commented Jan 17, 2021

There are tutorials available for how to make a star rating UI component, but I'm really hoping to do something a little more complicated, and I think it's going to require handling the rating as a slider (with an invisible knob).

My idea is that the "bar" will be a row of five stars and then sliding along it results in this:

0.0 = "star" x 5
0.5 = ("star.leadinghalf.fill" x 1) + ("star" x 4)
1.0 = ("star.fill" x 1) + ("star" x 4)
1.5 = ("star.fill" x 1) + ("star.leadinghalf.fill" x 1) + ("star" x 3)
.. and so forth up to ("star.fill" x 5)

I've tried altering your sliders to do something like this, and clearly I did it wrong because any attempt to "slide" along the row resulted in the row of stars changing position on the screen.

Is this something that should be handled as a slider, or should I instead perhaps handle it so that each star is a button that starts at "star (empty)" and changes to "star.leadinghalf.fill" the first time it's tapped, and then to "star.fill" if it's tapped again, before cycling back to being empty?

@ay42
Copy link
Member

ay42 commented Oct 2, 2021

@NCrusher74 probably too late for an answer but you can do this with masking views

Thumb = EmptyView()
Slider background = Row of grey stars
Slider track = Row of yellow stars
Slider track mask = Rectangle

I would go for a custom RatingView instead.

@ay42 ay42 closed this as completed Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants