Fix rtcRefreshControl

Reviewed By: javache

Differential Revision: D3428671

fbshipit-source-id: c3ae599d4a1a831513b4a7c88ae6aa3b3469e92a
This commit is contained in:
Clement Genzmer 2016-06-13 17:44:55 -07:00 committed by Facebook Github Bot 8
parent 88f08ec99a
commit 7c8b91442b
1 changed files with 11 additions and 11 deletions

View File

@ -140,7 +140,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
@property (nonatomic, copy) NSIndexSet *stickyHeaderIndices;
@property (nonatomic, assign) BOOL centerContent;
@property (nonatomic, strong) RCTRefreshControl *refreshControl;
@property (nonatomic, strong) RCTRefreshControl *rctRefreshControl;
@end
@ -275,8 +275,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
CGFloat scrollTop = self.bounds.origin.y + self.contentInset.top;
// If the RefreshControl is refreshing, remove it's height so sticky headers are
// positioned properly when scrolling down while refreshing.
if (self.refreshControl != nil && self.refreshControl.refreshing) {
scrollTop -= self.refreshControl.frame.size.height;
if (_rctRefreshControl != nil && _rctRefreshControl.refreshing) {
scrollTop -= _rctRefreshControl.frame.size.height;
}
// Find the section headers that need to be docked
@ -358,13 +358,13 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
return [super hitTest:point withEvent:event];
}
- (void)setRefreshControl:(RCTRefreshControl *)refreshControl
- (void)setRctRefreshControl:(RCTRefreshControl *)refreshControl
{
if (_refreshControl) {
[_refreshControl removeFromSuperview];
if (_rctRefreshControl) {
[_rctRefreshControl removeFromSuperview];
}
_refreshControl = refreshControl;
[self addSubview:_refreshControl];
_rctRefreshControl = refreshControl;
[self addSubview:_rctRefreshControl];
}
@end
@ -422,7 +422,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
{
[super insertReactSubview:view atIndex:atIndex];
if ([view isKindOfClass:[RCTRefreshControl class]]) {
_scrollView.refreshControl = (RCTRefreshControl*)view;
[_scrollView setRctRefreshControl:(RCTRefreshControl *)view];
} else {
RCTAssert(_contentView == nil, @"RCTScrollView may only contain a single subview");
_contentView = view;
@ -434,7 +434,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
{
[super removeReactSubview:subview];
if ([subview isKindOfClass:[RCTRefreshControl class]]) {
_scrollView.refreshControl = nil;
[_scrollView setRctRefreshControl:nil];
} else {
RCTAssert(_contentView == subview, @"Attempted to remove non-existent subview");
_contentView = nil;
@ -490,7 +490,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
_scrollView.contentOffset = originalOffset;
// Adjust the refresh control frame if the scrollview layout changes.
RCTRefreshControl *refreshControl = _scrollView.refreshControl;
RCTRefreshControl *refreshControl = _scrollView.rctRefreshControl;
if (refreshControl && refreshControl.refreshing) {
refreshControl.frame = (CGRect){_scrollView.contentOffset, {_scrollView.frame.size.width, refreshControl.frame.size.height}};
}