diff --git a/packages/react-native/React/Base/RCTUtils.mm b/packages/react-native/React/Base/RCTUtils.mm index e6f8aa1062bba2..8744d6fb798e1b 100644 --- a/packages/react-native/React/Base/RCTUtils.mm +++ b/packages/react-native/React/Base/RCTUtils.mm @@ -38,7 +38,9 @@ BOOL RCTIsHomeAssetURL(NSURL *__nullable imageURL); // Returns the current device's orientation +#if !TARGET_OS_TV UIDeviceOrientation RCTDeviceOrientation(void); +#endif // Whether the New Architecture is enabled or not BOOL RCTIsNewArchEnabled(void) @@ -381,10 +383,12 @@ CGFloat RCTFontSizeMultiplier(void) return mapping[RCTSharedApplication().preferredContentSizeCategory].floatValue; } +#if !TARGET_OS_TV UIDeviceOrientation RCTDeviceOrientation(void) { return [[UIDevice currentDevice] orientation]; } +#endif CGSize RCTScreenSize(void) { @@ -397,11 +401,16 @@ CGSize RCTScreenSize(void) }); }); +#if !TARGET_OS_TV if (UIDeviceOrientationIsLandscape(RCTDeviceOrientation())) { return CGSizeMake(portraitSize.height, portraitSize.width); } else { return CGSizeMake(portraitSize.width, portraitSize.height); } +#else + // tvOS doesn't have device orientation, always return landscape size + return CGSizeMake(portraitSize.height, portraitSize.width); +#endif } CGSize RCTViewportSize(void) diff --git a/packages/react-native/React/CoreModules/RCTDeviceInfo.mm b/packages/react-native/React/CoreModules/RCTDeviceInfo.mm index 8620af60246d48..c5946382d08f7c 100644 --- a/packages/react-native/React/CoreModules/RCTDeviceInfo.mm +++ b/packages/react-native/React/CoreModules/RCTDeviceInfo.mm @@ -25,7 +25,9 @@ @interface RCTDeviceInfo () _invalidated; @@ -103,10 +105,11 @@ - (void)initialize name:UIApplicationDidBecomeActiveNotification object:nil]; -#if TARGET_OS_IOS - +#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST _currentInterfaceOrientation = RCTKeyWindow().windowScene.interfaceOrientation; +#endif +#if TARGET_OS_IOS [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(interfaceFrameDidChange) name:UIDeviceOrientationDidChangeNotification diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm index bbba4cd45ee60e..c27f816e14e1bd 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm @@ -21,6 +21,7 @@ using namespace facebook::react; +#if !TARGET_OS_TV static UIInterfaceOrientationMask supportedOrientationsMask(ModalHostViewSupportedOrientationsMask mask) { UIInterfaceOrientationMask supportedOrientations = 0; @@ -55,6 +56,7 @@ static UIInterfaceOrientationMask supportedOrientationsMask(ModalHostViewSupport return supportedOrientations; } +#endif static std::tuple animationConfiguration(const ModalHostViewAnimationType animation) { @@ -77,9 +79,21 @@ static UIModalPresentationStyle presentationConfiguration(const ModalHostViewPro case ModalHostViewPresentationStyle::FullScreen: return UIModalPresentationFullScreen; case ModalHostViewPresentationStyle::PageSheet: +#if !TARGET_OS_TV return UIModalPresentationPageSheet; +#else + return UIModalPresentationFullScreen; +#endif case ModalHostViewPresentationStyle::FormSheet: +#if TARGET_OS_TV + if (@available(tvOS 26.0, *)) { + return UIModalPresentationFormSheet; + } else { + return UIModalPresentationFullScreen; + } +#else return UIModalPresentationFormSheet; +#endif case ModalHostViewPresentationStyle::OverFullScreen: return UIModalPresentationOverFullScreen; } diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index 9895b22dbfb288..a3947e808a3d8c 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -67,7 +67,9 @@ - (instancetype)initWithFrame:(CGRect)frame if (self = [super initWithFrame:frame]) { _props = ViewShadowNode::defaultSharedProps(); _reactSubviews = [NSMutableArray new]; +#if !TARGET_OS_TV self.multipleTouchEnabled = YES; +#endif _useCustomContainerView = NO; _removeClippedSubviews = NO; } diff --git a/packages/react-native/React/Modules/RCTUIManager.mm b/packages/react-native/React/Modules/RCTUIManager.mm index 689b63d077a39c..79d15605cafcf4 100644 --- a/packages/react-native/React/Modules/RCTUIManager.mm +++ b/packages/react-native/React/Modules/RCTUIManager.mm @@ -321,6 +321,7 @@ - (void)didReceiveNewContentSizeMultiplier }); } +#if TARGET_OS_IOS // Names and coordinate system from html5 spec: // https://developer.mozilla.org/en-US/docs/Web/API/Screen.orientation // https://developer.mozilla.org/en-US/docs/Web/API/Screen.lockOrientation @@ -360,7 +361,6 @@ - (void)didReceiveNewContentSizeMultiplier }; } -#if TARGET_OS_IOS - (void)namedOrientationDidChange { NSDictionary *orientationEvent = deviceOrientationEventBody([UIDevice currentDevice].orientation); diff --git a/packages/react-native/React/Views/RCTComponentData.mm b/packages/react-native/React/Views/RCTComponentData.mm index 36de415c2b4f44..64190118a881ea 100644 --- a/packages/react-native/React/Views/RCTComponentData.mm +++ b/packages/react-native/React/Views/RCTComponentData.mm @@ -88,7 +88,9 @@ - (UIView *)createViewWithTag:(nullable NSNumber *)tag rootTag:(nullable NSNumbe UIView *view = [self.manager view]; view.reactTag = tag; view.rootTag = rootTag; +#if !TARGET_OS_TV view.multipleTouchEnabled = YES; +#endif view.userInteractionEnabled = YES; // required for touch handling view.layer.allowsGroupOpacity = YES; // required for touch handling return view;