@lodev09/react-native-true-sheet 4.0.0-beta.10 → 4.0.0-beta.11
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/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.cpp
CHANGED
|
@@ -21,15 +21,13 @@ void TrueSheetContentViewShadowNode::layout(LayoutContext layoutContext) {
|
|
|
21
21
|
updateNaturalHeightIfNeeded(layoutContext);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
// own size back as a content size change — e.g. flex: 1 content tracking a
|
|
28
|
-
// drag frame by frame.
|
|
24
|
+
// Even auto-height content can be constrained by the container when a
|
|
25
|
+
// descendant ScrollView shrinks to fit. Its committed height then hides
|
|
26
|
+
// content growth, so only a fixed, non-flexible height can be used directly.
|
|
29
27
|
static bool isHeightContainerDerived(const yoga::Style &style) {
|
|
30
28
|
return style.flexGrow().unwrapOrDefault(0) > 0 ||
|
|
31
29
|
style.flexShrink().unwrapOrDefault(0) > 0 ||
|
|
32
|
-
style.dimension(Dimension::Height).
|
|
30
|
+
!style.dimension(Dimension::Height).isPoints();
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
// The natural height is the height the content wants when unbounded — the
|
|
@@ -168,6 +168,8 @@ using namespace facebook::react;
|
|
|
168
168
|
if (_scrollableHandle > 0 && !_detectedScrollView) {
|
|
169
169
|
[self.delegate contentViewScrollViewDidChange];
|
|
170
170
|
}
|
|
171
|
+
|
|
172
|
+
[self updateKeyboardInset];
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
#pragma mark - Scrollable
|
|
@@ -183,6 +185,13 @@ using namespace facebook::react;
|
|
|
183
185
|
_detectedScrollView.scrollView.contentInset = contentInset;
|
|
184
186
|
}
|
|
185
187
|
|
|
188
|
+
- (void)updateKeyboardInset {
|
|
189
|
+
CGFloat keyboardHeight = _keyboardObserver.currentHeight;
|
|
190
|
+
if (_detectedScrollView && keyboardHeight > 0) {
|
|
191
|
+
[self setKeyboardInset:[self keyboardInsetWithHeight:keyboardHeight]];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
186
195
|
- (void)clearScrollable {
|
|
187
196
|
[self setKeyboardInset:0];
|
|
188
197
|
_appliedKeyboardOffset = 0;
|
|
@@ -213,26 +222,22 @@ using namespace facebook::react;
|
|
|
213
222
|
[self applyContentInsetAdjustment];
|
|
214
223
|
|
|
215
224
|
// If keyboard is currently showing, re-apply the keyboard inset to the new ScrollView
|
|
216
|
-
|
|
217
|
-
if (keyboardHeight > 0) {
|
|
218
|
-
[self setKeyboardInset:[self keyboardInsetWithHeight:keyboardHeight]];
|
|
219
|
-
}
|
|
225
|
+
[self updateKeyboardInset];
|
|
220
226
|
}
|
|
221
227
|
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
// floats within the viewport — its clearance is the content padding's job
|
|
225
|
-
// (the caret reveal accounts for it, see footerOcclusion).
|
|
228
|
+
// Short or nested scroll views can end above the sheet's bottom edge.
|
|
229
|
+
// Measure their actual keyboard overlap, including space occupied by a relative footer.
|
|
226
230
|
- (CGFloat)keyboardInsetWithHeight:(CGFloat)height {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
+
UIScrollView *scrollView = _detectedScrollView.scrollView;
|
|
232
|
+
UIWindow *window = scrollView.window;
|
|
233
|
+
CGRect scrollFrame = [scrollView convertRect:scrollView.bounds toView:window];
|
|
234
|
+
CGFloat keyboardTop = CGRectGetMaxY(window.bounds) - height;
|
|
235
|
+
CGFloat inset = MAX(0, CGRectGetMaxY(scrollFrame) - keyboardTop);
|
|
231
236
|
|
|
232
237
|
// UIKit stacks the safe area on top of contentInset while the adjustment
|
|
233
238
|
// behavior is automatic — take it out so the total lands on the keyboard edge.
|
|
234
239
|
if (_appliedContentInsetAdjustment) {
|
|
235
|
-
inset = MAX(0, inset -
|
|
240
|
+
inset = MAX(0, inset - scrollView.safeAreaInsets.bottom);
|
|
236
241
|
}
|
|
237
242
|
|
|
238
243
|
// Track how much of keyboardOffset actually lands in the inset so the caret
|
|
@@ -242,7 +247,6 @@ using namespace facebook::react;
|
|
|
242
247
|
|
|
243
248
|
// Content that already fits above the keyboard has nothing to reveal — the
|
|
244
249
|
// inset would only open blank scroll range below it (huge gap at the bottom).
|
|
245
|
-
UIScrollView *scrollView = _detectedScrollView.scrollView;
|
|
246
250
|
if (scrollView.contentSize.height <= scrollView.bounds.size.height - adjustedInset) {
|
|
247
251
|
_appliedKeyboardOffset = 0;
|
|
248
252
|
return 0;
|
|
@@ -334,12 +338,14 @@ using namespace facebook::react;
|
|
|
334
338
|
|
|
335
339
|
CGFloat inset = [self keyboardInsetWithHeight:height];
|
|
336
340
|
[UIView animateWithDuration:duration
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
341
|
+
delay:0
|
|
342
|
+
options:curve | UIViewAnimationOptionBeginFromCurrentState
|
|
343
|
+
animations:^{
|
|
344
|
+
[self setKeyboardInset:inset];
|
|
345
|
+
}
|
|
346
|
+
completion:^(BOOL finished) {
|
|
347
|
+
[self updateKeyboardInset];
|
|
348
|
+
}];
|
|
343
349
|
|
|
344
350
|
// Defer scroll until the next run loop so content insets are applied first
|
|
345
351
|
if (firstResponder) {
|
|
@@ -363,7 +369,7 @@ using namespace facebook::react;
|
|
|
363
369
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
364
370
|
// Typing can grow the content (e.g. a multiline input) past the fits-above-
|
|
365
371
|
// the-keyboard threshold — keep the inset in sync before revealing the caret.
|
|
366
|
-
[self
|
|
372
|
+
[self updateKeyboardInset];
|
|
367
373
|
[self scrollToFocusedCaretAnimated:YES];
|
|
368
374
|
});
|
|
369
375
|
}
|
package/package.json
CHANGED