Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/react-native/React/Base/RCTConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ typedef NSURL RCTFileURL;
+ (UIKeyboardAppearance)UIKeyboardAppearance:(id)json;
+ (UIReturnKeyType)UIReturnKeyType:(id)json;
+ (UIUserInterfaceStyle)UIUserInterfaceStyle:(id)json API_AVAILABLE(ios(12));
#if !TARGET_OS_TV
+ (UIInterfaceOrientationMask)UIInterfaceOrientationMask:(NSString *)orientation;
#endif
+ (UIModalPresentationStyle)UIModalPresentationStyle:(id)json;

#if !TARGET_OS_TV
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/React/Base/RCTConvert.mm
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ + (UIKeyboardType)UIKeyboardType:(id)json RCT_DYNAMIC
UIUserInterfaceStyleUnspecified,
integerValue)

#if !TARGET_OS_TV
RCT_ENUM_CONVERTER(
UIInterfaceOrientationMask,
(@{
Expand All @@ -510,6 +511,7 @@ + (UIKeyboardType)UIKeyboardType:(id)json RCT_DYNAMIC
}),
NSNotFound,
unsignedIntegerValue)
#endif

RCT_ENUM_CONVERTER(
UIModalPresentationStyle,
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/React/Base/RCTUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ RCT_EXTERN UIWindow *__nullable RCTKeyWindow(void);
RCT_EXTERN UIViewController *__nullable RCTPresentedViewController(void);

// Retrieve current window UIStatusBarManager
#if !TARGET_OS_TV
RCT_EXTERN UIStatusBarManager *__nullable RCTUIStatusBarManager(void) API_AVAILABLE(ios(13));
#endif

// Does this device support force touch (aka 3D Touch)?
RCT_EXTERN BOOL RCTForceTouchAvailable(void);
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/React/Base/RCTUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,12 @@ BOOL RCTRunningInAppExtension(void)
return nil;
}

#if !TARGET_OS_TV
UIStatusBarManager *__nullable RCTUIStatusBarManager(void)
{
return RCTKeyWindow().windowScene.statusBarManager;
}
#endif

