@swmansion/react-native-bottom-sheet 0.10.0 → 0.10.2

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.
@@ -180,7 +180,7 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
180
180
  val closedTy = detentSpecs.maxOfOrNull { it.height } ?: h.toFloat()
181
181
  sheetContainer.translationY = closedTy
182
182
  emitPosition()
183
- snapToIndex(targetIndex, 0f, emitIndexChange = false, emitSettle = false)
183
+ snapToIndex(targetIndex, 0f, emitIndexChange = false, emitSettle = true)
184
184
  } else {
185
185
  sheetContainer.translationY = translationY(targetIndex)
186
186
  emitPosition()
@@ -337,14 +337,20 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
337
337
  } else {
338
338
  val currentVisibleHeight = previousMaxHeight - sheetContainer.translationY
339
339
  val targetHeight = detentSpecs.getOrNull(targetIndex)?.height ?: 0f
340
- if (targetHeight <= currentVisibleHeight + 0.5f) {
341
- // Content shrank (or is unchanged): snap immediately. Animating here
342
- // would expose blank space below the shrunken content.
340
+ val isContentDetent = rawDetentSpecs.getOrNull(targetIndex)?.kind == DetentKind.CONTENT
341
+ val didShrink = targetHeight < currentVisibleHeight - 0.5f
342
+ if (isContentDetent && didShrink) {
343
+ // Content shrank: snap immediately. Animating here would expose
344
+ // blank space below the shrunken content.
345
+ sheetContainer.translationY = targetTy
346
+ emitPosition()
347
+ } else if (kotlin.math.abs(targetHeight - currentVisibleHeight) <= 0.5f) {
348
+ // No meaningful change.
343
349
  sheetContainer.translationY = targetTy
344
350
  emitPosition()
345
351
  } else {
346
- // Content grew: re-anchor at the current visible height, then animate
347
- // up to the taller detent.
352
+ // Detent value changed (or content grew): re-anchor at the current
353
+ // visible height, then animate to the new target.
348
354
  sheetContainer.translationY =
349
355
  (newMaxHeight - currentVisibleHeight).coerceIn(0f, newMaxHeight)
350
356
  scrimPinnedFull = scrimPinnedFull || wasScrimFull
@@ -6,17 +6,17 @@
6
6
  #import <ReactNativeBottomSheet/ReactNativeBottomSheet-Swift.h>
7
7
  #endif
8
8
 
9
- @interface BottomSheetContentView () <RNSBottomSheetHostingViewDelegate>
9
+ @interface BottomSheetContentView () <BottomSheetHostingViewDelegate>
10
10
  @end
11
11
 
12
12
  @implementation BottomSheetContentView {
13
- RNSBottomSheetHostingView *_impl;
13
+ BottomSheetHostingView *_impl;
14
14
  }
15
15
 
16
16
  - (instancetype)initWithFrame:(CGRect)frame
17
17
  {
18
18
  if (self = [super initWithFrame:frame]) {
19
- _impl = [[RNSBottomSheetHostingView alloc] initWithFrame:self.bounds];
19
+ _impl = [[BottomSheetHostingView alloc] initWithFrame:self.bounds];
20
20
  _impl.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
21
21
  _impl.eventDelegate = self;
22
22
  [self addSubview:_impl];
@@ -100,22 +100,22 @@
100
100
  [_impl resetSheetState];
101
101
  }
102
102
 
103
- - (void)bottomSheetHostingView:(RNSBottomSheetHostingView *)view didChangeIndex:(NSInteger)index
103
+ - (void)bottomSheetHostingView:(BottomSheetHostingView *)view didChangeIndex:(NSInteger)index
104
104
  {
105
105
  [self.delegate bottomSheetView:self didChangeIndex:index];
106
106
  }
107
107
 
108
- - (void)bottomSheetHostingView:(RNSBottomSheetHostingView *)view didSettle:(NSInteger)index
108
+ - (void)bottomSheetHostingView:(BottomSheetHostingView *)view didSettle:(NSInteger)index
109
109
  {
110
110
  [self.delegate bottomSheetView:self didSettle:index];
111
111
  }
112
112
 
113
- - (void)bottomSheetHostingView:(RNSBottomSheetHostingView *)view didChangePosition:(CGFloat)position
113
+ - (void)bottomSheetHostingView:(BottomSheetHostingView *)view didChangePosition:(CGFloat)position
114
114
  {
115
115
  [self.delegate bottomSheetView:self didChangePosition:position];
116
116
  }
117
117
 
118
- - (void)bottomSheetHostingView:(RNSBottomSheetHostingView *)view didReportError:(NSString *)message
118
+ - (void)bottomSheetHostingView:(BottomSheetHostingView *)view didReportError:(NSString *)message
119
119
  {
120
120
  [self.delegate bottomSheetView:self didReportError:message];
121
121
  }
@@ -1,10 +1,10 @@
1
1
  import UIKit
2
2
 
3
- @objc public protocol RNSBottomSheetHostingViewDelegate: AnyObject {
4
- func bottomSheetHostingView(_ view: RNSBottomSheetHostingView, didChangeIndex index: Int)
5
- func bottomSheetHostingView(_ view: RNSBottomSheetHostingView, didSettle index: Int)
6
- func bottomSheetHostingView(_ view: RNSBottomSheetHostingView, didChangePosition position: CGFloat)
7
- func bottomSheetHostingView(_ view: RNSBottomSheetHostingView, didReportError message: String)
3
+ @objc public protocol BottomSheetHostingViewDelegate: AnyObject {
4
+ func bottomSheetHostingView(_ view: BottomSheetHostingView, didChangeIndex index: Int)
5
+ func bottomSheetHostingView(_ view: BottomSheetHostingView, didSettle index: Int)
6
+ func bottomSheetHostingView(_ view: BottomSheetHostingView, didChangePosition position: CGFloat)
7
+ func bottomSheetHostingView(_ view: BottomSheetHostingView, didReportError message: String)
8
8
  }
9
9
 
10
10
  private struct DetentSpec: Equatable {
@@ -24,8 +24,8 @@ private struct RawDetentSpec {
24
24
  }
25
25
 
26
26
  @objcMembers
27
- public final class RNSBottomSheetHostingView: UIView {
28
- public weak var eventDelegate: RNSBottomSheetHostingViewDelegate?
27
+ public final class BottomSheetHostingView: UIView {
28
+ public weak var eventDelegate: BottomSheetHostingViewDelegate?
29
29
  public var modal: Bool = false {
30
30
  didSet { updateScrim() }
31
31
  }
@@ -152,7 +152,7 @@ public final class RNSBottomSheetHostingView: UIView {
152
152
  let closedTy = maximumResolvedDetentHeight ?? bounds.height
153
153
  sheetContainer.transform = CGAffineTransform(translationX: 0, y: closedTy)
154
154
  emitPosition()
155
- snapToIndex(targetIndex, velocity: 0, emitIndexChange: false, emitSettle: false)
155
+ snapToIndex(targetIndex, velocity: 0, emitIndexChange: false, emitSettle: true)
156
156
  } else {
157
157
  sheetContainer.transform = CGAffineTransform(translationX: 0, y: translationY(for: targetIndex))
158
158
  emitPosition()
@@ -669,14 +669,21 @@ public final class RNSBottomSheetHostingView: UIView {
669
669
  } else {
670
670
  let currentVisibleHeight = previousMaxHeight - currentTranslationY
671
671
  let targetHeight = detent(at: targetIndex).height
672
- if targetHeight <= currentVisibleHeight + 0.5 {
673
- // Content shrank (or is unchanged): snap immediately. Animating here
674
- // would expose blank space below the shrunken content.
672
+ let isContentDetent = rawDetentSpecs.indices.contains(targetIndex)
673
+ && rawDetentSpecs[targetIndex].kind == .content
674
+ let didShrink = targetHeight < currentVisibleHeight - 0.5
675
+ if isContentDetent, didShrink {
676
+ // Content shrank: snap immediately. Animating here would expose blank
677
+ // space below the shrunken content.
678
+ sheetContainer.transform = CGAffineTransform(translationX: 0, y: targetTy)
679
+ emitPosition()
680
+ } else if abs(targetHeight - currentVisibleHeight) <= 0.5 {
681
+ // No meaningful change.
675
682
  sheetContainer.transform = CGAffineTransform(translationX: 0, y: targetTy)
676
683
  emitPosition()
677
684
  } else {
678
- // Content grew: re-anchor at the current visible height, then animate
679
- // up to the taller detent.
685
+ // Detent value changed (or content grew): re-anchor at the current
686
+ // visible height, then animate to the new target.
680
687
  let startTy = min(max(newMaxHeight - currentVisibleHeight, 0), newMaxHeight)
681
688
  sheetContainer.transform = CGAffineTransform(translationX: 0, y: startTy)
682
689
  scrimPinnedFull = scrimPinnedFull || wasScrimFull
@@ -770,7 +777,7 @@ public final class RNSBottomSheetHostingView: UIView {
770
777
  }
771
778
  }
772
779
 
773
- extension RNSBottomSheetHostingView: UIGestureRecognizerDelegate {
780
+ extension BottomSheetHostingView: UIGestureRecognizerDelegate {
774
781
  public func gestureRecognizer(
775
782
  _ gestureRecognizer: UIGestureRecognizer,
776
783
  shouldBeRequiredToFailBy other: UIGestureRecognizer
@@ -787,7 +794,7 @@ extension RNSBottomSheetHostingView: UIGestureRecognizerDelegate {
787
794
  }
788
795
  }
789
796
 
790
- private extension RNSBottomSheetHostingView {
797
+ private extension BottomSheetHostingView {
791
798
  var currentTranslationY: CGFloat {
792
799
  if activeAnimator != nil, let presentation = sheetContainer.layer.presentation() {
793
800
  return presentation.affineTransform().ty
@@ -15,7 +15,7 @@ export interface NativeProps extends ViewProps {
15
15
  detents: ReadonlyArray<NativeDetent>;
16
16
  maxDetentHeight: CodegenTypes.Double;
17
17
  index: CodegenTypes.Int32;
18
- animateIn: boolean;
18
+ animateIn?: CodegenTypes.WithDefault<boolean, true>;
19
19
  modal: boolean;
20
20
  disableScrollableNegotiation?: boolean;
21
21
  scrimColor?: ColorValue;
@@ -8,7 +8,7 @@ export interface NativeProps extends ViewProps {
8
8
  detents: ReadonlyArray<NativeDetent>;
9
9
  maxDetentHeight: CodegenTypes.Double;
10
10
  index: CodegenTypes.Int32;
11
- animateIn: boolean;
11
+ animateIn?: CodegenTypes.WithDefault<boolean, true>;
12
12
  modal: boolean;
13
13
  disableScrollableNegotiation?: boolean;
14
14
  scrimColor?: ColorValue;
@@ -1 +1 @@
1
- {"version":3,"file":"BottomSheetNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/BottomSheetNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,KAAK,YAAY,GAAG,QAAQ,CAAC;IAC3B,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC,CAAC;AAEH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACrC,eAAe,EAAE,YAAY,CAAC,MAAM,CAAC;IACrC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,aAAa,CAAC,EAAE,YA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C,EAAE,YAAY,CAAC,kBAAkB,CACxC,QAAQ,CAAC;QAAE,KAAK,EAAE,YAAY,CAAC,KAAK,CAAA;KAAE,CAAC,CACxC,CAAC;IACF,gBAAgB,CAAC,EAAE,YAAY,CAAC,kBAAkB,CAChD,QAAQ,CAAC;QAAE,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAA;KAAE,CAAC,CAC5C,CAAC;CACH;;AAED,wBAAsE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/react-native-bottom-sheet",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Provides bottom-sheet components for React Native.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -15,7 +15,7 @@ export interface NativeProps extends ViewProps {
15
15
  detents: ReadonlyArray<NativeDetent>;
16
16
  maxDetentHeight: CodegenTypes.Double;
17
17
  index: CodegenTypes.Int32;
18
- animateIn: boolean;
18
+ animateIn?: CodegenTypes.WithDefault<boolean, true>;
19
19
  modal: boolean;
20
20
  disableScrollableNegotiation?: boolean;
21
21
  scrimColor?: ColorValue;