@swmansion/react-native-bottom-sheet 0.9.3 → 0.9.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/README.md
CHANGED
|
@@ -133,6 +133,22 @@ Detents are the points to which the sheet snaps. Each detent is either a number
|
|
|
133
133
|
(a fixed height in pixels) or `'content'` (the sheet’s content height, capped by
|
|
134
134
|
the available screen height). The default detents are `[0, 'content']`.
|
|
135
135
|
|
|
136
|
+
Sheet children are laid out in a flex container. For a full‍-‍height
|
|
137
|
+
sheet, apply `flex: 1` to your sheet surface and use the
|
|
138
|
+
`'content'` detent:
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
<BottomSheet
|
|
142
|
+
// `detents` defaults to `[0, 'content']`.
|
|
143
|
+
index={index}
|
|
144
|
+
onIndexChange={setIndex}
|
|
145
|
+
>
|
|
146
|
+
<View style={{ flex: 1, backgroundColor: 'white' }}>
|
|
147
|
+
{/* Full-height sheet content. */}
|
|
148
|
+
</View>
|
|
149
|
+
</BottomSheet>
|
|
150
|
+
```
|
|
151
|
+
|
|
136
152
|
The `index` prop is a zero‍-‍based index into the `detents` array.
|
|
137
153
|
`onIndexChange` and `onSettle` have different responsibilities:
|
|
138
154
|
|
|
@@ -228,8 +244,6 @@ product‍—‍[hire us](https://swmansion.com/contact/projects?utm_so
|
|
|
228
244
|
|
|
229
245
|
[](https://swmansion.com)
|
|
230
246
|
|
|
231
|
-
[](https://github.com/software-mansion-labs/react-native-bottom-sheet/graphs/contributors)
|
|
232
|
-
|
|
233
247
|
## Sponsored by [Gobi Maps](https://www.gobimaps.com)
|
|
234
248
|
|
|
235
249
|
The best of your city, all in one map.
|
|
@@ -260,12 +260,13 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
|
|
|
260
260
|
|
|
261
261
|
private fun resolveDetentSpecs(): List<DetentSpec> {
|
|
262
262
|
val maxHeight = resolvedMaxDetentHeight()
|
|
263
|
-
val contentHeight =
|
|
263
|
+
val contentHeight =
|
|
264
|
+
validContentHeight().takeIf { it.isFinite() }?.coerceAtMost(maxHeight) ?: maxHeight
|
|
264
265
|
return rawDetentSpecs.map { spec ->
|
|
265
266
|
val height =
|
|
266
267
|
when (spec.kind) {
|
|
267
|
-
DetentKind.POINTS -> spec.value
|
|
268
|
-
DetentKind.CONTENT -> contentHeight
|
|
268
|
+
DetentKind.POINTS -> spec.value.coerceAtMost(contentHeight)
|
|
269
|
+
DetentKind.CONTENT -> contentHeight
|
|
269
270
|
}.coerceIn(0f, maxHeight)
|
|
270
271
|
DetentSpec(height = height, programmatic = spec.programmatic)
|
|
271
272
|
}
|
|
@@ -451,6 +452,7 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
|
|
|
451
452
|
}
|
|
452
453
|
|
|
453
454
|
val targetTy = translationY(index)
|
|
455
|
+
val currentTy = sheetContainer.translationY
|
|
454
456
|
activeAnimationEmitsSettle = emitSettle
|
|
455
457
|
activeAnimation?.cancel()
|
|
456
458
|
|
|
@@ -461,8 +463,8 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
|
|
|
461
463
|
dampingRatio = SpringForce.DAMPING_RATIO_NO_BOUNCY
|
|
462
464
|
stiffness = SpringForce.STIFFNESS_MEDIUM
|
|
463
465
|
}
|
|
464
|
-
setMinValue(minDetentTranslationY)
|
|
465
|
-
setMaxValue(maxDetentTranslationY)
|
|
466
|
+
setMinValue(minOf(minDetentTranslationY, currentTy, targetTy))
|
|
467
|
+
setMaxValue(maxOf(maxDetentTranslationY, currentTy, targetTy))
|
|
466
468
|
setStartVelocity(velocity)
|
|
467
469
|
addEndListener { _, canceled, _, _ ->
|
|
468
470
|
if (canceled) {
|
|
@@ -130,7 +130,7 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
130
130
|
let indexToApply = pendingIndex ?? targetIndex
|
|
131
131
|
let clampedIndex = max(0, min(detentSpecs.count - 1, indexToApply))
|
|
132
132
|
|
|
133
|
-
if animateIn
|
|
133
|
+
if animateIn, isInvalidContentDetentTarget(clampedIndex) {
|
|
134
134
|
targetIndex = clampedIndex
|
|
135
135
|
pendingIndex = clampedIndex
|
|
136
136
|
let closedTy = maximumResolvedDetentHeight ?? bounds.height
|
|
@@ -392,6 +392,7 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
392
392
|
switch gesture.state {
|
|
393
393
|
case .began:
|
|
394
394
|
isPanning = true
|
|
395
|
+
sheetContainer.endEditing(true)
|
|
395
396
|
setContentInteractionEnabled(false)
|
|
396
397
|
if let handler = surfaceTouchHandler {
|
|
397
398
|
handler.isEnabled = false
|
|
@@ -545,7 +546,7 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
545
546
|
let height: CGFloat
|
|
546
547
|
switch spec.kind {
|
|
547
548
|
case .points:
|
|
548
|
-
height = spec.value
|
|
549
|
+
height = min(spec.value, contentHeight)
|
|
549
550
|
case .content:
|
|
550
551
|
height = contentHeight
|
|
551
552
|
}
|
package/package.json
CHANGED