@lodev09/react-native-true-sheet 3.7.4-beta.0 → 3.7.4-beta.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.
- 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/TrueSheetViewController.mm +32 -77
- package/ios/utils/LayoutUtil.h +23 -0
- package/ios/utils/LayoutUtil.mm +28 -3
- package/package.json +1 -1
|
@@ -79,7 +79,7 @@ using namespace facebook::react;
|
|
|
79
79
|
|
|
80
80
|
- (void)setupContentScrollViewPinning {
|
|
81
81
|
if (_scrollViewPinningSet && _contentView) {
|
|
82
|
-
[_contentView setupScrollViewPinning:_scrollViewPinningEnabled
|
|
82
|
+
[_contentView setupScrollViewPinning:_scrollViewPinningEnabled];
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -104,10 +104,6 @@ using namespace facebook::react;
|
|
|
104
104
|
}
|
|
105
105
|
_headerView = (TrueSheetHeaderView *)childComponentView;
|
|
106
106
|
_headerView.delegate = self;
|
|
107
|
-
|
|
108
|
-
if (_contentView) {
|
|
109
|
-
[self setupContentScrollViewPinning];
|
|
110
|
-
}
|
|
111
107
|
[self headerViewDidChangeSize:_headerView.frame.size];
|
|
112
108
|
}
|
|
113
109
|
|
|
@@ -129,10 +125,6 @@ using namespace facebook::react;
|
|
|
129
125
|
if ([childComponentView isKindOfClass:[TrueSheetHeaderView class]]) {
|
|
130
126
|
_headerView.delegate = nil;
|
|
131
127
|
_headerView = nil;
|
|
132
|
-
|
|
133
|
-
if (_contentView) {
|
|
134
|
-
[self setupContentScrollViewPinning];
|
|
135
|
-
}
|
|
136
128
|
[self headerViewDidChangeSize:CGSizeZero];
|
|
137
129
|
}
|
|
138
130
|
|
|
@@ -150,21 +142,21 @@ using namespace facebook::react;
|
|
|
150
142
|
#pragma mark - TrueSheetContentViewDelegate
|
|
151
143
|
|
|
152
144
|
- (void)contentViewDidChangeSize:(CGSize)newSize {
|
|
153
|
-
|
|
154
|
-
[self.delegate containerViewContentDidChangeSize:newSize];
|
|
155
|
-
}
|
|
145
|
+
[self.delegate containerViewContentDidChangeSize:newSize];
|
|
156
146
|
}
|
|
157
147
|
|
|
158
148
|
- (void)contentViewDidChangeChildren {
|
|
159
149
|
[self setupContentScrollViewPinning];
|
|
160
150
|
}
|
|
161
151
|
|
|
152
|
+
- (void)contentViewDidChangeInsets {
|
|
153
|
+
[self setupContentScrollViewPinning];
|
|
154
|
+
}
|
|
155
|
+
|
|
162
156
|
#pragma mark - TrueSheetHeaderViewDelegate
|
|
163
157
|
|
|
164
158
|
- (void)headerViewDidChangeSize:(CGSize)newSize {
|
|
165
|
-
|
|
166
|
-
[self.delegate containerViewHeaderDidChangeSize:newSize];
|
|
167
|
-
}
|
|
159
|
+
[self.delegate containerViewHeaderDidChangeSize:newSize];
|
|
168
160
|
}
|
|
169
161
|
|
|
170
162
|
#pragma mark - Keyboard Handling
|
|
@@ -22,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
22
22
|
|
|
23
23
|
- (void)contentViewDidChangeSize:(CGSize)newSize;
|
|
24
24
|
- (void)contentViewDidChangeChildren;
|
|
25
|
+
- (void)contentViewDidChangeInsets;
|
|
25
26
|
|
|
26
27
|
@end
|
|
27
28
|
|
|
@@ -34,9 +35,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
34
35
|
/**
|
|
35
36
|
* Setup ScrollView pinning
|
|
36
37
|
* @param pinned Whether to pin the scroll view
|
|
37
|
-
* @param headerView Optional header view to pin below (can be nil)
|
|
38
38
|
*/
|
|
39
|
-
- (void)setupScrollViewPinning:(BOOL)pinned
|
|
39
|
+
- (void)setupScrollViewPinning:(BOOL)pinned;
|
|
40
40
|
|
|
41
41
|
@end
|
|
42
42
|
|
|
@@ -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
|
|
|
@@ -186,23 +186,16 @@
|
|
|
186
186
|
UIViewController *presenter = self.presentingViewController;
|
|
187
187
|
if ([presenter isKindOfClass:[TrueSheetViewController class]]) {
|
|
188
188
|
_parentSheetController = (TrueSheetViewController *)presenter;
|
|
189
|
-
|
|
190
|
-
[_parentSheetController.delegate viewControllerWillBlur];
|
|
191
|
-
}
|
|
189
|
+
[_parentSheetController.delegate viewControllerWillBlur];
|
|
192
190
|
}
|
|
193
191
|
|
|
194
192
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
CGFloat detent = [self detentValueForIndex:index];
|
|
199
|
-
|
|
200
|
-
[self.delegate viewControllerWillPresentAtIndex:index position:position detent:detent];
|
|
201
|
-
}
|
|
193
|
+
NSInteger index = self.currentDetentIndex;
|
|
194
|
+
CGFloat position = self.currentPosition;
|
|
195
|
+
CGFloat detent = [self detentValueForIndex:index];
|
|
202
196
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
197
|
+
[self.delegate viewControllerWillPresentAtIndex:index position:position detent:detent];
|
|
198
|
+
[self.delegate viewControllerWillFocus];
|
|
206
199
|
});
|
|
207
200
|
}
|
|
208
201
|
|
|
@@ -213,22 +206,13 @@
|
|
|
213
206
|
[super viewDidAppear:animated];
|
|
214
207
|
|
|
215
208
|
if (!_isPresented) {
|
|
216
|
-
|
|
217
|
-
if ([_parentSheetController.delegate respondsToSelector:@selector(viewControllerDidBlur)]) {
|
|
218
|
-
[_parentSheetController.delegate viewControllerDidBlur];
|
|
219
|
-
}
|
|
220
|
-
}
|
|
209
|
+
[_parentSheetController.delegate viewControllerDidBlur];
|
|
221
210
|
|
|
222
211
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if ([self.delegate respondsToSelector:@selector(viewControllerDidFocus)]) {
|
|
230
|
-
[self.delegate viewControllerDidFocus];
|
|
231
|
-
}
|
|
212
|
+
NSInteger index = [self currentDetentIndex];
|
|
213
|
+
CGFloat detent = [self detentValueForIndex:index];
|
|
214
|
+
[self.delegate viewControllerDidPresentAtIndex:index position:self.currentPosition detent:detent];
|
|
215
|
+
[self.delegate viewControllerDidFocus];
|
|
232
216
|
|
|
233
217
|
[self emitChangePositionDelegateWithPosition:self.currentPosition realtime:NO debug:@"did present"];
|
|
234
218
|
});
|
|
@@ -246,19 +230,9 @@
|
|
|
246
230
|
if (self.isDismissing && !_isWillDismissEmitted) {
|
|
247
231
|
_isWillDismissEmitted = YES;
|
|
248
232
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if ([self.delegate respondsToSelector:@selector(viewControllerWillDismiss)]) {
|
|
254
|
-
[self.delegate viewControllerWillDismiss];
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (_parentSheetController) {
|
|
258
|
-
if ([_parentSheetController.delegate respondsToSelector:@selector(viewControllerWillFocus)]) {
|
|
259
|
-
[_parentSheetController.delegate viewControllerWillFocus];
|
|
260
|
-
}
|
|
261
|
-
}
|
|
233
|
+
[self.delegate viewControllerWillBlur];
|
|
234
|
+
[self.delegate viewControllerWillDismiss];
|
|
235
|
+
[_parentSheetController.delegate viewControllerWillFocus];
|
|
262
236
|
}
|
|
263
237
|
}
|
|
264
238
|
|
|
@@ -267,20 +241,11 @@
|
|
|
267
241
|
_isPresented = NO;
|
|
268
242
|
_isWillDismissEmitted = NO;
|
|
269
243
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
[_parentSheetController.delegate viewControllerDidFocus];
|
|
273
|
-
}
|
|
274
|
-
_parentSheetController = nil;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if ([self.delegate respondsToSelector:@selector(viewControllerDidBlur)]) {
|
|
278
|
-
[self.delegate viewControllerDidBlur];
|
|
279
|
-
}
|
|
244
|
+
[_parentSheetController.delegate viewControllerDidFocus];
|
|
245
|
+
_parentSheetController = nil;
|
|
280
246
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
247
|
+
[self.delegate viewControllerDidBlur];
|
|
248
|
+
[self.delegate viewControllerDidDismiss];
|
|
284
249
|
}
|
|
285
250
|
}
|
|
286
251
|
|
|
@@ -327,21 +292,17 @@
|
|
|
327
292
|
- (void)viewDidLayoutSubviews {
|
|
328
293
|
[super viewDidLayoutSubviews];
|
|
329
294
|
|
|
330
|
-
|
|
331
|
-
[self.delegate viewControllerDidChangeSize:self.view.frame.size];
|
|
332
|
-
}
|
|
295
|
+
[self.delegate viewControllerDidChangeSize:self.view.frame.size];
|
|
333
296
|
|
|
334
297
|
if (_pendingDetentIndex >= 0) {
|
|
335
298
|
NSInteger pendingIndex = _pendingDetentIndex;
|
|
336
299
|
_pendingDetentIndex = -1;
|
|
337
300
|
|
|
338
301
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
[self emitChangePositionDelegateWithPosition:self.currentPosition realtime:NO debug:@"pending detent change"];
|
|
344
|
-
}
|
|
302
|
+
[self storeResolvedPositionForIndex:pendingIndex];
|
|
303
|
+
CGFloat detent = [self detentValueForIndex:pendingIndex];
|
|
304
|
+
[self.delegate viewControllerDidChangeDetent:pendingIndex position:self.currentPosition detent:detent];
|
|
305
|
+
[self emitChangePositionDelegateWithPosition:self.currentPosition realtime:NO debug:@"pending detent change"];
|
|
345
306
|
});
|
|
346
307
|
}
|
|
347
308
|
|
|
@@ -400,9 +361,7 @@
|
|
|
400
361
|
NSInteger index = self.currentDetentIndex;
|
|
401
362
|
CGFloat detent = [self detentValueForIndex:index];
|
|
402
363
|
|
|
403
|
-
|
|
404
|
-
[self.delegate viewControllerDidDrag:gesture.state index:index position:self.currentPosition detent:detent];
|
|
405
|
-
}
|
|
364
|
+
[self.delegate viewControllerDidDrag:gesture.state index:index position:self.currentPosition detent:detent];
|
|
406
365
|
|
|
407
366
|
switch (gesture.state) {
|
|
408
367
|
case UIGestureRecognizerStateBegan:
|
|
@@ -493,9 +452,7 @@
|
|
|
493
452
|
|
|
494
453
|
CGFloat index = [self interpolatedIndexForPosition:position];
|
|
495
454
|
CGFloat detent = [self interpolatedDetentForPosition:position];
|
|
496
|
-
|
|
497
|
-
[self.delegate viewControllerDidChangePosition:index position:position detent:detent realtime:realtime];
|
|
498
|
-
}
|
|
455
|
+
[self.delegate viewControllerDidChangePosition:index position:position detent:detent realtime:realtime];
|
|
499
456
|
}
|
|
500
457
|
}
|
|
501
458
|
|
|
@@ -778,15 +735,13 @@
|
|
|
778
735
|
|
|
779
736
|
- (void)sheetPresentationControllerDidChangeSelectedDetentIdentifier:
|
|
780
737
|
(UISheetPresentationController *)sheetPresentationController {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
});
|
|
789
|
-
}
|
|
738
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
739
|
+
NSInteger index = self.currentDetentIndex;
|
|
740
|
+
if (index >= 0) {
|
|
741
|
+
CGFloat detent = [self detentValueForIndex:index];
|
|
742
|
+
[self.delegate viewControllerDidChangeDetent:index position:self.currentPosition detent:detent];
|
|
743
|
+
}
|
|
744
|
+
});
|
|
790
745
|
}
|
|
791
746
|
|
|
792
747
|
#pragma mark - RNSDismissibleModalProtocol
|
package/ios/utils/LayoutUtil.h
CHANGED
|
@@ -40,6 +40,29 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
40
40
|
*/
|
|
41
41
|
+ (void)pinView:(UIView *)view toParentView:(UIView *)parentView withTopView:(UIView *)topView edges:(UIRectEdge)edges;
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Pins a view to its parent view with insets
|
|
45
|
+
* @param view The view to pin
|
|
46
|
+
* @param parentView The parent view to pin to
|
|
47
|
+
* @param edges The edges to pin (UIRectEdge flags)
|
|
48
|
+
* @param insets The insets to apply to each edge
|
|
49
|
+
*/
|
|
50
|
+
+ (void)pinView:(UIView *)view toParentView:(UIView *)parentView edges:(UIRectEdge)edges insets:(UIEdgeInsets)insets;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Pins a view to its parent view with its top edge anchored below a top sibling view, with insets
|
|
54
|
+
* @param view The view to pin
|
|
55
|
+
* @param parentView The parent view to pin to
|
|
56
|
+
* @param topView The view to position below (top sibling)
|
|
57
|
+
* @param edges The edges to pin to parent (excluding top, which is pinned to topView)
|
|
58
|
+
* @param insets The insets to apply to each edge
|
|
59
|
+
*/
|
|
60
|
+
+ (void)pinView:(UIView *)view
|
|
61
|
+
toParentView:(UIView *)parentView
|
|
62
|
+
withTopView:(UIView *)topView
|
|
63
|
+
edges:(UIRectEdge)edges
|
|
64
|
+
insets:(UIEdgeInsets)insets;
|
|
65
|
+
|
|
43
66
|
/**
|
|
44
67
|
* Unpins a view by removing its constraints and re-enabling autoresizing mask translation
|
|
45
68
|
* @param view The view to unpin
|
package/ios/utils/LayoutUtil.mm
CHANGED
|
@@ -38,7 +38,32 @@
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
+ (void)pinView:(UIView *)view toParentView:(UIView *)parentView edges:(UIRectEdge)edges insets:(UIEdgeInsets)insets {
|
|
42
|
+
view.translatesAutoresizingMaskIntoConstraints = NO;
|
|
43
|
+
|
|
44
|
+
if (edges & UIRectEdgeTop) {
|
|
45
|
+
[view.topAnchor constraintEqualToAnchor:parentView.topAnchor constant:insets.top].active = YES;
|
|
46
|
+
}
|
|
47
|
+
if (edges & UIRectEdgeBottom) {
|
|
48
|
+
[view.bottomAnchor constraintEqualToAnchor:parentView.bottomAnchor constant:-insets.bottom].active = YES;
|
|
49
|
+
}
|
|
50
|
+
if (edges & UIRectEdgeLeft) {
|
|
51
|
+
[view.leadingAnchor constraintEqualToAnchor:parentView.leadingAnchor constant:insets.left].active = YES;
|
|
52
|
+
}
|
|
53
|
+
if (edges & UIRectEdgeRight) {
|
|
54
|
+
[view.trailingAnchor constraintEqualToAnchor:parentView.trailingAnchor constant:-insets.right].active = YES;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
41
58
|
+ (void)pinView:(UIView *)view toParentView:(UIView *)parentView withTopView:(UIView *)topView edges:(UIRectEdge)edges {
|
|
59
|
+
[self pinView:view toParentView:parentView withTopView:topView edges:edges insets:UIEdgeInsetsZero];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
+ (void)pinView:(UIView *)view
|
|
63
|
+
toParentView:(UIView *)parentView
|
|
64
|
+
withTopView:(UIView *)topView
|
|
65
|
+
edges:(UIRectEdge)edges
|
|
66
|
+
insets:(UIEdgeInsets)insets {
|
|
42
67
|
view.translatesAutoresizingMaskIntoConstraints = NO;
|
|
43
68
|
|
|
44
69
|
// Pin top edge to bottom of top sibling
|
|
@@ -46,13 +71,13 @@
|
|
|
46
71
|
|
|
47
72
|
// Pin other edges to parent based on edges parameter
|
|
48
73
|
if (edges & UIRectEdgeBottom) {
|
|
49
|
-
[view.bottomAnchor constraintEqualToAnchor:parentView.bottomAnchor].active = YES;
|
|
74
|
+
[view.bottomAnchor constraintEqualToAnchor:parentView.bottomAnchor constant:-insets.bottom].active = YES;
|
|
50
75
|
}
|
|
51
76
|
if (edges & UIRectEdgeLeft) {
|
|
52
|
-
[view.leadingAnchor constraintEqualToAnchor:parentView.leadingAnchor].active = YES;
|
|
77
|
+
[view.leadingAnchor constraintEqualToAnchor:parentView.leadingAnchor constant:insets.left].active = YES;
|
|
53
78
|
}
|
|
54
79
|
if (edges & UIRectEdgeRight) {
|
|
55
|
-
[view.trailingAnchor constraintEqualToAnchor:parentView.trailingAnchor].active = YES;
|
|
80
|
+
[view.trailingAnchor constraintEqualToAnchor:parentView.trailingAnchor constant:-insets.right].active = YES;
|
|
56
81
|
}
|
|
57
82
|
}
|
|
58
83
|
|
package/package.json
CHANGED