@lodev09/react-native-true-sheet 3.7.3 → 3.7.4-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.
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +0 -4
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +29 -30
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensFragmentObserver.kt +65 -14
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetStackManager.kt +1 -1
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewComponentDescriptor.h +4 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.cpp +13 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.h +11 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.cpp +12 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.h +10 -0
- package/ios/TrueSheetContainerView.mm +7 -15
- package/ios/TrueSheetContentView.h +2 -2
- package/ios/TrueSheetContentView.mm +84 -89
- package/ios/TrueSheetHeaderView.mm +1 -3
- package/ios/TrueSheetView.mm +72 -14
- package/ios/TrueSheetViewController.h +0 -15
- package/ios/TrueSheetViewController.mm +76 -146
- package/ios/core/RNScreensEventObserver.h +43 -0
- package/ios/core/RNScreensEventObserver.mm +119 -0
- package/ios/core/TrueSheetBlurView.mm +26 -22
- package/ios/utils/LayoutUtil.h +23 -0
- package/ios/utils/LayoutUtil.mm +28 -3
- package/lib/module/TrueSheet.js +16 -5
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/typescript/src/TrueSheet.d.ts +4 -0
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TrueSheet.tsx +16 -3
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
#import <react/renderer/components/TrueSheetSpec/Props.h>
|
|
16
16
|
#import <react/renderer/components/TrueSheetSpec/RCTComponentViewHelpers.h>
|
|
17
17
|
#import "TrueSheetView.h"
|
|
18
|
-
#import "TrueSheetViewController.h"
|
|
19
18
|
#import "utils/LayoutUtil.h"
|
|
20
19
|
|
|
21
20
|
using namespace facebook::react;
|
|
@@ -24,6 +23,8 @@ using namespace facebook::react;
|
|
|
24
23
|
RCTScrollViewComponentView *_pinnedScrollView;
|
|
25
24
|
UIView *_pinnedTopView;
|
|
26
25
|
CGSize _lastSize;
|
|
26
|
+
UIEdgeInsets _contentInsets;
|
|
27
|
+
UIEdgeInsets _pinnedInsets;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
@@ -34,109 +35,96 @@ using namespace facebook::react;
|
|
|
34
35
|
if (self = [super initWithFrame:frame]) {
|
|
35
36
|
static const auto defaultProps = std::make_shared<const TrueSheetContentViewProps>();
|
|
36
37
|
_props = defaultProps;
|
|
37
|
-
|
|
38
|
-
_pinnedScrollView = nil;
|
|
39
|
-
_pinnedTopView = nil;
|
|
40
|
-
_lastSize = CGSizeZero;
|
|
41
38
|
}
|
|
42
39
|
return self;
|
|
43
40
|
}
|
|
44
41
|
|
|
42
|
+
#pragma mark - Layout
|
|
43
|
+
|
|
45
44
|
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
|
|
46
45
|
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics {
|
|
47
46
|
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
UIEdgeInsets newInsets = UIEdgeInsetsMake(layoutMetrics.contentInsets.top, layoutMetrics.contentInsets.left,
|
|
49
|
+
layoutMetrics.contentInsets.bottom, layoutMetrics.contentInsets.right);
|
|
50
|
+
|
|
51
|
+
if (!UIEdgeInsetsEqualToEdgeInsets(newInsets, _contentInsets)) {
|
|
52
|
+
_contentInsets = newInsets;
|
|
53
|
+
[self.delegate contentViewDidChangeInsets];
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
CGSize newSize = CGSizeMake(layoutMetrics.frame.size.width, layoutMetrics.frame.size.height);
|
|
51
57
|
if (!CGSizeEqualToSize(newSize, _lastSize)) {
|
|
52
58
|
_lastSize = newSize;
|
|
53
|
-
|
|
54
|
-
[self.delegate contentViewDidChangeSize:newSize];
|
|
55
|
-
}
|
|
59
|
+
[self.delegate contentViewDidChangeSize:newSize];
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
|
|
63
|
+
#pragma mark - Child Mounting
|
|
64
|
+
|
|
59
65
|
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
|
|
60
66
|
[super mountChildComponentView:childComponentView index:index];
|
|
61
|
-
|
|
62
|
-
if ([self.delegate respondsToSelector:@selector(contentViewDidChangeChildren)]) {
|
|
63
|
-
[self.delegate contentViewDidChangeChildren];
|
|
64
|
-
}
|
|
67
|
+
[self.delegate contentViewDidChangeChildren];
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
|
|
68
71
|
[super unmountChildComponentView:childComponentView index:index];
|
|
69
|
-
|
|
70
|
-
if ([self.delegate respondsToSelector:@selector(contentViewDidChangeChildren)]) {
|
|
71
|
-
[self.delegate contentViewDidChangeChildren];
|
|
72
|
-
}
|
|
72
|
+
[self.delegate contentViewDidChangeChildren];
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
-
|
|
76
|
-
|
|
75
|
+
#pragma mark - ScrollView Pinning
|
|
76
|
+
|
|
77
|
+
- (void)clearPinning {
|
|
77
78
|
if (_pinnedScrollView) {
|
|
78
|
-
[LayoutUtil unpinView:_pinnedScrollView fromParentView:
|
|
79
|
+
[LayoutUtil unpinView:_pinnedScrollView fromParentView:self];
|
|
80
|
+
[LayoutUtil unpinView:_pinnedScrollView fromParentView:self.superview];
|
|
79
81
|
}
|
|
82
|
+
_pinnedScrollView = nil;
|
|
83
|
+
_pinnedTopView = nil;
|
|
84
|
+
_pinnedInsets = UIEdgeInsetsZero;
|
|
80
85
|
}
|
|
81
86
|
|
|
82
|
-
- (void)setupScrollViewPinning:(BOOL)pinned
|
|
83
|
-
// Pin to container view (parent of content view)
|
|
87
|
+
- (void)setupScrollViewPinning:(BOOL)pinned {
|
|
84
88
|
UIView *containerView = self.superview;
|
|
85
89
|
|
|
86
90
|
if (!pinned) {
|
|
87
|
-
[self
|
|
88
|
-
_pinnedScrollView = nil;
|
|
89
|
-
_pinnedTopView = nil;
|
|
91
|
+
[self clearPinning];
|
|
90
92
|
return;
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
// Auto-detect and pin scroll views for proper sheet scrolling behavior
|
|
94
|
-
// Pinning ensures ScrollView fills the available area and scrolls correctly with the sheet
|
|
95
95
|
UIView *topSibling = nil;
|
|
96
96
|
RCTScrollViewComponentView *scrollView = [self findScrollView:&topSibling];
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
BOOL needsUpdate = scrollView != _pinnedScrollView || topSibling != _pinnedTopView ||
|
|
99
|
+
!UIEdgeInsetsEqualToEdgeInsets(_contentInsets, _pinnedInsets);
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
BOOL topViewChanged = topView != _pinnedTopView;
|
|
101
|
+
if (scrollView && containerView && needsUpdate) {
|
|
102
|
+
[self clearPinning];
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
[self unpinScrollViewFromParentView:containerView];
|
|
104
|
+
UIEdgeInsets insets =
|
|
105
|
+
UIEdgeInsetsMake(topSibling ? 0 : _contentInsets.top, _contentInsets.left, 0, _contentInsets.right);
|
|
108
106
|
|
|
109
|
-
if (
|
|
110
|
-
// Pin ScrollView below the top view
|
|
107
|
+
if (topSibling) {
|
|
111
108
|
[LayoutUtil pinView:scrollView
|
|
112
|
-
toParentView:
|
|
113
|
-
withTopView:
|
|
114
|
-
edges:UIRectEdgeLeft | UIRectEdgeRight
|
|
109
|
+
toParentView:self
|
|
110
|
+
withTopView:topSibling
|
|
111
|
+
edges:UIRectEdgeLeft | UIRectEdgeRight
|
|
112
|
+
insets:insets];
|
|
115
113
|
} else {
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
[LayoutUtil pinView:scrollView
|
|
115
|
+
toParentView:self
|
|
116
|
+
edges:UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeRight
|
|
117
|
+
insets:insets];
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
[LayoutUtil pinView:scrollView toParentView:containerView edges:UIRectEdgeBottom];
|
|
121
|
+
|
|
120
122
|
_pinnedScrollView = scrollView;
|
|
121
|
-
_pinnedTopView =
|
|
123
|
+
_pinnedTopView = topSibling;
|
|
124
|
+
_pinnedInsets = _contentInsets;
|
|
122
125
|
} else if (!scrollView && _pinnedScrollView) {
|
|
123
|
-
|
|
124
|
-
[self unpinScrollViewFromParentView:containerView];
|
|
125
|
-
_pinnedScrollView = nil;
|
|
126
|
-
_pinnedTopView = nil;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
- (RCTScrollViewComponentView *)findScrollViewInSubviews:(NSArray<UIView *> *)subviews {
|
|
131
|
-
for (UIView *subview in subviews) {
|
|
132
|
-
if ([subview isKindOfClass:TrueSheetView.class]) {
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if ([subview isKindOfClass:RCTScrollViewComponentView.class]) {
|
|
136
|
-
return (RCTScrollViewComponentView *)subview;
|
|
137
|
-
}
|
|
126
|
+
[self clearPinning];
|
|
138
127
|
}
|
|
139
|
-
return nil;
|
|
140
128
|
}
|
|
141
129
|
|
|
142
130
|
- (RCTScrollViewComponentView *)findScrollView:(UIView **)outTopSibling {
|
|
@@ -144,12 +132,8 @@ using namespace facebook::react;
|
|
|
144
132
|
return nil;
|
|
145
133
|
}
|
|
146
134
|
|
|
147
|
-
UIView *topSibling = nil;
|
|
148
|
-
|
|
149
|
-
// Check first-level children for scroll views (ScrollView or FlatList)
|
|
150
135
|
RCTScrollViewComponentView *scrollView = [self findScrollViewInSubviews:self.subviews];
|
|
151
136
|
|
|
152
|
-
// If not found, check second level (grandchildren)
|
|
153
137
|
if (!scrollView) {
|
|
154
138
|
for (UIView *subview in self.subviews) {
|
|
155
139
|
scrollView = [self findScrollViewInSubviews:subview.subviews];
|
|
@@ -159,43 +143,54 @@ using namespace facebook::react;
|
|
|
159
143
|
}
|
|
160
144
|
}
|
|
161
145
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
CGFloat closestDistance = CGFLOAT_MAX;
|
|
146
|
+
if (outTopSibling) {
|
|
147
|
+
*outTopSibling = [self findTopSiblingForScrollView:scrollView];
|
|
148
|
+
}
|
|
166
149
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
150
|
+
return scrollView;
|
|
151
|
+
}
|
|
171
152
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
closestDistance = distance;
|
|
177
|
-
topSibling = sibling;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
153
|
+
- (RCTScrollViewComponentView *)findScrollViewInSubviews:(NSArray<UIView *> *)subviews {
|
|
154
|
+
for (UIView *subview in subviews) {
|
|
155
|
+
if ([subview isKindOfClass:RCTScrollViewComponentView.class] && ![subview isKindOfClass:TrueSheetView.class]) {
|
|
156
|
+
return (RCTScrollViewComponentView *)subview;
|
|
180
157
|
}
|
|
181
158
|
}
|
|
159
|
+
return nil;
|
|
160
|
+
}
|
|
182
161
|
|
|
183
|
-
|
|
184
|
-
|
|
162
|
+
- (UIView *)findTopSiblingForScrollView:(RCTScrollViewComponentView *)scrollView {
|
|
163
|
+
if (!scrollView || scrollView.superview != self || self.subviews.count <= 1) {
|
|
164
|
+
return nil;
|
|
185
165
|
}
|
|
186
166
|
|
|
187
|
-
|
|
167
|
+
CGFloat scrollViewTop = CGRectGetMinY(scrollView.frame);
|
|
168
|
+
UIView *topSibling = nil;
|
|
169
|
+
CGFloat closestDistance = CGFLOAT_MAX;
|
|
170
|
+
|
|
171
|
+
for (UIView *sibling in self.subviews) {
|
|
172
|
+
if (sibling == scrollView || [sibling isKindOfClass:TrueSheetView.class]) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
CGFloat siblingBottom = CGRectGetMaxY(sibling.frame);
|
|
177
|
+
if (siblingBottom <= scrollViewTop) {
|
|
178
|
+
CGFloat distance = scrollViewTop - siblingBottom;
|
|
179
|
+
if (distance < closestDistance) {
|
|
180
|
+
closestDistance = distance;
|
|
181
|
+
topSibling = sibling;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return topSibling;
|
|
188
187
|
}
|
|
189
188
|
|
|
189
|
+
#pragma mark - Lifecycle
|
|
190
|
+
|
|
190
191
|
- (void)prepareForRecycle {
|
|
191
192
|
[super prepareForRecycle];
|
|
192
|
-
|
|
193
|
-
// Remove scroll view constraints
|
|
194
|
-
if (_pinnedScrollView) {
|
|
195
|
-
[LayoutUtil unpinView:_pinnedScrollView fromParentView:self.superview];
|
|
196
|
-
_pinnedScrollView = nil;
|
|
197
|
-
_pinnedTopView = nil;
|
|
198
|
-
}
|
|
193
|
+
[self clearPinning];
|
|
199
194
|
}
|
|
200
195
|
|
|
201
196
|
@end
|
|
@@ -44,9 +44,7 @@ using namespace facebook::react;
|
|
|
44
44
|
// Notify delegate when header size changes
|
|
45
45
|
if (!CGSizeEqualToSize(newSize, _lastSize)) {
|
|
46
46
|
_lastSize = newSize;
|
|
47
|
-
|
|
48
|
-
[self.delegate headerViewDidChangeSize:newSize];
|
|
49
|
-
}
|
|
47
|
+
[self.delegate headerViewDidChangeSize:newSize];
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
|
package/ios/TrueSheetView.mm
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
#import "TrueSheetFooterView.h"
|
|
15
15
|
#import "TrueSheetModule.h"
|
|
16
16
|
#import "TrueSheetViewController.h"
|
|
17
|
+
#import "core/RNScreensEventObserver.h"
|
|
17
18
|
#import "events/TrueSheetDragEvents.h"
|
|
18
19
|
#import "events/TrueSheetFocusEvents.h"
|
|
19
20
|
#import "events/TrueSheetLifecycleEvents.h"
|
|
@@ -36,7 +37,9 @@
|
|
|
36
37
|
|
|
37
38
|
using namespace facebook::react;
|
|
38
39
|
|
|
39
|
-
@interface TrueSheetView () <TrueSheetViewControllerDelegate,
|
|
40
|
+
@interface TrueSheetView () <TrueSheetViewControllerDelegate,
|
|
41
|
+
TrueSheetContainerViewDelegate,
|
|
42
|
+
RNScreensEventObserverDelegate>
|
|
40
43
|
@end
|
|
41
44
|
|
|
42
45
|
@implementation TrueSheetView {
|
|
@@ -52,6 +55,10 @@ using namespace facebook::react;
|
|
|
52
55
|
BOOL _isSheetUpdatePending;
|
|
53
56
|
BOOL _pendingLayoutUpdate;
|
|
54
57
|
BOOL _didInitiallyPresent;
|
|
58
|
+
BOOL _dismissedByNavigation;
|
|
59
|
+
BOOL _pendingNavigationRepresent;
|
|
60
|
+
BOOL _pendingMountEvent;
|
|
61
|
+
RNScreensEventObserver *_screensEventObserver;
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
#pragma mark - Initialization
|
|
@@ -75,6 +82,9 @@ using namespace facebook::react;
|
|
|
75
82
|
_initialDetentAnimated = YES;
|
|
76
83
|
_scrollable = NO;
|
|
77
84
|
_isSheetUpdatePending = NO;
|
|
85
|
+
|
|
86
|
+
_screensEventObserver = [[RNScreensEventObserver alloc] init];
|
|
87
|
+
_screensEventObserver.delegate = self;
|
|
78
88
|
}
|
|
79
89
|
return self;
|
|
80
90
|
}
|
|
@@ -89,6 +99,12 @@ using namespace facebook::react;
|
|
|
89
99
|
[TrueSheetModule registerView:self withTag:@(self.tag)];
|
|
90
100
|
}
|
|
91
101
|
|
|
102
|
+
if (_pendingNavigationRepresent && !_controller.isPresented) {
|
|
103
|
+
_pendingNavigationRepresent = NO;
|
|
104
|
+
[self presentAtIndex:_controller.activeDetentIndex animated:YES completion:nil];
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
92
108
|
if (_initialDetentIndex >= 0 && !_didInitiallyPresent) {
|
|
93
109
|
UIViewController *vc = [self findPresentingViewController];
|
|
94
110
|
|
|
@@ -104,6 +120,9 @@ using namespace facebook::react;
|
|
|
104
120
|
}
|
|
105
121
|
|
|
106
122
|
- (void)dealloc {
|
|
123
|
+
[_screensEventObserver stopObserving];
|
|
124
|
+
_screensEventObserver = nil;
|
|
125
|
+
|
|
107
126
|
if (_controller && _controller.presentingViewController) {
|
|
108
127
|
// Find the root presenting controller to dismiss the entire stack
|
|
109
128
|
UIViewController *root = _controller.presentingViewController;
|
|
@@ -114,6 +133,8 @@ using namespace facebook::react;
|
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
_didInitiallyPresent = NO;
|
|
136
|
+
_dismissedByNavigation = NO;
|
|
137
|
+
_pendingNavigationRepresent = NO;
|
|
117
138
|
|
|
118
139
|
_controller.delegate = nil;
|
|
119
140
|
_controller = nil;
|
|
@@ -227,6 +248,8 @@ using namespace facebook::react;
|
|
|
227
248
|
if (_controller) {
|
|
228
249
|
[self updateStateWithSize:_controller.view.frame.size];
|
|
229
250
|
}
|
|
251
|
+
|
|
252
|
+
[_screensEventObserver startObservingWithState:_state.get()->getData()];
|
|
230
253
|
}
|
|
231
254
|
|
|
232
255
|
/**
|
|
@@ -248,6 +271,12 @@ using namespace facebook::react;
|
|
|
248
271
|
- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
|
|
249
272
|
[super finalizeUpdates:updateMask];
|
|
250
273
|
|
|
274
|
+
// Emit pending mount event now that eventEmitter is available
|
|
275
|
+
if (_pendingMountEvent && (updateMask & RNComponentViewUpdateMaskEventEmitter)) {
|
|
276
|
+
_pendingMountEvent = NO;
|
|
277
|
+
[TrueSheetLifecycleEvents emitMount:_eventEmitter];
|
|
278
|
+
}
|
|
279
|
+
|
|
251
280
|
if (!(updateMask & RNComponentViewUpdateMaskProps) || !_controller)
|
|
252
281
|
return;
|
|
253
282
|
|
|
@@ -281,6 +310,8 @@ using namespace facebook::react;
|
|
|
281
310
|
|
|
282
311
|
_lastStateSize = CGSizeZero;
|
|
283
312
|
_didInitiallyPresent = NO;
|
|
313
|
+
_dismissedByNavigation = NO;
|
|
314
|
+
_pendingNavigationRepresent = NO;
|
|
284
315
|
}
|
|
285
316
|
|
|
286
317
|
#pragma mark - Child Component Mounting
|
|
@@ -320,19 +351,25 @@ using namespace facebook::react;
|
|
|
320
351
|
_containerView.scrollViewPinningEnabled = _scrollable;
|
|
321
352
|
[_containerView setupContentScrollViewPinning];
|
|
322
353
|
|
|
323
|
-
|
|
354
|
+
if (_eventEmitter) {
|
|
355
|
+
[TrueSheetLifecycleEvents emitMount:_eventEmitter];
|
|
356
|
+
} else {
|
|
357
|
+
_pendingMountEvent = YES;
|
|
358
|
+
}
|
|
324
359
|
}
|
|
325
360
|
|
|
326
361
|
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
|
|
327
362
|
if (![childComponentView isKindOfClass:[TrueSheetContainerView class]])
|
|
328
363
|
return;
|
|
329
364
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
snapshot
|
|
334
|
-
|
|
335
|
-
|
|
365
|
+
if (_controller.isPresented) {
|
|
366
|
+
UIView *superView = _containerView.superview;
|
|
367
|
+
UIView *snapshot = [_containerView snapshotViewAfterScreenUpdates:NO];
|
|
368
|
+
if (snapshot) {
|
|
369
|
+
snapshot.frame = _containerView.frame;
|
|
370
|
+
[superView insertSubview:snapshot belowSubview:_containerView];
|
|
371
|
+
_snapshotView = snapshot;
|
|
372
|
+
}
|
|
336
373
|
}
|
|
337
374
|
|
|
338
375
|
_containerView.delegate = nil;
|
|
@@ -381,6 +418,8 @@ using namespace facebook::react;
|
|
|
381
418
|
[_controller setupSheetDetents];
|
|
382
419
|
[_controller setupActiveDetentWithIndex:index];
|
|
383
420
|
|
|
421
|
+
[_screensEventObserver capturePresenterScreenFromView:self];
|
|
422
|
+
|
|
384
423
|
[presentingViewController presentViewController:_controller
|
|
385
424
|
animated:animated
|
|
386
425
|
completion:^{
|
|
@@ -510,13 +549,20 @@ using namespace facebook::react;
|
|
|
510
549
|
}
|
|
511
550
|
|
|
512
551
|
- (void)viewControllerWillDismiss {
|
|
513
|
-
|
|
514
|
-
|
|
552
|
+
if (!_dismissedByNavigation) {
|
|
553
|
+
[TrueSheetLifecycleEvents emitWillDismiss:_eventEmitter];
|
|
554
|
+
}
|
|
515
555
|
}
|
|
516
556
|
|
|
517
557
|
- (void)viewControllerDidDismiss {
|
|
518
|
-
|
|
519
|
-
|
|
558
|
+
[_containerView cleanupKeyboardHandler];
|
|
559
|
+
if (!_dismissedByNavigation) {
|
|
560
|
+
_dismissedByNavigation = NO;
|
|
561
|
+
_pendingNavigationRepresent = NO;
|
|
562
|
+
|
|
563
|
+
_controller.activeDetentIndex = -1;
|
|
564
|
+
[TrueSheetLifecycleEvents emitDidDismiss:_eventEmitter];
|
|
565
|
+
}
|
|
520
566
|
}
|
|
521
567
|
|
|
522
568
|
- (void)viewControllerDidChangeDetent:(NSInteger)index position:(CGFloat)position detent:(CGFloat)detent {
|
|
@@ -553,8 +599,20 @@ using namespace facebook::react;
|
|
|
553
599
|
[TrueSheetFocusEvents emitDidBlur:_eventEmitter];
|
|
554
600
|
}
|
|
555
601
|
|
|
556
|
-
-
|
|
557
|
-
|
|
602
|
+
#pragma mark - RNScreensEventObserverDelegate
|
|
603
|
+
|
|
604
|
+
- (void)presenterScreenWillDisappear {
|
|
605
|
+
if (_controller.isPresented && !_controller.isBeingDismissed) {
|
|
606
|
+
_dismissedByNavigation = YES;
|
|
607
|
+
[self dismissAllAnimated:YES completion:nil];
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
- (void)presenterScreenWillAppear {
|
|
612
|
+
if (_dismissedByNavigation && !_controller.isPresented && !_controller.isBeingPresented) {
|
|
613
|
+
_dismissedByNavigation = NO;
|
|
614
|
+
_pendingNavigationRepresent = YES;
|
|
615
|
+
}
|
|
558
616
|
}
|
|
559
617
|
|
|
560
618
|
#pragma mark - Private Helpers
|
|
@@ -16,13 +16,6 @@
|
|
|
16
16
|
#define RNS_DISMISSIBLE_MODAL_PROTOCOL_AVAILABLE 0
|
|
17
17
|
#endif
|
|
18
18
|
|
|
19
|
-
#if __has_include(<RNScreens/RNSLifecycleListenerProtocol.h>)
|
|
20
|
-
#import <RNScreens/RNSLifecycleListenerProtocol.h>
|
|
21
|
-
#define RNS_LIFECYCLE_LISTENER_PROTOCOL_AVAILABLE 1
|
|
22
|
-
#else
|
|
23
|
-
#define RNS_LIFECYCLE_LISTENER_PROTOCOL_AVAILABLE 0
|
|
24
|
-
#endif
|
|
25
|
-
|
|
26
19
|
NS_ASSUME_NONNULL_BEGIN
|
|
27
20
|
|
|
28
21
|
@protocol TrueSheetViewControllerDelegate <NSObject>
|
|
@@ -46,10 +39,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
46
39
|
- (void)viewControllerWillBlur;
|
|
47
40
|
- (void)viewControllerDidBlur;
|
|
48
41
|
|
|
49
|
-
#if RNS_LIFECYCLE_LISTENER_PROTOCOL_AVAILABLE
|
|
50
|
-
- (void)viewControllerDidDetectScreenDisappear;
|
|
51
|
-
#endif
|
|
52
|
-
|
|
53
42
|
@end
|
|
54
43
|
|
|
55
44
|
@interface TrueSheetViewController : UIViewController <UISheetPresentationControllerDelegate,
|
|
@@ -57,10 +46,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
57
46
|
#if RNS_DISMISSIBLE_MODAL_PROTOCOL_AVAILABLE
|
|
58
47
|
,
|
|
59
48
|
RNSDismissibleModalProtocol
|
|
60
|
-
#endif
|
|
61
|
-
#if RNS_LIFECYCLE_LISTENER_PROTOCOL_AVAILABLE
|
|
62
|
-
,
|
|
63
|
-
RNSLifecycleListenerProtocol
|
|
64
49
|
#endif
|
|
65
50
|
>
|
|
66
51
|
|