Skip to content

Commit

Permalink
replace contentInsetsForView: with RCTContentInsets()
Browse files Browse the repository at this point in the history
Summary:
as title

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D31949240

fbshipit-source-id: 2660a4b44fd2aad5cda52ec61e741e7b4e9eb442
  • Loading branch information
philIip authored and facebook-github-bot committed Nov 10, 2021
1 parent 98abf1b commit f10741a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
5 changes: 0 additions & 5 deletions React/Views/RCTView.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
withScrollView:(UIScrollView *)scrollView
updateOffset:(BOOL)updateOffset;

/**
* Find the first view controller whose view, or any subview is the specified view.
*/
+ (UIEdgeInsets)contentInsetsForView:(UIView *)curView;

/**
* Layout direction of the view.
* This is inherited from UIView+React, but we override it here
Expand Down
15 changes: 2 additions & 13 deletions React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "RCTBorderDrawing.h"
#import "RCTI18nUtil.h"
#import "RCTLog.h"
#import "RCTViewUtils.h"
#import "UIView+React.h"

UIAccessibilityTraits const SwitchAccessibilityTrait = 0x20000000000001;
Expand Down Expand Up @@ -456,7 +457,7 @@ + (void)autoAdjustInsetsForView:(UIView<RCTAutoInsetsProtocol> *)parentView
CGPoint contentOffset = scrollView.contentOffset;

if (parentView.automaticallyAdjustContentInsets) {
UIEdgeInsets autoInset = [self contentInsetsForView:parentView];
UIEdgeInsets autoInset = RCTContentInsets(parentView);
baseInset.top += autoInset.top;
baseInset.bottom += autoInset.bottom;
baseInset.left += autoInset.left;
Expand All @@ -478,18 +479,6 @@ + (void)autoAdjustInsetsForView:(UIView<RCTAutoInsetsProtocol> *)parentView
}
}

+ (UIEdgeInsets)contentInsetsForView:(UIView *)view
{
while (view) {
UIViewController *controller = view.reactViewController;
if (controller) {
return controller.view.safeAreaInsets;
}
view = view.superview;
}
return UIEdgeInsetsZero;
}

#pragma mark - View Unmounting

- (void)react_remountAllSubviews
Expand Down
3 changes: 2 additions & 1 deletion React/Views/ScrollView/RCTScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "RCTUIManagerObserverCoordinator.h"
#import "RCTUIManagerUtils.h"
#import "RCTUtils.h"
#import "RCTViewUtils.h"
#import "UIView+Private.h"
#import "UIView+React.h"

Expand Down Expand Up @@ -793,7 +794,7 @@ - (CGSize)_calculateViewportSize
{
CGSize viewportSize = self.bounds.size;
if (_automaticallyAdjustContentInsets) {
UIEdgeInsets contentInsets = [RCTView contentInsetsForView:self];
UIEdgeInsets contentInsets = RCTContentInsets(self);
viewportSize = CGSizeMake(
self.bounds.size.width - contentInsets.left - contentInsets.right,
self.bounds.size.height - contentInsets.top - contentInsets.bottom);
Expand Down

0 comments on commit f10741a

Please sign in to comment.