Skip to content

Commit 96e6f1e

Browse files
authored
feat/tracking view allow safeArea (#1017)
* Replace unsafe method with getDerivedStateFromProps * allow tracking view to controll safe-area sapce, was allways true * add native code to support useSafeArea prop
1 parent e5bad6c commit 96e6f1e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/components/Keyboard/KeyboardTracking/KeyboardTrackingView.ios.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ class KeyboardTrackingView extends PureComponent {
2929
* (This is caused because of the usage of inputAccessory to be able to track the
3030
* keyboard interactive change and it introduces this bug)
3131
*/
32-
trackInteractive: PropTypes.bool
32+
trackInteractive: PropTypes.bool,
33+
/**
34+
* Allow control safe area
35+
*/
36+
useSafeArea: PropTypes.bool
37+
};
38+
39+
/** V6 should be change to default false */
40+
static defaultProps = {
41+
useSafeArea: true
3342
};
3443

3544
render() {

lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ @interface KeyboardTrackingViewTemp : UIView
5050
@property (nonatomic) CGFloat originalHeight;
5151
@property (nonatomic) KeyboardTrackingScrollBehavior scrollBehavior;
5252
@property (nonatomic) BOOL addBottomView;
53+
@property (nonatomic) BOOL useSafeArea;
5354
@property (nonatomic) BOOL scrollToFocusedInput;
5455
@property (nonatomic) BOOL allowHitsOutsideBounds;
5556

@@ -483,7 +484,7 @@ -(CGFloat)getBottomSafeArea
483484
{
484485
CGFloat bottomSafeArea = 0;
485486
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
486-
if (@available(iOS 11.0, *)) {
487+
if (@available(iOS 11.0, *) && self.useSafeArea) {
487488
bottomSafeArea = self.superview ? self.superview.safeAreaInsets.bottom : self.safeAreaInsets.bottom;
488489
}
489490
#endif
@@ -632,6 +633,7 @@ @implementation KeyboardTrackingViewTempManager
632633
RCT_REMAP_VIEW_PROPERTY(manageScrollView, manageScrollView, BOOL)
633634
RCT_REMAP_VIEW_PROPERTY(requiresSameParentToManageScrollView, requiresSameParentToManageScrollView, BOOL)
634635
RCT_REMAP_VIEW_PROPERTY(addBottomView, addBottomView, BOOL)
636+
RCT_REMAP_VIEW_PROPERTY(useSafeArea, useSafeArea, BOOL)
635637
RCT_REMAP_VIEW_PROPERTY(scrollToFocusedInput, scrollToFocusedInput, BOOL)
636638
RCT_REMAP_VIEW_PROPERTY(allowHitsOutsideBounds, allowHitsOutsideBounds, BOOL)
637639

0 commit comments

Comments
 (0)