Skip to content

Commit bef45fb

Browse files
sbuggayfacebook-github-bot
authored andcommitted
Compile out parts of RCTScrollView (#54999)
Summary: Parts of RCTScrollView are using APIs unsupported by AppleTV. Changelog: [Internal] Differential Revision: D89899914
1 parent 9adcac3 commit bef45fb

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/react-native/React/Views/ScrollView/RCTScrollView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ __attribute__((deprecated("This API will be removed along with the legacy archit
5151
@property (nonatomic, assign) BOOL snapToEnd;
5252
@property (nonatomic, copy) NSString *snapToAlignment;
5353
@property (nonatomic, assign) BOOL inverted;
54+
#if !TARGET_OS_TV
5455
/** Focus area of newly-activated text input relative to the window to compare against UIKeyboardFrameBegin/End */
5556
@property (nonatomic, assign) CGRect firstResponderFocus;
5657
/** newly-activated text input outside of the scroll view */
5758
@property (nonatomic, weak) UIView *firstResponderViewOutsideScrollView;
59+
#endif
5860

5961
// NOTE: currently these event props are only declared so we can export the
6062
// event names to JS - we don't call the blocks directly because scroll events

packages/react-native/React/Views/ScrollView/RCTScrollView.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,22 @@ - (void)setCustomRefreshControl:(UIView<RCTCustomRefreshControlProtocol> *)refre
211211
if ([_customRefreshControl respondsToSelector:@selector(setScrollView:)]) {
212212
_customRefreshControl.scrollView = self;
213213
}
214+
#if !TARGET_OS_TV
214215
if ([refreshControl isKindOfClass:UIRefreshControl.class]) {
215216
self.refreshControl = (UIRefreshControl *)refreshControl;
216217
} else {
218+
#endif
217219
[self addSubview:_customRefreshControl];
220+
#if !TARGET_OS_TV
218221
}
222+
#endif
219223
}
220224

221225
- (void)setPinchGestureEnabled:(BOOL)pinchGestureEnabled
222226
{
227+
#if !TARGET_OS_TV
223228
self.pinchGestureRecognizer.enabled = pinchGestureEnabled;
229+
#endif
224230
_pinchGestureEnabled = pinchGestureEnabled;
225231
}
226232

@@ -229,7 +235,9 @@ - (void)didMoveToWindow
229235
[super didMoveToWindow];
230236
// ScrollView enables pinch gesture late in its lifecycle. So simply setting it
231237
// in the setter gets overridden when the view loads.
238+
#if !TARGET_OS_TV
232239
self.pinchGestureRecognizer.enabled = _pinchGestureEnabled;
240+
#endif
233241
}
234242

235243
- (BOOL)shouldGroupAccessibilityChildren
@@ -260,15 +268,19 @@ @implementation RCTScrollView {
260268

261269
- (void)_registerKeyboardListener
262270
{
271+
#if !TARGET_OS_TV
263272
[[NSNotificationCenter defaultCenter] addObserver:self
264273
selector:@selector(_keyboardWillChangeFrame:)
265274
name:UIKeyboardWillChangeFrameNotification
266275
object:nil];
276+
#endif
267277
}
268278

269279
- (void)_unregisterKeyboardListener
270280
{
281+
#if !TARGET_OS_TV
271282
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
283+
#endif
272284
}
273285

274286
static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCurve curve)
@@ -283,6 +295,7 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
283295

284296
- (void)_keyboardWillChangeFrame:(NSNotification *)notification
285297
{
298+
#if !TARGET_OS_TV
286299
if (![self automaticallyAdjustKeyboardInsets]) {
287300
return;
288301
}
@@ -358,6 +371,7 @@ - (void)_keyboardWillChangeFrame:(NSNotification *)notification
358371
[self scrollToOffset:newContentOffset animated:NO];
359372
}
360373
completion:nil];
374+
#endif
361375
}
362376

363377
- (instancetype)initWithEventDispatcher:(id<RCTEventDispatcherProtocol>)eventDispatcher
@@ -428,7 +442,11 @@ - (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex
428442
[super insertReactSubview:view atIndex:atIndex];
429443
if ([view conformsToProtocol:@protocol(RCTCustomRefreshControlProtocol)]) {
430444
[_scrollView setCustomRefreshControl:(UIView<RCTCustomRefreshControlProtocol> *)view];
445+
#if !TARGET_OS_TV
431446
if (![view isKindOfClass:[UIRefreshControl class]] && [view conformsToProtocol:@protocol(UIScrollViewDelegate)]) {
447+
#else
448+
if ([view conformsToProtocol:@protocol(UIScrollViewDelegate)]) {
449+
#endif
432450
[self addScrollListener:(UIView<UIScrollViewDelegate> *)view];
433451
}
434452
} else {
@@ -449,8 +467,12 @@ - (void)removeReactSubview:(UIView *)subview
449467
[super removeReactSubview:subview];
450468
if ([subview conformsToProtocol:@protocol(RCTCustomRefreshControlProtocol)]) {
451469
[_scrollView setCustomRefreshControl:nil];
470+
#if !TARGET_OS_TV
452471
if (![subview isKindOfClass:[UIRefreshControl class]] &&
453472
[subview conformsToProtocol:@protocol(UIScrollViewDelegate)]) {
473+
#else
474+
if ([subview conformsToProtocol:@protocol(UIScrollViewDelegate)]) {
475+
#endif
454476
[self removeScrollListener:(UIView<UIScrollViewDelegate> *)subview];
455477
}
456478
} else {
@@ -1083,8 +1105,10 @@ -(type)getter \
10831105
RCT_SET_AND_PRESERVE_OFFSET(setMaximumZoomScale, maximumZoomScale, CGFloat)
10841106
RCT_SET_AND_PRESERVE_OFFSET(setMinimumZoomScale, minimumZoomScale, CGFloat)
10851107
RCT_SET_AND_PRESERVE_OFFSET(setScrollEnabled, isScrollEnabled, BOOL)
1108+
#if !TARGET_OS_TV
10861109
RCT_SET_AND_PRESERVE_OFFSET(setPagingEnabled, isPagingEnabled, BOOL)
10871110
RCT_SET_AND_PRESERVE_OFFSET(setScrollsToTop, scrollsToTop, BOOL)
1111+
#endif
10881112
RCT_SET_AND_PRESERVE_OFFSET(setShowsHorizontalScrollIndicator, showsHorizontalScrollIndicator, BOOL)
10891113
RCT_SET_AND_PRESERVE_OFFSET(setShowsVerticalScrollIndicator, showsVerticalScrollIndicator, BOOL)
10901114
RCT_SET_AND_PRESERVE_OFFSET(setZoomScale, zoomScale, CGFloat);

0 commit comments

Comments
 (0)