@lodev09/react-native-true-sheet 3.6.2 → 3.6.4

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.
@@ -46,7 +46,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
46
46
  // Initial present configuration (set by ViewManager before mount)
47
47
  var initialDetentIndex: Int = -1
48
48
  var initialDetentAnimated: Boolean = true
49
- private var hasInitialPresented: Boolean = false
49
+ private var pendingInitialPresentation: Boolean = false
50
50
 
51
51
  var stateWrapper: StateWrapper? = null
52
52
  set(value) {
@@ -98,6 +98,11 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
98
98
 
99
99
  // ==================== View Hierarchy Management ====================
100
100
 
101
+ override fun onAttachedToWindow() {
102
+ super.onAttachedToWindow()
103
+ presentInitialDetentIfNeeded()
104
+ }
105
+
101
106
  override fun addView(child: View?, index: Int) {
102
107
  viewController.addView(child, index)
103
108
 
@@ -105,13 +110,9 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
105
110
  child.delegate = this
106
111
  viewController.createSheet()
107
112
 
108
- if (initialDetentIndex >= 0 && !hasInitialPresented) {
109
- hasInitialPresented = true
110
- if (initialDetentAnimated) {
111
- present(initialDetentIndex, true) { }
112
- } else {
113
- post { present(initialDetentIndex, false) { } }
114
- }
113
+ if (initialDetentIndex >= 0 && !viewController.isPresented) {
114
+ pendingInitialPresentation = true
115
+ presentInitialDetentIfNeeded()
115
116
  }
116
117
 
117
118
  val surfaceId = UIManagerHelper.getSurfaceId(this)
@@ -119,6 +120,19 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
119
120
  }
120
121
  }
121
122
 
123
+ private fun presentInitialDetentIfNeeded() {
124
+ if (!pendingInitialPresentation || initialDetentIndex < 0 || viewController.isPresented || !isAttachedToWindow) {
125
+ return
126
+ }
127
+
128
+ pendingInitialPresentation = false
129
+ if (initialDetentAnimated) {
130
+ present(initialDetentIndex, true) { }
131
+ } else {
132
+ post { present(initialDetentIndex, false) { } }
133
+ }
134
+ }
135
+
122
136
  override fun getChildCount(): Int = viewController.childCount
123
137
 
124
138
  override fun getChildAt(index: Int): View? = viewController.getChildAt(index)
@@ -154,7 +168,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
154
168
  TrueSheetStackManager.removeSheet(this)
155
169
 
156
170
  if (viewController.isPresented) {
157
- viewController.dismiss()
171
+ viewController.dismiss(animated = false)
158
172
  }
159
173
  viewController.delegate = null
160
174
  }
@@ -757,7 +757,6 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
757
757
 
758
758
  val adjustedHalfExpandedHeight = minOf(halfExpandedDetentHeight, maxAvailableHeight)
759
759
  val halfExpandedRatio = (adjustedHalfExpandedHeight.toFloat() / realScreenHeight.toFloat())
760
- .coerceIn(0f, 0.999f)
761
760
 
762
761
  val expandedOffset = realScreenHeight - maxDetentHeight
763
762
 
@@ -802,7 +801,7 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
802
801
  isFitToContents = fitToContents
803
802
  skipCollapsed = false
804
803
  setPeekHeight(peekHeight, animate)
805
- this.halfExpandedRatio = halfExpandedRatio.coerceIn(0f, 0.999f)
804
+ this.halfExpandedRatio = halfExpandedRatio.coerceIn(0.01f, 0.999f)
806
805
  this.expandedOffset = expandedOffset
807
806
  }
808
807
  }
@@ -13,6 +13,7 @@
13
13
  #import "core/TrueSheetGrabberView.h"
14
14
  #import "utils/BlurUtil.h"
15
15
  #import "utils/GestureUtil.h"
16
+ #import "utils/PlatformUtil.h"
16
17
  #import "utils/WindowUtil.h"
17
18
 
18
19
  #import <React/RCTLog.h>
@@ -669,6 +670,7 @@
669
670
  }
670
671
 
671
672
  - (void)setupBackground {
673
+ #if RNTS_IPHONE_OS_VERSION_AVAILABLE(26_1)
672
674
  BOOL useBackgroundEffect = NO;
673
675
  if (@available(iOS 26.1, *)) {
674
676
  useBackgroundEffect = !self.isDesignCompatibilityMode;
@@ -692,6 +694,7 @@
692
694
  }
693
695
  }
694
696
  }
697
+ #endif
695
698
 
696
699
  NSString *effectiveBackgroundBlur = self.backgroundBlur;
697
700
  if (@available(iOS 26.0, *)) {
@@ -718,12 +721,14 @@
718
721
  [_blurView applyBlurEffect];
719
722
  }
720
723
 
724
+ #if RNTS_IPHONE_OS_VERSION_AVAILABLE(26_1)
721
725
  if (@available(iOS 26.1, *)) {
722
726
  if (useBackgroundEffect && self.backgroundColor) {
723
727
  self.sheet.backgroundEffect = [UIColorEffect effectWithColor:self.backgroundColor];
724
728
  return;
725
729
  }
726
730
  }
731
+ #endif
727
732
 
728
733
  self.view.backgroundColor = self.backgroundColor;
729
734
  }
@@ -0,0 +1,15 @@
1
+ //
2
+ // Created by Jovanni Lo (@lodev09)
3
+ // Copyright (c) 2024-present. All rights reserved.
4
+ //
5
+ // This source code is licensed under the MIT license found in the
6
+ // LICENSE file in the root directory of this source tree.
7
+ //
8
+
9
+ #ifndef PlatformUtil_h
10
+ #define PlatformUtil_h
11
+
12
+ #define RNTS_IPHONE_OS_VERSION_AVAILABLE(v) \
13
+ (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_##v) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_##v)
14
+
15
+ #endif /* PlatformUtil_h */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodev09/react-native-true-sheet",
3
- "version": "3.6.2",
3
+ "version": "3.6.4",
4
4
  "description": "The true native bottom sheet experience for your React Native Apps.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",