@@ -155,7 +155,7 @@ @interface RCTCustomScrollView : UIScrollView<UIGestureRecognizerDelegate>
155
155
156
156
@property (nonatomic , assign ) BOOL centerContent;
157
157
#if !TARGET_OS_TV
158
- @property (nonatomic , strong ) RCTRefreshControl *rctRefreshControl ;
158
+ @property (nonatomic , strong ) UIView<RCTCustomRefreshContolProtocol> *customRefreshControl ;
159
159
@property (nonatomic , assign ) BOOL pinchGestureEnabled;
160
160
#endif
161
161
@@ -329,13 +329,13 @@ - (void)setFrame:(CGRect)frame
329
329
}
330
330
331
331
#if !TARGET_OS_TV
332
- - (void )setRctRefreshControl : (RCTRefreshControl *)refreshControl
332
+ - (void )setCustomRefreshControl : (UIView<RCTCustomRefreshContolProtocol> *)refreshControl
333
333
{
334
- if (_rctRefreshControl ) {
335
- [_rctRefreshControl removeFromSuperview ];
334
+ if (_customRefreshControl ) {
335
+ [_customRefreshControl removeFromSuperview ];
336
336
}
337
- _rctRefreshControl = refreshControl;
338
- [self addSubview: _rctRefreshControl ];
337
+ _customRefreshControl = refreshControl;
338
+ [self addSubview: _customRefreshControl ];
339
339
}
340
340
341
341
- (void )setPinchGestureEnabled : (BOOL )pinchGestureEnabled
@@ -443,13 +443,12 @@ - (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex
443
443
{
444
444
[super insertReactSubview: view atIndex: atIndex];
445
445
#if !TARGET_OS_TV
446
- if ([view isKindOfClass: [RCTRefreshControl class ]]) {
447
- [_scrollView setRctRefreshControl: (RCTRefreshControl *)view];
448
- }
449
- else if ([view conformsToProtocol: @protocol (UIScrollViewDelegate)]) {
450
- [self addScrollListener: (UIView<UIScrollViewDelegate> *)view];
451
- [_scrollView addSubview: view];
452
- [_scrollView sendSubviewToBack: view];
446
+ if ([view conformsToProtocol: @protocol (RCTCustomRefreshContolProtocol)]) {
447
+ [_scrollView setCustomRefreshControl: (UIView<RCTCustomRefreshContolProtocol> *)view];
448
+ if (![view isKindOfClass: [UIRefreshControl class ]]
449
+ && [view conformsToProtocol: @protocol (UIScrollViewDelegate)]) {
450
+ [self addScrollListener: (UIView<UIScrollViewDelegate> *)view];
451
+ }
453
452
} else
454
453
#endif
455
454
{
@@ -464,11 +463,12 @@ - (void)removeReactSubview:(UIView *)subview
464
463
{
465
464
[super removeReactSubview: subview];
466
465
#if !TARGET_OS_TV
467
- if ([subview isKindOfClass: [RCTRefreshControl class ]]) {
468
- [_scrollView setRctRefreshControl: nil ];
469
- } else if ([subview conformsToProtocol: @protocol (UIScrollViewDelegate)]) {
470
- [self removeScrollListener: (UIView<UIScrollViewDelegate> *)subview];
471
- [subview removeFromSuperview ];
466
+ if ([subview conformsToProtocol: @protocol (RCTCustomRefreshContolProtocol)]) {
467
+ [_scrollView setCustomRefreshControl: nil ];
468
+ if (![subview isKindOfClass: [UIRefreshControl class ]]
469
+ && [subview conformsToProtocol: @protocol (UIScrollViewDelegate)]) {
470
+ [self removeScrollListener: (UIView<UIScrollViewDelegate> *)subview];
471
+ }
472
472
} else
473
473
#endif
474
474
{
@@ -519,8 +519,8 @@ - (void)layoutSubviews
519
519
520
520
#if !TARGET_OS_TV
521
521
// Adjust the refresh control frame if the scrollview layout changes.
522
- RCTRefreshControl *refreshControl = _scrollView.rctRefreshControl ;
523
- if (refreshControl && refreshControl.refreshing ) {
522
+ UIView<RCTCustomRefreshContolProtocol> *refreshControl = _scrollView.customRefreshControl ;
523
+ if (refreshControl && refreshControl.isRefreshing ) {
524
524
refreshControl.frame = (CGRect ){_scrollView.contentOffset , {_scrollView.frame .size .width , refreshControl.frame .size .height }};
525
525
}
526
526
#endif
0 commit comments