@@ -20,16 +20,22 @@ extension RangeSlider {
2020}
2121
2222extension RangeSlider {
23- public init < V> ( range: Binding < ClosedRange < V > > , in bounds: ClosedRange < V > = 0.0 ... 1.0 , step: V . Stride = 0.001 , onEditingChanged: @escaping ( Bool ) -> Void = { _ in } ) where V : BinaryFloatingPoint , V. Stride : BinaryFloatingPoint {
24-
23+ public init < V> (
24+ range: Binding < ClosedRange < V > > ,
25+ in bounds: ClosedRange < V > = 0.0 ... 1.0 ,
26+ step: V . Stride = 0.001 ,
27+ distance: ClosedRange < V > = 0.0 ... . infinity,
28+ onEditingChanged: @escaping ( Bool ) -> Void = { _ in }
29+ ) where V : BinaryFloatingPoint , V. Stride : BinaryFloatingPoint {
2530 self . init (
2631 RangeSliderStyleConfiguration (
2732 range: Binding (
28- get: { CGFloat ( range. wrappedValue. clamped ( to: bounds) . lowerBound) ... CGFloat ( range. wrappedValue. clamped ( to: bounds) . upperBound) } ,
29- set: { range. wrappedValue = V ( $0. lowerBound) ... V ( $0. upperBound) }
33+ get: { CGFloat ( range. wrappedValue. clamped ( to: bounds) . lowerBound) ... CGFloat ( range. wrappedValue. clamped ( to: bounds) . upperBound) } ,
34+ set: { range. wrappedValue = V ( $0. lowerBound) ... V ( $0. upperBound) }
3035 ) ,
31- bounds: CGFloat ( bounds. lowerBound) ... CGFloat ( bounds. upperBound) ,
36+ bounds: CGFloat ( bounds. lowerBound) ... CGFloat ( bounds. upperBound) ,
3237 step: CGFloat ( step) ,
38+ distance: CGFloat ( distance. lowerBound) ... CGFloat ( distance. upperBound) ,
3339 onEditingChanged: onEditingChanged,
3440 dragOffset: . constant( 0 )
3541 )
@@ -38,16 +44,22 @@ extension RangeSlider {
3844}
3945
4046extension RangeSlider {
41- public init < V> ( range: Binding < ClosedRange < V > > , in bounds: ClosedRange < V > = 0 ... 1 , step: V . Stride = 1 , onEditingChanged: @escaping ( Bool ) -> Void = { _ in } ) where V : BinaryInteger , V. Stride : BinaryInteger {
42-
47+ public init < V> (
48+ range: Binding < ClosedRange < V > > ,
49+ in bounds: ClosedRange < V > = 0 ... 1 ,
50+ step: V . Stride = 1 ,
51+ distance: ClosedRange < V > = 0 ... . max,
52+ onEditingChanged: @escaping ( Bool ) -> Void = { _ in }
53+ ) where V : FixedWidthInteger , V. Stride : FixedWidthInteger {
4354 self . init (
4455 RangeSliderStyleConfiguration (
4556 range: Binding (
46- get: { CGFloat ( range. wrappedValue. lowerBound) ... CGFloat ( range. wrappedValue. upperBound) } ,
47- set: { range. wrappedValue = V ( $0. lowerBound) ... V ( $0. upperBound) }
57+ get: { CGFloat ( range. wrappedValue. lowerBound) ... CGFloat ( range. wrappedValue. upperBound) } ,
58+ set: { range. wrappedValue = V ( $0. lowerBound) ... V ( $0. upperBound) }
4859 ) ,
49- bounds: CGFloat ( bounds. lowerBound) ... CGFloat ( bounds. upperBound) ,
60+ bounds: CGFloat ( bounds. lowerBound) ... CGFloat ( bounds. upperBound) ,
5061 step: CGFloat ( step) ,
62+ distance: CGFloat ( distance. lowerBound) ... CGFloat ( distance. upperBound) ,
5163 onEditingChanged: onEditingChanged,
5264 dragOffset: . constant( 0 )
5365 )
@@ -59,7 +71,9 @@ struct RangeSlider_Previews: PreviewProvider {
5971 static var previews : some View {
6072 Group {
6173 HorizontalRangeSlidersPreview ( )
74+ . previewDisplayName ( " Horizontal Range Sliders " )
6275 VerticalRangeSlidersPreview ( )
76+ . previewDisplayName ( " Vertical Range Sliders " )
6377 }
6478 }
6579}
@@ -76,7 +90,7 @@ private struct HorizontalRangeSlidersPreview: View {
7690 VStack {
7791 RangeSlider ( range: $range1)
7892
79- RangeSlider ( range: $range2)
93+ RangeSlider ( range: $range2, distance : 0.3 ... 1.0 )
8094 . rangeSliderStyle (
8195 HorizontalRangeSliderStyle (
8296 track:
@@ -180,7 +194,7 @@ private struct VerticalRangeSlidersPreview: View {
180194 VerticalRangeSliderStyle ( )
181195 )
182196
183- RangeSlider ( range: $range2)
197+ RangeSlider ( range: $range2, distance : 0.5 ... 0.7 )
184198 . rangeSliderStyle (
185199 VerticalRangeSliderStyle (
186200 track:
0 commit comments