@swmansion/react-native-bottom-sheet 0.9.5 → 0.10.0-next.1
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.
|
@@ -260,12 +260,20 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
|
|
|
260
260
|
|
|
261
261
|
private fun resolveDetentSpecs(): List<DetentSpec> {
|
|
262
262
|
val maxHeight = resolvedMaxDetentHeight()
|
|
263
|
-
val
|
|
264
|
-
validContentHeight().takeIf { it.isFinite() }?.coerceAtMost(maxHeight)
|
|
265
|
-
|
|
263
|
+
val measuredContentHeight =
|
|
264
|
+
validContentHeight().takeIf { maxHeight > 0f && it.isFinite() }?.coerceAtMost(maxHeight)
|
|
265
|
+
val contentHeight = measuredContentHeight ?: maxHeight
|
|
266
|
+
return rawDetentSpecs.mapIndexed { index, spec ->
|
|
266
267
|
val height =
|
|
267
268
|
when (spec.kind) {
|
|
268
|
-
DetentKind.POINTS ->
|
|
269
|
+
DetentKind.POINTS -> {
|
|
270
|
+
if (measuredContentHeight != null && spec.value > contentHeight) {
|
|
271
|
+
throw IllegalArgumentException(
|
|
272
|
+
"Invalid bottom sheet detent at index $index: fixed detent ${spec.value / density} exceeds measured content height ${contentHeight / density}."
|
|
273
|
+
)
|
|
274
|
+
}
|
|
275
|
+
spec.value
|
|
276
|
+
}
|
|
269
277
|
DetentKind.CONTENT -> contentHeight
|
|
270
278
|
}.coerceIn(0f, maxHeight)
|
|
271
279
|
DetentSpec(height = height, programmatic = spec.programmatic)
|
|
@@ -541,12 +541,21 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
541
541
|
|
|
542
542
|
private func resolveDetentSpecs() -> [DetentSpec] {
|
|
543
543
|
let maxHeight = resolvedMaxDetentHeight
|
|
544
|
-
let
|
|
545
|
-
|
|
544
|
+
let measuredContentHeight = maxHeight > 0 ? validContentHeight.map { min($0, maxHeight) } : nil
|
|
545
|
+
let contentHeight = measuredContentHeight ?? maxHeight
|
|
546
|
+
return rawDetentSpecs.enumerated().map { index, spec in
|
|
546
547
|
let height: CGFloat
|
|
547
548
|
switch spec.kind {
|
|
548
549
|
case .points:
|
|
549
|
-
|
|
550
|
+
if measuredContentHeight != nil, spec.value > contentHeight {
|
|
551
|
+
NSException(
|
|
552
|
+
name: NSExceptionName.invalidArgumentException,
|
|
553
|
+
reason:
|
|
554
|
+
"Invalid bottom sheet detent at index \(index): fixed detent \(spec.value) exceeds measured content height \(contentHeight).",
|
|
555
|
+
userInfo: nil
|
|
556
|
+
).raise()
|
|
557
|
+
}
|
|
558
|
+
height = spec.value
|
|
550
559
|
case .content:
|
|
551
560
|
height = contentHeight
|
|
552
561
|
}
|
package/package.json
CHANGED