@swmansion/react-native-bottom-sheet 0.7.0-next.3 → 0.7.0-next.5
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.
- package/android/src/main/java/com/swmansion/reactnativebottomsheet/BottomSheetView.kt +11 -0
- package/ios/BottomSheetComponentView.mm +6 -0
- package/ios/BottomSheetContentView.h +1 -0
- package/ios/BottomSheetContentView.mm +5 -0
- package/ios/RNSBottomSheetHostingView.swift +47 -0
- package/package.json +1 -1
|
@@ -408,8 +408,19 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
|
|
|
408
408
|
|
|
409
409
|
fun destroy() {
|
|
410
410
|
activeAnimation?.cancel()
|
|
411
|
+
activeAnimation = null
|
|
411
412
|
stopChoreographer()
|
|
412
413
|
velocityTracker?.recycle()
|
|
413
414
|
velocityTracker = null
|
|
415
|
+
detentSpecs = emptyList()
|
|
416
|
+
targetIndex = 0
|
|
417
|
+
pendingIndex = null
|
|
418
|
+
hasLaidOut = false
|
|
419
|
+
isPanning = false
|
|
420
|
+
initialTouchY = 0f
|
|
421
|
+
lastTouchY = 0f
|
|
422
|
+
activePointerId = MotionEvent.INVALID_POINTER_ID
|
|
423
|
+
sheetContainer.translationY = 0f
|
|
424
|
+
sheetContainer.removeAllViews()
|
|
414
425
|
}
|
|
415
426
|
}
|
|
@@ -60,6 +60,11 @@
|
|
|
60
60
|
[_impl unmountChildComponentView:childView];
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
- (void)resetSheetState
|
|
64
|
+
{
|
|
65
|
+
[_impl resetSheetState];
|
|
66
|
+
}
|
|
67
|
+
|
|
63
68
|
- (void)bottomSheetHostingView:(RNSBottomSheetHostingView *)view didChangeIndex:(NSInteger)index
|
|
64
69
|
{
|
|
65
70
|
[self.delegate bottomSheetView:self didChangeIndex:index];
|
|
@@ -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
|
|
|
@@ -128,6 +132,22 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
128
132
|
childView.removeFromSuperview()
|
|
129
133
|
}
|
|
130
134
|
|
|
135
|
+
public func resetSheetState() {
|
|
136
|
+
activeAnimator?.stopAnimation(true)
|
|
137
|
+
activeAnimator = nil
|
|
138
|
+
stopDisplayLink()
|
|
139
|
+
detentSpecs = []
|
|
140
|
+
targetIndex = 0
|
|
141
|
+
pendingIndex = nil
|
|
142
|
+
hasLaidOut = false
|
|
143
|
+
isPanning = false
|
|
144
|
+
setContentInteractionEnabled(true)
|
|
145
|
+
sheetContainer.transform = .identity
|
|
146
|
+
for subview in sheetContainer.subviews {
|
|
147
|
+
subview.removeFromSuperview()
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
131
151
|
private func detent(at index: Int) -> DetentSpec {
|
|
132
152
|
guard detentSpecs.indices.contains(index) else {
|
|
133
153
|
return DetentSpec(height: 0, programmatic: false)
|
|
@@ -166,6 +186,17 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
166
186
|
displayLink = nil
|
|
167
187
|
}
|
|
168
188
|
|
|
189
|
+
private func setContentInteractionEnabled(_ isEnabled: Bool) {
|
|
190
|
+
if isContentInteractionDisabled == !isEnabled {
|
|
191
|
+
return
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
for subview in sheetContainer.subviews {
|
|
195
|
+
subview.isUserInteractionEnabled = isEnabled
|
|
196
|
+
}
|
|
197
|
+
isContentInteractionDisabled = !isEnabled
|
|
198
|
+
}
|
|
199
|
+
|
|
169
200
|
@objc private func displayLinkFired() {
|
|
170
201
|
emitPosition()
|
|
171
202
|
}
|
|
@@ -194,6 +225,7 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
194
225
|
self.stopDisplayLink()
|
|
195
226
|
self.emitPosition()
|
|
196
227
|
self.activeAnimator = nil
|
|
228
|
+
self.setContentInteractionEnabled(true)
|
|
197
229
|
self.eventDelegate?.bottomSheetHostingView(self, didChangeIndex: index)
|
|
198
230
|
}
|
|
199
231
|
animator.startAnimation()
|
|
@@ -207,6 +239,7 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
207
239
|
switch gesture.state {
|
|
208
240
|
case .began:
|
|
209
241
|
isPanning = true
|
|
242
|
+
setContentInteractionEnabled(false)
|
|
210
243
|
gesture.setTranslation(.zero, in: self)
|
|
211
244
|
if let animator = activeAnimator {
|
|
212
245
|
stopDisplayLink()
|
|
@@ -234,6 +267,7 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
234
267
|
|
|
235
268
|
case .failed:
|
|
236
269
|
isPanning = false
|
|
270
|
+
setContentInteractionEnabled(true)
|
|
237
271
|
|
|
238
272
|
default:
|
|
239
273
|
break
|
|
@@ -291,6 +325,19 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
291
325
|
}
|
|
292
326
|
|
|
293
327
|
extension RNSBottomSheetHostingView: UIGestureRecognizerDelegate {
|
|
328
|
+
public func gestureRecognizer(
|
|
329
|
+
_ gestureRecognizer: UIGestureRecognizer,
|
|
330
|
+
shouldRequireFailureOf other: UIGestureRecognizer
|
|
331
|
+
) -> Bool {
|
|
332
|
+
guard gestureRecognizer === panGesture else { return false }
|
|
333
|
+
|
|
334
|
+
if other is UITapGestureRecognizer {
|
|
335
|
+
return true
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return false
|
|
339
|
+
}
|
|
340
|
+
|
|
294
341
|
public func gestureRecognizer(
|
|
295
342
|
_ gestureRecognizer: UIGestureRecognizer,
|
|
296
343
|
shouldBeRequiredToFailBy other: UIGestureRecognizer
|
package/package.json
CHANGED