@swmansion/react-native-bottom-sheet 0.8.0-next.6 → 0.8.0-next.7
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.
|
@@ -181,14 +181,24 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
|
|
|
181
181
|
val programmatic = dict["programmatic"] as? Boolean ?: false
|
|
182
182
|
DetentSpec(height = (height * density).toFloat(), programmatic = programmatic)
|
|
183
183
|
}
|
|
184
|
-
|
|
185
184
|
if (width > 0 && height > 0 && detentSpecs.isNotEmpty()) {
|
|
186
185
|
layoutSheetContainer(width, height)
|
|
187
186
|
|
|
188
|
-
if (hasLaidOut &&
|
|
187
|
+
if (hasLaidOut && !isPanning) {
|
|
189
188
|
targetIndex = targetIndex.coerceIn(0, detentSpecs.size - 1)
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
if (activeAnimation != null) {
|
|
190
|
+
val currentTy = sheetContainer.translationY
|
|
191
|
+
activeAnimation?.cancel()
|
|
192
|
+
activeAnimation = null
|
|
193
|
+
stopChoreographer()
|
|
194
|
+
sheetContainer.translationY =
|
|
195
|
+
currentTy.coerceIn(0f, detentSpecs.lastOrNull()?.height ?: currentTy)
|
|
196
|
+
emitPosition()
|
|
197
|
+
snapToIndex(targetIndex, 0f, emitIndexChange = false, emitSettle = false)
|
|
198
|
+
} else {
|
|
199
|
+
sheetContainer.translationY = translationY(targetIndex)
|
|
200
|
+
emitPosition()
|
|
201
|
+
}
|
|
192
202
|
}
|
|
193
203
|
}
|
|
194
204
|
|
|
@@ -298,7 +308,6 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
|
|
|
298
308
|
targetIndex = index
|
|
299
309
|
|
|
300
310
|
val targetTy = translationY(index)
|
|
301
|
-
|
|
302
311
|
activeAnimation?.cancel()
|
|
303
312
|
|
|
304
313
|
val spring = SpringAnimation(sheetContainer, DynamicAnimation.TRANSLATION_Y, targetTy).apply {
|
|
@@ -18,6 +18,7 @@ using namespace facebook::react;
|
|
|
18
18
|
BottomSheetContentView *_sheetView;
|
|
19
19
|
State::Shared _sheetState;
|
|
20
20
|
float _lastContentOffsetY;
|
|
21
|
+
BOOL _needsIndexSyncAfterRecycle;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
@@ -30,6 +31,7 @@ using namespace facebook::react;
|
|
|
30
31
|
if (self = [super initWithFrame:frame]) {
|
|
31
32
|
static const auto defaultProps = std::make_shared<const BottomSheetViewProps>();
|
|
32
33
|
_props = defaultProps;
|
|
34
|
+
_needsIndexSyncAfterRecycle = NO;
|
|
33
35
|
|
|
34
36
|
_sheetView = [[BottomSheetContentView alloc] initWithFrame:CGRectZero];
|
|
35
37
|
_sheetView.delegate = self;
|
|
@@ -56,8 +58,9 @@ using namespace facebook::react;
|
|
|
56
58
|
[_sheetView setDetents:detentsArray];
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
if (newViewProps.index != oldViewProps.index) {
|
|
61
|
+
if (_needsIndexSyncAfterRecycle || newViewProps.index != oldViewProps.index) {
|
|
60
62
|
[_sheetView setDetentIndex:newViewProps.index];
|
|
63
|
+
_needsIndexSyncAfterRecycle = NO;
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
if (newViewProps.animateIn != oldViewProps.animateIn) {
|
|
@@ -129,6 +132,7 @@ using namespace facebook::react;
|
|
|
129
132
|
- (void)prepareForRecycle
|
|
130
133
|
{
|
|
131
134
|
[super prepareForRecycle];
|
|
135
|
+
_needsIndexSyncAfterRecycle = YES;
|
|
132
136
|
[_sheetView resetSheetState];
|
|
133
137
|
_sheetState.reset();
|
|
134
138
|
_lastContentOffsetY = 0;
|
|
@@ -162,6 +162,30 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
162
162
|
let programmatic = (dict["programmatic"] as? Bool) ?? (dict["programmatic"] as? NSNumber)?.boolValue ?? false
|
|
163
163
|
return DetentSpec(height: CGFloat(height), programmatic: programmatic)
|
|
164
164
|
}
|
|
165
|
+
guard bounds.width > 0, bounds.height > 0, !detentSpecs.isEmpty else {
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if hasLaidOut && !isPanning {
|
|
170
|
+
targetIndex = max(0, min(detentSpecs.count - 1, targetIndex))
|
|
171
|
+
layoutIfNeeded()
|
|
172
|
+
|
|
173
|
+
if let animator = activeAnimator {
|
|
174
|
+
stopDisplayLink()
|
|
175
|
+
let visualTy = sheetContainer.layer.presentation()?.affineTransform().ty ?? sheetContainer.transform.ty
|
|
176
|
+
animator.stopAnimation(true)
|
|
177
|
+
activeAnimator = nil
|
|
178
|
+
sheetContainer.transform = CGAffineTransform(
|
|
179
|
+
translationX: 0,
|
|
180
|
+
y: min(max(visualTy, 0), detentSpecs.last?.height ?? visualTy)
|
|
181
|
+
)
|
|
182
|
+
emitPosition()
|
|
183
|
+
snapToIndex(targetIndex, velocity: 0, emitIndexChange: false, emitSettle: false)
|
|
184
|
+
} else {
|
|
185
|
+
sheetContainer.transform = CGAffineTransform(translationX: 0, y: translationY(for: targetIndex))
|
|
186
|
+
emitPosition()
|
|
187
|
+
}
|
|
188
|
+
}
|
|
165
189
|
}
|
|
166
190
|
|
|
167
191
|
public func setDetentIndex(_ newIndex: Int) {
|
package/package.json
CHANGED