ChargeMap / Compose-NumberPicker

Jetpack Compose Number Picker
236 stars 33 forks source link

Consider supporting negative numbers or some type of "rollover" #1

Open pandasys opened 2 years ago

pandasys commented 2 years ago

Example, I display hours minutes seconds to allow the user to enter the duration of a piece of media. They can perform searches on how long a song is - show me all songs over 10 minutes.

For my seconds picker I give the range -1..60. My label function emits an empty string for -1 and 60. When the picker hits 60, I increment my "minutes" and set the "seconds" picker value to 0. Effectively the change is from 0:0:59 to 0:1:0. Works nicely with little effort on my part. The opposite does not work as the picker can never go below 0.

If I set a picker to -1..N, it will display -1 as the smallest value but does not allow me to move to that number. I've only glanced at the code, but could the picker possibly be genericized to work over any ClosedRange using start, endInclusive, and step functions? I'm only concerned with numbers at the moment, but seems this could be an even more versitale widget - a range value picker.

Thanks for publishing this. Very useful as is.

r4phab commented 2 years ago

Hi @pandasys, Thank you for the time taken to describe the issue, I'll surely try to address this soon !