Skip to content
Closed
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
9 changes: 9 additions & 0 deletions packages/react-native/React/Base/RCTUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions packages/react-native/React/CoreModules/RCTDeviceInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ @interface RCTDeviceInfo () <NativeDeviceInfoSpec, RCTInitializing, RCTInvalidat
@end

@implementation RCTDeviceInfo {
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
UIInterfaceOrientation _currentInterfaceOrientation;
#endif
NSDictionary *_currentInterfaceDimensions;
BOOL _isFullscreen;
std::atomic<BOOL> _invalidated;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

using namespace facebook::react;

#if !TARGET_OS_TV
static UIInterfaceOrientationMask supportedOrientationsMask(ModalHostViewSupportedOrientationsMask mask)
{
UIInterfaceOrientationMask supportedOrientations = 0;
Expand Down Expand Up @@ -55,6 +56,7 @@ static UIInterfaceOrientationMask supportedOrientationsMask(ModalHostViewSupport

return supportedOrientations;
}
#endif

static std::tuple<BOOL, UIModalTransitionStyle> animationConfiguration(const ModalHostViewAnimationType animation)
{
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/Modules/RCTUIManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -360,7 +361,6 @@ - (void)didReceiveNewContentSizeMultiplier
};
}

#if TARGET_OS_IOS
- (void)namedOrientationDidChange
{
NSDictionary *orientationEvent = deviceOrientationEventBody([UIDevice currentDevice].orientation);
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/React/Views/RCTComponentData.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading