@@ -13,8 +13,6 @@ public struct HorizontalRangeSliderStyle<Track: View, LowerThumb: View, UpperThu
13
13
14
14
private let options : RangeSliderOptions
15
15
16
- let onSelectLower : ( ) -> Void
17
- let onSelectUpper : ( ) -> Void
18
16
19
17
public func makeBody( configuration: Self . Configuration ) -> some View {
20
18
GeometryReader { geometry in
@@ -45,15 +43,11 @@ public struct HorizontalRangeSliderStyle<Track: View, LowerThumb: View, UpperThu
45
43
) ,
46
44
y: geometry. size. height / 2
47
45
)
48
- . onTapGesture {
49
- self . onSelectLower ( )
50
- }
51
46
. gesture (
52
- DragGesture ( )
47
+ DragGesture ( minimumDistance : 0 )
53
48
. onChanged { gestureValue in
54
49
configuration. onEditingChanged ( true )
55
50
56
- self . onSelectLower ( )
57
51
58
52
if configuration. dragOffset. wrappedValue == nil {
59
53
configuration. dragOffset. wrappedValue = gestureValue. startLocation. x - distanceFrom(
@@ -103,15 +97,11 @@ public struct HorizontalRangeSliderStyle<Track: View, LowerThumb: View, UpperThu
103
97
) ,
104
98
y: geometry. size. height / 2
105
99
)
106
- . onTapGesture {
107
- self . onSelectUpper ( )
108
- }
109
100
. gesture (
110
- DragGesture ( )
101
+ DragGesture ( minimumDistance : 0 )
111
102
. onChanged { gestureValue in
112
103
configuration. onEditingChanged ( true )
113
104
114
- self . onSelectUpper ( )
115
105
116
106
if configuration. dragOffset. wrappedValue == nil {
117
107
configuration. dragOffset. wrappedValue = gestureValue. startLocation. x - distanceFrom(
@@ -152,9 +142,7 @@ public struct HorizontalRangeSliderStyle<Track: View, LowerThumb: View, UpperThu
152
142
. frame ( minHeight: max ( self . lowerThumbInteractiveSize. height, self . upperThumbInteractiveSize. height) )
153
143
}
154
144
155
- public init ( track: Track , lowerThumb: LowerThumb , upperThumb: UpperThumb , lowerThumbSize: CGSize = CGSize ( width: 27 , height: 27 ) , upperThumbSize: CGSize = CGSize ( width: 27 , height: 27 ) , lowerThumbInteractiveSize: CGSize = CGSize ( width: 44 , height: 44 ) , upperThumbInteractiveSize: CGSize = CGSize ( width: 44 , height: 44 ) , options: RangeSliderOptions = . defaultOptions,
156
- onSelectLower: @escaping ( ) -> Void = { } ,
157
- onSelectUpper: @escaping ( ) -> Void = { } ) {
145
+ public init ( track: Track , lowerThumb: LowerThumb , upperThumb: UpperThumb , lowerThumbSize: CGSize = CGSize ( width: 27 , height: 27 ) , upperThumbSize: CGSize = CGSize ( width: 27 , height: 27 ) , lowerThumbInteractiveSize: CGSize = CGSize ( width: 44 , height: 44 ) , upperThumbInteractiveSize: CGSize = CGSize ( width: 44 , height: 44 ) , options: RangeSliderOptions = . defaultOptions) {
158
146
self . track = track
159
147
self . lowerThumb = lowerThumb
160
148
self . upperThumb = upperThumb
@@ -163,15 +151,12 @@ public struct HorizontalRangeSliderStyle<Track: View, LowerThumb: View, UpperThu
163
151
self . lowerThumbInteractiveSize = lowerThumbInteractiveSize
164
152
self . upperThumbInteractiveSize = upperThumbInteractiveSize
165
153
self . options = options
166
- self . onSelectLower = onSelectLower
167
- self . onSelectUpper = onSelectUpper
168
154
}
169
155
}
170
156
171
157
extension HorizontalRangeSliderStyle where Track == DefaultHorizontalRangeTrack {
172
158
public init ( lowerThumb: LowerThumb , upperThumb: UpperThumb , lowerThumbSize: CGSize = CGSize ( width: 27 , height: 27 ) , upperThumbSize: CGSize = CGSize ( width: 27 , height: 27 ) , lowerThumbInteractiveSize: CGSize = CGSize ( width: 44 , height: 44 ) , upperThumbInteractiveSize: CGSize = CGSize ( width: 44 , height: 44 ) , options: RangeSliderOptions = . defaultOptions,
173
- onSelectLower: @escaping ( ) -> Void = { } ,
174
- onSelectUpper: @escaping ( ) -> Void = { } ) {
159
+ ) {
175
160
self . track = DefaultHorizontalRangeTrack ( )
176
161
self . lowerThumb = lowerThumb
177
162
self . upperThumb = upperThumb
@@ -180,16 +165,13 @@ extension HorizontalRangeSliderStyle where Track == DefaultHorizontalRangeTrack
180
165
self . lowerThumbInteractiveSize = lowerThumbInteractiveSize
181
166
self . upperThumbInteractiveSize = upperThumbInteractiveSize
182
167
self . options = options
183
- self . onSelectLower = onSelectLower
184
- self . onSelectUpper = onSelectUpper
185
168
186
169
}
187
170
}
188
171
189
172
extension HorizontalRangeSliderStyle where LowerThumb == DefaultThumb , UpperThumb == DefaultThumb {
190
173
public init ( track: Track , lowerThumbSize: CGSize = CGSize ( width: 27 , height: 27 ) , upperThumbSize: CGSize = CGSize ( width: 27 , height: 27 ) , lowerThumbInteractiveSize: CGSize = CGSize ( width: 44 , height: 44 ) , upperThumbInteractiveSize: CGSize = CGSize ( width: 44 , height: 44 ) , options: RangeSliderOptions = . defaultOptions,
191
- onSelectLower: @escaping ( ) -> Void = { } ,
192
- onSelectUpper: @escaping ( ) -> Void = { } ) {
174
+ ) {
193
175
self . track = track
194
176
self . lowerThumb = DefaultThumb ( )
195
177
self . upperThumb = DefaultThumb ( )
@@ -198,16 +180,13 @@ extension HorizontalRangeSliderStyle where LowerThumb == DefaultThumb, UpperThum
198
180
self . lowerThumbInteractiveSize = lowerThumbInteractiveSize
199
181
self . upperThumbInteractiveSize = upperThumbInteractiveSize
200
182
self . options = options
201
- self . onSelectLower = onSelectLower
202
- self . onSelectUpper = onSelectUpper
203
183
204
184
}
205
185
}
206
186
207
187
extension HorizontalRangeSliderStyle where LowerThumb == DefaultThumb , UpperThumb == DefaultThumb , Track == DefaultHorizontalRangeTrack {
208
188
public init ( lowerThumbSize: CGSize = CGSize ( width: 27 , height: 27 ) , upperThumbSize: CGSize = CGSize ( width: 27 , height: 27 ) , lowerThumbInteractiveSize: CGSize = CGSize ( width: 44 , height: 44 ) , upperThumbInteractiveSize: CGSize = CGSize ( width: 44 , height: 44 ) , options: RangeSliderOptions = . defaultOptions,
209
- onSelectLower: @escaping ( ) -> Void = { } ,
210
- onSelectUpper: @escaping ( ) -> Void = { } ) {
189
+ ) {
211
190
self . track = DefaultHorizontalRangeTrack ( )
212
191
self . lowerThumb = DefaultThumb ( )
213
192
self . upperThumb = DefaultThumb ( )
@@ -216,8 +195,6 @@ extension HorizontalRangeSliderStyle where LowerThumb == DefaultThumb, UpperThum
216
195
self . lowerThumbInteractiveSize = lowerThumbInteractiveSize
217
196
self . upperThumbInteractiveSize = upperThumbInteractiveSize
218
197
self . options = options
219
- self . onSelectLower = onSelectLower
220
- self . onSelectUpper = onSelectUpper
221
198
}
222
199
}
223
200
0 commit comments