TomThorpe / TTRangeSlider

A slider, similar in style to UISlider, but which allows you to pick a minimum and maximum range.
MIT License
968 stars 204 forks source link

A text label versus number format for values displayed above min/max value #114

Closed MarcCJohnson closed 2 years ago

MarcCJohnson commented 3 years ago

It would be nice to be able to display a text label over the min/max value based upon that value.

example one: if min range value is < 10 but > 5 "a small value" but > 10 "a bigger value"

example two: # of seconds to display the time above the slider's min/max value

So generally a text label that uses the numeric value to calculate something a bit more complex than numeric format.

MarcCJohnson commented 2 years ago

Created a pull request with this in it yesterday for your evaluation.

MarcCJohnson commented 2 years ago

Checking back on this... been using it in my project. Please let me know if you have any questions/concerns.

TomThorpe commented 2 years ago

Hi Marc,

Sorry for the long delay on this. If I'm honest I don't really maintain this project anymore, although I do still appreciate peoples input and help!

For your suggestion (and the PR you raised), would it not be possible to use the existing numberFormatterOverride property instead? The intention of this from the readme is:

numberFormatterOverride

Each handle in the slider has a label above it showing the current selected value. By default, this is displayed as a decimal format.

You can override this default here by supplying your own NSNumberFormatter. For example, you could supply an NSNumberFormatter that has a currency style, or a prefix or suffix.

So by subclassing NSNumberFormatter and having it do whatever you want, you could then format the min and max labels however you want?

Thanks for your input, Tom

MarcCJohnson commented 2 years ago

My use case was/is to replace the labels with time format which could have included text like dd/mmm-Yy or really any date format, so more than overriding a number format. I did implement a solution and created a pull request that implements an optional method on the ttrangesliderdelegate with a working example. I see there's option to request a review of it that I thought I'd used but maybe not. I am new to using GitHub even though I've been around it forever.

TomThorpe commented 2 years ago

Hey Marc,

No problem at all, I do see the pull request there, however, I think you can already perform this functionality using the numberFormatterOverride property that already exists.

I really appreciate your input though nonetheless, especially as you're new to using Github. You did all the right things :-) It's just that I think this feature is already possible.

Thanks again though :-)