@swmansion/react-native-bottom-sheet 0.7.0-next.3 → 0.7.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -28,6 +28,7 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
28
28
|
private var pendingIndex: Int?
|
|
29
29
|
private var hasLaidOut = false
|
|
30
30
|
private var isPanning = false
|
|
31
|
+
private var isContentInteractionDisabled = false
|
|
31
32
|
|
|
32
33
|
public override init(frame: CGRect) {
|
|
33
34
|
super.init(frame: frame)
|
|
@@ -40,6 +41,9 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
40
41
|
|
|
41
42
|
panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:)))
|
|
42
43
|
panGesture.delegate = self
|
|
44
|
+
panGesture.cancelsTouchesInView = true
|
|
45
|
+
panGesture.delaysTouchesBegan = true
|
|
46
|
+
panGesture.delaysTouchesEnded = true
|
|
43
47
|
sheetContainer.addGestureRecognizer(panGesture)
|
|
44
48
|
}
|
|
45
49
|
|
|
@@ -166,6 +170,17 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
166
170
|
displayLink = nil
|
|
167
171
|
}
|
|
168
172
|
|
|
173
|
+
private func setContentInteractionEnabled(_ isEnabled: Bool) {
|
|
174
|
+
if isContentInteractionDisabled == !isEnabled {
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
for subview in sheetContainer.subviews {
|
|
179
|
+
subview.isUserInteractionEnabled = isEnabled
|
|
180
|
+
}
|
|
181
|
+
isContentInteractionDisabled = !isEnabled
|
|
182
|
+
}
|
|
183
|
+
|
|
169
184
|
@objc private func displayLinkFired() {
|
|
170
185
|
emitPosition()
|
|
171
186
|
}
|
|
@@ -194,6 +209,7 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
194
209
|
self.stopDisplayLink()
|
|
195
210
|
self.emitPosition()
|
|
196
211
|
self.activeAnimator = nil
|
|
212
|
+
self.setContentInteractionEnabled(true)
|
|
197
213
|
self.eventDelegate?.bottomSheetHostingView(self, didChangeIndex: index)
|
|
198
214
|
}
|
|
199
215
|
animator.startAnimation()
|
|
@@ -207,6 +223,7 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
207
223
|
switch gesture.state {
|
|
208
224
|
case .began:
|
|
209
225
|
isPanning = true
|
|
226
|
+
setContentInteractionEnabled(false)
|
|
210
227
|
gesture.setTranslation(.zero, in: self)
|
|
211
228
|
if let animator = activeAnimator {
|
|
212
229
|
stopDisplayLink()
|
|
@@ -234,6 +251,7 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
234
251
|
|
|
235
252
|
case .failed:
|
|
236
253
|
isPanning = false
|
|
254
|
+
setContentInteractionEnabled(true)
|
|
237
255
|
|
|
238
256
|
default:
|
|
239
257
|
break
|
|
@@ -291,6 +309,19 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
291
309
|
}
|
|
292
310
|
|
|
293
311
|
extension RNSBottomSheetHostingView: UIGestureRecognizerDelegate {
|
|
312
|
+
public func gestureRecognizer(
|
|
313
|
+
_ gestureRecognizer: UIGestureRecognizer,
|
|
314
|
+
shouldRequireFailureOf other: UIGestureRecognizer
|
|
315
|
+
) -> Bool {
|
|
316
|
+
guard gestureRecognizer === panGesture else { return false }
|
|
317
|
+
|
|
318
|
+
if other is UITapGestureRecognizer {
|
|
319
|
+
return true
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return false
|
|
323
|
+
}
|
|
324
|
+
|
|
294
325
|
public func gestureRecognizer(
|
|
295
326
|
_ gestureRecognizer: UIGestureRecognizer,
|
|
296
327
|
shouldBeRequiredToFailBy other: UIGestureRecognizer
|
package/package.json
CHANGED