UIViewController *__nullable RCTPresentedViewController(void)
{
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/React/Views/RCTModalHostView.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ __attribute__((deprecated("This API will be removed along with the legacy archit

@property (nonatomic, weak) id<RCTModalHostViewInteractor> delegate;

#if !TARGET_OS_TV
@property (nonatomic, copy) NSArray<NSString *> *supportedOrientations;
@property (nonatomic, copy) RCTDirectEventBlock onOrientationChange;
#endif

// Fabric only
@property (nonatomic, copy) RCTDirectEventBlock onDismiss;
Expand Down
8 changes: 8 additions & 0 deletions packages/react-native/React/Views/RCTModalHostView.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ @implementation RCTModalHostView {
RCTModalHostViewController *_modalViewController;
RCTTouchHandler *_touchHandler;
UIView *_reactSubview;
#if !TARGET_OS_TV
UIInterfaceOrientation _lastKnownOrientation;
#endif
RCTDirectEventBlock _onRequestClose;
}

Expand Down Expand Up @@ -90,6 +92,7 @@ - (void)presentationControllerDidDismiss:(UIPresentationController *)presentatio

- (void)notifyForOrientationChange
{
#if !TARGET_OS_TV
if (!_onOrientationChange) {
return;
}
Expand All @@ -106,6 +109,7 @@ - (void)notifyForOrientationChange
@"orientation" : isPortrait ? @"portrait" : @"landscape",
};
_onOrientationChange(eventPayload);
#endif
}

- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex
Expand Down Expand Up @@ -191,7 +195,9 @@ - (void)ensurePresentedOnlyIfNeeded
if (shouldBePresented) {
RCTAssert(self.reactViewController, @"Can't present modal view controller without a presenting view controller");

#if !TARGET_OS_TV
_modalViewController.supportedInterfaceOrientations = [self supportedOrientationsMask];
#endif

if ([self.animationType isEqualToString:@"fade"]) {
_modalViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
Expand Down Expand Up @@ -224,6 +230,7 @@ - (void)setTransparent:(BOOL)transparent
transparent ? UIModalPresentationOverFullScreen : UIModalPresentationFullScreen;
}

#if !TARGET_OS_TV
- (UIInterfaceOrientationMask)supportedOrientationsMask
{
if (_supportedOrientations.count == 0) {
Expand All @@ -250,6 +257,7 @@ - (UIInterfaceOrientationMask)supportedOrientationsMask
}
return supportedOrientations;
}
#endif

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ __attribute__((deprecated("This API will be removed along with the legacy archit

@property (nonatomic, copy) void (^boundsDidChangeBlock)(CGRect newBounds);

#if !TARGET_OS_TV
@property (nonatomic, assign) UIInterfaceOrientationMask supportedInterfaceOrientations;
#endif

@end

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/React/Views/ScrollView/RCTScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ __attribute__((deprecated("This API will be removed along with the legacy archit
@property (nonatomic, assign) BOOL snapToEnd;
@property (nonatomic, copy) NSString *snapToAlignment;
@property (nonatomic, assign) BOOL inverted;
#if !TARGET_OS_TV
/** Focus area of newly-activated text input relative to the window to compare against UIKeyboardFrameBegin/End */
@property (nonatomic, assign) CGRect firstResponderFocus;
/** newly-activated text input outside of the scroll view */
@property (nonatomic, weak) UIView *firstResponderViewOutsideScrollView;
#endif

// NOTE: currently these event props are only declared so we can export the
// event names to JS - we don't call the blocks directly because scroll events
Expand Down
24 changes: 24 additions & 0 deletions packages/react-native/React/Views/ScrollView/RCTScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,22 @@ - (void)setCustomRefreshControl:(UIView<RCTCustomRefreshControlProtocol> *)refre
if ([_customRefreshControl respondsToSelector:@selector(setScrollView:)]) {
_customRefreshControl.scrollView = self;
}
#if !TARGET_OS_TV
if ([refreshControl isKindOfClass:UIRefreshControl.class]) {
self.refreshControl = (UIRefreshControl *)refreshControl;
} else {
#endif
[self addSubview:_customRefreshControl];
#if !TARGET_OS_TV
}
#endif
}

- (void)setPinchGestureEnabled:(BOOL)pinchGestureEnabled
{
#if !TARGET_OS_TV
self.pinchGestureRecognizer.enabled = pinchGestureEnabled;
#endif
_pinchGestureEnabled = pinchGestureEnabled;
}

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

- (BOOL)shouldGroupAccessibilityChildren
Expand Down Expand Up @@ -260,15 +268,19 @@ @implementation RCTScrollView {

- (void)_registerKeyboardListener
{
#if !TARGET_OS_TV
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_keyboardWillChangeFrame:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
#endif
}

- (void)_unregisterKeyboardListener
{
#if !TARGET_OS_TV
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
#endif
}

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

- (void)_keyboardWillChangeFrame:(NSNotification *)notification
{
#if !TARGET_OS_TV
if (![self automaticallyAdjustKeyboardInsets]) {
return;
}
Expand Down Expand Up @@ -358,6 +371,7 @@ - (void)_keyboardWillChangeFrame:(NSNotification *)notification
[self scrollToOffset:newContentOffset animated:NO];
}
completion:nil];
#endif
}

- (instancetype)initWithEventDispatcher:(id<RCTEventDispatcherProtocol>)eventDispatcher
Expand Down Expand Up @@ -428,7 +442,11 @@ - (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex
[super insertReactSubview:view atIndex:atIndex];
if ([view conformsToProtocol:@protocol(RCTCustomRefreshControlProtocol)]) {
[_scrollView setCustomRefreshControl:(UIView<RCTCustomRefreshControlProtocol> *)view];
#if !TARGET_OS_TV
if (![view isKindOfClass:[UIRefreshControl class]] && [view conformsToProtocol:@protocol(UIScrollViewDelegate)]) {
#else
if ([view conformsToProtocol:@protocol(UIScrollViewDelegate)]) {
#endif
[self addScrollListener:(UIView<UIScrollViewDelegate> *)view];
}
} else {
Expand All @@ -449,8 +467,12 @@ - (void)removeReactSubview:(UIView *)subview
[super removeReactSubview:subview];
if ([subview conformsToProtocol:@protocol(RCTCustomRefreshControlProtocol)]) {
[_scrollView setCustomRefreshControl:nil];
#if !TARGET_OS_TV
if (![subview isKindOfClass:[UIRefreshControl class]] &&
[subview conformsToProtocol:@protocol(UIScrollViewDelegate)]) {
#else
if ([subview conformsToProtocol:@protocol(UIScrollViewDelegate)]) {
#endif
[self removeScrollListener:(UIView<UIScrollViewDelegate> *)subview];
}
} else {
Expand Down Expand Up @@ -1083,8 +1105,10 @@ -(type)getter \
RCT_SET_AND_PRESERVE_OFFSET(setMaximumZoomScale, maximumZoomScale, CGFloat)
RCT_SET_AND_PRESERVE_OFFSET(setMinimumZoomScale, minimumZoomScale, CGFloat)
RCT_SET_AND_PRESERVE_OFFSET(setScrollEnabled, isScrollEnabled, BOOL)
#if !TARGET_OS_TV
RCT_SET_AND_PRESERVE_OFFSET(setPagingEnabled, isPagingEnabled, BOOL)
RCT_SET_AND_PRESERVE_OFFSET(setScrollsToTop, scrollsToTop, BOOL)
#endif
RCT_SET_AND_PRESERVE_OFFSET(setShowsHorizontalScrollIndicator, showsHorizontalScrollIndicator, BOOL)
RCT_SET_AND_PRESERVE_OFFSET(setShowsVerticalScrollIndicator, showsVerticalScrollIndicator, BOOL)
RCT_SET_AND_PRESERVE_OFFSET(setZoomScale, zoomScale, CGFloat);
Expand Down
Loading