Revert D20587945: iOS: Fix refreshControl layouting

Differential Revision:
D20587945

Original commit changeset: 94f560b17e36

fbshipit-source-id: e8ec95b2ea8632ef09e132351a1458cf97671206
This commit is contained in:
Valentin Shergin authored and Facebook GitHub Bot committed 2020-04-28 13:09:11 -07:00
1 parent 9263eb5d38
commit 79bc7f9fad
2 files changed
+20 -4

No files matched your search

@@ -41,6 +41,12 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
{
[super layoutSubviews];
// Fix for bug #7976
// TODO: Remove when updating to use iOS 10 refreshControl UIScrollView prop.
if (self.backgroundColor == nil) {
self.backgroundColor = [UIColor clearColor];
}
// If the control is refreshing when mounted we need to call
// beginRefreshing in layoutSubview or it doesn't work.
if (_currentRefreshingState && _isInitialRender) {
+14 -4
View File
@@ -32,7 +32,7 @@
@property (nonatomic, assign) BOOL centerContent;
#if !TARGET_OS_TV
@property (nonatomic, strong) UIRefreshControl<RCTCustomRefreshContolProtocol> *customRefreshControl;
@property (nonatomic, strong) UIView<RCTCustomRefreshContolProtocol> *customRefreshControl;
@property (nonatomic, assign) BOOL pinchGestureEnabled;
#endif
@@ -224,13 +224,13 @@
}
#if !TARGET_OS_TV
- (void)setCustomRefreshControl:(UIRefreshControl<RCTCustomRefreshContolProtocol> *)refreshControl
- (void)setCustomRefreshControl:(UIView<RCTCustomRefreshContolProtocol> *)refreshControl
{
if (_customRefreshControl) {
[_customRefreshControl removeFromSuperview];
}
_customRefreshControl = refreshControl;
self.refreshControl = refreshControl;
[self addSubview:_customRefreshControl];
}
- (void)setPinchGestureEnabled:(BOOL)pinchGestureEnabled
@@ -344,7 +344,7 @@ static inline void RCTApplyTransformationAccordingLayoutDirection(
[super insertReactSubview:view atIndex:atIndex];
#if !TARGET_OS_TV
if ([view conformsToProtocol:@protocol(RCTCustomRefreshContolProtocol)]) {
[_scrollView setCustomRefreshControl:(UIRefreshControl<RCTCustomRefreshContolProtocol> *)view];
[_scrollView setCustomRefreshControl:(UIView<RCTCustomRefreshContolProtocol> *)view];
if (![view isKindOfClass:[UIRefreshControl class]] && [view conformsToProtocol:@protocol(UIScrollViewDelegate)]) {
[self addScrollListener:(UIView<UIScrollViewDelegate> *)view];
}
@@ -418,6 +418,16 @@ static inline void RCTApplyTransformationAccordingLayoutDirection(
[super layoutSubviews];
RCTAssert(self.subviews.count == 1, @"we should only have exactly one subview");
RCTAssert([self.subviews lastObject] == _scrollView, @"our only subview should be a scrollview");
#if !TARGET_OS_TV
// Adjust the refresh control frame if the scrollview layout changes.
UIView<RCTCustomRefreshContolProtocol> *refreshControl = _scrollView.customRefreshControl;
if (refreshControl && refreshControl.isRefreshing) {
refreshControl.frame =
(CGRect){_scrollView.contentOffset, {_scrollView.frame.size.width, refreshControl.frame.size.height}};
}
#endif
[self updateClippedSubviews];
}