RangeSeekSlider icon indicating copy to clipboard operation
RangeSeekSlider copied to clipboard

Update format of the minLabel & maxLabel

Open fparkar opened this issue 7 years ago • 1 comments

Hello there, I would like to format the slider text (minimum label & maximum label) that are there on the left & right side.

Let me explain scenario.

I am making flight app where I am using this slider I have filter where I need to select the duration I have duration as 245 to 510 means 4 hrs 5 min to 8 hr 30 min. What I want to do is show 4 hrs 5 min instead of 245. Any idea how this customization can be done? I can handle the logic, however I am unable to find a place where I can set text. I have a function ready which will convert integer (245) to string (4 hrs 5 min).

fparkar avatar May 19 '18 18:05 fparkar

Thank you.

I found a solution.

I set tag as 99 for the hour slider and update below in updateLabelValues.

    if let replacedString = delegate?.rangeSeekSlider(self, stringForMinValue: selectedMinValue) {
        minLabel.string = replacedString
    } else {
        if (self.tag==99) {
            minLabel.string = "\(GlobalFunctions.minutesToHoursMinutes(minutes: Int(selectedMinValue)).hours)\("hourShort".localized()) \(GlobalFunctions.minutesToHoursMinutes(minutes: Int(selectedMinValue)).leftMinutes)\("minutesShort".localized())"
        } else {
            minLabel.string = numberFormatter.string(from: selectedMinValue as NSNumber)
        }
    }

    if let replacedString = delegate?.rangeSeekSlider(self, stringForMaxValue: selectedMaxValue) {
        maxLabel.string = replacedString
    } else {
        if (self.tag==99) {
            maxLabel.string = "\(GlobalFunctions.minutesToHoursMinutes(minutes: Int(selectedMaxValue)).hours)\("hourShort".localized()) \(GlobalFunctions.minutesToHoursMinutes(minutes: Int(selectedMaxValue)).leftMinutes)\("minutesShort".localized())"
        } else {
            maxLabel.string = numberFormatter.string(from: selectedMaxValue as NSNumber)
        }
    }

fparkar avatar May 19 '18 18:05 fparkar