Skip to content

Commit 0d33279

Browse files
committed
fix: add missing ifdefs, sync with upstream
1 parent e51f66d commit 0d33279

File tree

7 files changed

+556
-933
lines changed

7 files changed

+556
-933
lines changed

packages/out-of-tree-platforms/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@callstack/out-of-tree-platforms",
3-
"version": "0.76.0-main",
3+
"version": "0.75.0-rc.6",
44
"description": "Utils for React Native out of tree platforms.",
55
"keywords": ["out-of-tree", "react-native"],
66
"homepage": "https://github.com/callstack/react-native-visionos/tree/HEAD/packages/out-of-tree-platforms#readme",

packages/react-native/React/CoreModules/RCTDeviceInfo.mm

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ - (void)initialize
5151
selector:@selector(didReceiveNewContentSizeMultiplier)
5252
name:RCTAccessibilityManagerDidUpdateMultiplierNotification
5353
object:[_moduleRegistry moduleForName:"AccessibilityManager"]];
54-
55-
56-
_currentInterfaceOrientation = [RCTSharedApplication() statusBarOrientation];
5754

5855
_currentInterfaceDimensions = [self _exportedDimensions];
5956

@@ -71,10 +68,16 @@ - (void)initialize
7168
selector:@selector(interfaceFrameDidChange)
7269
name:RCTWindowFrameDidChangeNotification
7370
object:nil];
71+
72+
#if TARGET_OS_IOS
73+
74+
_currentInterfaceOrientation = RCTKeyWindow().windowScene.interfaceOrientation;
75+
7476
[[NSNotificationCenter defaultCenter] addObserver:self
7577
selector:@selector(interfaceFrameDidChange)
7678
name:UIDeviceOrientationDidChangeNotification
7779
object:nil];
80+
#endif
7881

7982
// TODO T175901725 - Registering the RCTDeviceInfo module to the notification is a short-term fix to unblock 0.73
8083
// The actual behavior should be that the module is properly registered in the TurboModule/Bridge infrastructure
@@ -101,12 +104,7 @@ - (void)_cleanupObservers
101104
[[NSNotificationCenter defaultCenter] removeObserver:self
102105
name:RCTAccessibilityManagerDidUpdateMultiplierNotification
103106
object:[_moduleRegistry moduleForName:"AccessibilityManager"]];
104-
#if !TARGET_OS_VISION
105-
[[NSNotificationCenter defaultCenter] removeObserver:self
106-
name:UIApplicationDidChangeStatusBarOrientationNotification
107-
object:nil];
108-
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
109-
#endif
107+
110108
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
111109

112110
[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTUserInterfaceStyleDidChangeNotification object:nil];
@@ -115,26 +113,25 @@ - (void)_cleanupObservers
115113

116114
[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTBridgeWillInvalidateModulesNotification object:nil];
117115

116+
#if TARGET_OS_IOS
118117
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
118+
#endif
119119
}
120120

121121
static BOOL RCTIsIPhoneNotched()
122122
{
123123
static BOOL isIPhoneNotched = NO;
124-
#if !TARGET_OS_VISION
125-
static dispatch_once_t onceToken;
124+
static dispatch_once_t onceToken;
126125

126+
#if TARGET_OS_IOS
127127
dispatch_once(&onceToken, ^{
128128
RCTAssertMainQueue();
129129

130130
// 20pt is the top safeArea value in non-notched devices
131131
isIPhoneNotched = RCTSharedApplication().keyWindow.safeAreaInsets.top > 20;
132132
});
133-
134-
// 20pt is the top safeArea value in non-notched devices
135-
isIPhoneNotched = RCTSharedApplication().keyWindow.safeAreaInsets.top > 20;
136-
});
137133
#endif
134+
138135
return isIPhoneNotched;
139136
}
140137

@@ -217,8 +214,9 @@ - (void)interfaceOrientationDidChange
217214

218215
- (void)_interfaceOrientationDidChange
219216
{
217+
#if TARGET_OS_IOS
220218
UIApplication *application = RCTSharedApplication();
221-
UIInterfaceOrientation nextOrientation = [application statusBarOrientation];
219+
UIInterfaceOrientation nextOrientation = RCTKeyWindow().windowScene.interfaceOrientation;
222220

223221
BOOL isRunningInFullScreen =
224222
CGRectEqualToRect(application.delegate.window.frame, application.delegate.window.screen.bounds);
@@ -246,6 +244,7 @@ - (void)_interfaceOrientationDidChange
246244
_isFullscreen = isRunningInFullScreen;
247245
#pragma clang diagnostic pop
248246
}
247+
#endif
249248
}
250249

251250
- (void)interfaceFrameDidChange

packages/react-native/React/CoreModules/RCTPerfMonitor.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,14 @@ - (UIPanGestureRecognizer *)gestureRecognizer
170170

171171
- (UIView *)container
172172
{
173+
173174
if (!_container) {
175+
#if TARGET_OS_IOS
174176
CGSize statusBarSize = RCTSharedApplication().statusBarFrame.size;
175177
CGFloat statusBarHeight = statusBarSize.height;
178+
#else
179+
CGFloat statusBarHeight = 0;
180+
#endif
176181
_container = [[UIView alloc] initWithFrame:CGRectMake(10, statusBarHeight, 180, RCTPerfMonitorBarHeight)];
177182
_container.layer.borderWidth = 2;
178183
_container.layer.borderColor = [UIColor lightGrayColor].CGColor;
@@ -185,6 +190,7 @@ - (UIView *)container
185190
}
186191

187192
return _container;
193+
188194
}
189195

190196
- (UILabel *)memory

packages/react-native/React/Views/RCTModalHostView.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ - (void)presentationControllerDidAttemptToDismiss:(UIPresentationController *)co
7272

7373
- (void)notifyForOrientationChange
7474
{
75+
#if TARGET_OS_IOS
7576
if (!_onOrientationChange) {
7677
return;
7778
}
@@ -88,6 +89,7 @@ - (void)notifyForOrientationChange
8889
@"orientation" : isPortrait ? @"portrait" : @"landscape",
8990
};
9091
_onOrientationChange(eventPayload);
92+
#endif
9193
}
9294

9395
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex

packages/react-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@callstack/react-native-visionos",
3-
"version": "1000.0.0",
3+
"version": "0.75.0-rc.6",
44
"description": "React Native for visionOS",
55
"license": "MIT",
66
"repository": {

0 commit comments

Comments
 (0)