diff --git a/packages/react-native/React/Base/RCTUtils.mm b/packages/react-native/React/Base/RCTUtils.mm index e6f8aa1062b..8744d6fb798 100644 --- a/packages/react-native/React/Base/RCTUtils.mm +++ b/packages/react-native/React/Base/RCTUtils.mm @@ -38,7 +38,9 @@ NSString *__nullable RCTHomePathForURL(NSURL *__nullable URL); 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 8620af60246..c5946382d08 100644 --- a/packages/react-native/React/CoreModules/RCTDeviceInfo.mm +++ b/packages/react-native/React/CoreModules/RCTDeviceInfo.mm @@ -25,7 +25,9 @@ using namespace facebook::react; @end @implementation RCTDeviceInfo { +#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST UIInterfaceOrientation _currentInterfaceOrientation; +#endif NSDictionary *_currentInterfaceDimensions; BOOL _isFullscreen; std::atomic _invalidated; @@ -103,10 +105,11 @@ RCT_EXPORT_MODULE() 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 bbba4cd45ee..c27f816e14e 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/Modules/RCTUIManager.mm b/packages/react-native/React/Modules/RCTUIManager.mm index 689b63d077a..79d15605caf 100644 --- a/packages/react-native/React/Modules/RCTUIManager.mm +++ b/packages/react-native/React/Modules/RCTUIManager.mm @@ -321,6 +321,7 @@ RCT_EXPORT_MODULE() }); } +#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 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation) }; } -#if TARGET_OS_IOS - (void)namedOrientationDidChange { NSDictionary *orientationEvent = deviceOrientationEventBody([UIDevice currentDevice].orientation);