spacenation / swiftui-sliders

:rocket: SwiftUI Sliders with custom styles
MIT License
820 stars 87 forks source link

The thumbs don't show for me. #20

Closed jimijon closed 4 years ago

jimijon commented 4 years ago

Used a simple example:

RangeSlider(range: $range)
                                   .rangeSliderStyle(
                                       HorizontalRangeSliderStyle(
                                           track:
                                               HorizontalRangeTrack(
                                                   view: Capsule().foregroundColor(.purple)
                                               )
                                               .background(Capsule().foregroundColor(Color.purple.opacity(0.25)))
                                               .frame(height: 8),
                                           lowerThumb: Circle().foregroundColor(.purple),
                                           upperThumb: Circle().foregroundColor(.purple),
                                           lowerThumbSize: CGSize(width: 32, height: 32),
                                           upperThumbSize: CGSize(width: 32, height: 32),
                                           options: .forceAdjacentValue
                                       )
                                   )

But the thumbs don't show. Any ideas?

ay42 commented 4 years ago

@jimijon probably your range value is outside of a default 0..1 range

jimijon commented 4 years ago

_value ClosedRange -25...115

This use to work in the old version... I think v0.6

ay42 commented 4 years ago

@jimijon it defaults to in bounds: ClosedRange<V> = 0.0...1.0 change it to your range and I think it will work.

jimijon commented 4 years ago

OH THE INITS! I missed those (upgrading threw me off)

This fixes both of my issues:

return RangeSlider(range: $range, in: lBound...uBound, step: 1, onEditingChanged: { value in if !value {self.queryCallback()}}) .rangeSliderStyle( HorizontalRangeSliderStyle(

                track:
                HorizontalRangeTrack(
                    view: Capsule().foregroundColor(Color("TPOrange"))
                )
                    .background(Capsule().foregroundColor(Color("TPOrange").opacity(0.30)))
                    .frame(height: 8),
                lowerThumb: Circle().foregroundColor(Color(UIColor(named: "TPLightGrey")!)),
                upperThumb: Circle().foregroundColor(Color(UIColor(named: "TPLightGrey")!)),
                lowerThumbSize: CGSize(width: 32, height: 32),
                upperThumbSize: CGSize(width: 32, height: 32),
                options: .forceAdjacentValue
                )

    ).padding([.horizontal]).frame(height: 64)