@lodev09/react-native-true-sheet 3.0.0-beta.0 → 3.0.0-beta.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.
@@ -302,7 +302,11 @@ using namespace facebook::react;
302
302
 
303
303
  - (void)prepareForRecycle {
304
304
  [super prepareForRecycle];
305
- [self invalidate];
305
+
306
+ // Dismiss controller if presented
307
+ if (_controller && _controller.presentingViewController) {
308
+ [_controller dismissViewControllerAnimated:YES completion:nil];
309
+ }
306
310
 
307
311
  // Unregister from the registry
308
312
  // Note: Re-registration will happen automatically when the component is reused
@@ -8,6 +8,13 @@
8
8
 
9
9
  #import <UIKit/UIKit.h>
10
10
 
11
+ #if __has_include(<RNScreens/RNSDismissibleModalProtocol.h>)
12
+ #import <RNScreens/RNSDismissibleModalProtocol.h>
13
+ #define RNS_DISMISSIBLE_MODAL_PROTOCOL_AVAILABLE 1
14
+ #else
15
+ #define RNS_DISMISSIBLE_MODAL_PROTOCOL_AVAILABLE 0
16
+ #endif
17
+
11
18
  NS_ASSUME_NONNULL_BEGIN
12
19
 
13
20
  @protocol TrueSheetViewControllerDelegate <NSObject>
@@ -23,7 +30,12 @@ NS_ASSUME_NONNULL_BEGIN
23
30
 
24
31
  @end
25
32
 
26
- @interface TrueSheetViewController : UIViewController <UISheetPresentationControllerDelegate>
33
+ @interface TrueSheetViewController : UIViewController <UISheetPresentationControllerDelegate
34
+ #if RNS_DISMISSIBLE_MODAL_PROTOCOL_AVAILABLE
35
+ ,
36
+ RNSDismissibleModalProtocol
37
+ #endif
38
+ >
27
39
 
28
40
  @property (nonatomic, weak, nullable) id<TrueSheetViewControllerDelegate> delegate;
29
41
  @property (nonatomic, strong) NSArray *detents;
@@ -58,6 +58,9 @@
58
58
  // The sheet's view has smaller insets, so we need the actual device insets
59
59
  UIWindow *window = [WindowUtil keyWindow];
60
60
  _bottomInset = window ? window.safeAreaInsets.bottom : 0;
61
+
62
+ // Allow modals to be presented from this view controller
63
+ self.definesPresentationContext = YES;
61
64
  }
62
65
  return self;
63
66
  }
@@ -127,7 +130,8 @@
127
130
  - (void)viewWillDisappear:(BOOL)animated {
128
131
  [super viewWillDisappear:animated];
129
132
 
130
- if ([self.delegate respondsToSelector:@selector(viewControllerWillDismiss)]) {
133
+ // Only dispatch willDismiss if the sheet is actually being dismissed
134
+ if (self.isBeingDismissed && [self.delegate respondsToSelector:@selector(viewControllerWillDismiss)]) {
131
135
  [self.delegate viewControllerWillDismiss];
132
136
  }
133
137
 
@@ -137,13 +141,22 @@
137
141
 
138
142
  - (void)viewDidDisappear:(BOOL)animated {
139
143
  [super viewDidDisappear:animated];
140
- if ([self.delegate respondsToSelector:@selector(viewControllerDidDismiss)]) {
144
+
145
+ // Only dispatch didDismiss if the sheet is actually being dismissed
146
+ // (not when another modal is presented on top)
147
+ BOOL isActuallyDismissing = self.presentingViewController == nil || self.isBeingDismissed;
148
+
149
+ if (isActuallyDismissing && [self.delegate respondsToSelector:@selector(viewControllerDidDismiss)]) {
141
150
  [self.delegate viewControllerDidDismiss];
142
151
  }
143
152
 
144
153
  _isTrackingPositionFromLayout = NO;
145
- _isPresented = NO;
146
- _activeDetentIndex = -1;
154
+
155
+ // Only reset state if actually dismissing
156
+ if (isActuallyDismissing) {
157
+ _isPresented = NO;
158
+ _activeDetentIndex = -1;
159
+ }
147
160
  }
148
161
 
149
162
  - (void)viewWillTransitionToSize:(CGSize)size
@@ -646,4 +659,14 @@
646
659
  }
647
660
  }
648
661
 
662
+ #pragma mark - RNSDismissibleModalProtocol
663
+
664
+ #if RNS_DISMISSIBLE_MODAL_PROTOCOL_AVAILABLE
665
+ - (BOOL)isDismissible {
666
+ // Return NO to prevent react-native-screens from dismissing this sheet
667
+ // when presenting a React Navigation modal
668
+ return NO;
669
+ }
670
+ #endif
671
+
649
672
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodev09/react-native-true-sheet",
3
- "version": "3.0.0-beta.0",
3
+ "version": "3.0.0-beta.1",
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",