Compile out orientation usage for AppleTV (#55128)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55128

UIOrientation usage is unsupported on AppleTV, compiling out.

Changelog: [internal]

Reviewed By: Abbondanzo

Differential Revision: D90513975

fbshipit-source-id: efc3a88c4519a9bf7bd50883e2c0218203d8c834
This commit is contained in:
Devan Buggay authored and meta-codesync[bot] committed 2026-01-13 16:09:38 -08:00
1 parent 8c058b4a4f
commit b94bf02bda
4 files changed
+29 -3

No files matched your search

@@ -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)
@@ -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<BOOL> _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
@@ -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<BOOL, UIModalTransitionStyle> 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;
}
@@ -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);