Skip to content

Commit b474bd0

Browse files
committed
iOS: Introduce vision interfaceIdiom (facebook#42243)
Summary: This PR introduces the `vision` interfaceIdiom to check if the app runs on visionOS. An update to the documentation should follow this change. [IOS] [ADDED] - Introduce `vision` interfaceIdiom Pull Request resolved: facebook#42243 Test Plan: This change has been used in `react-native-visionos` and the interfaceIdiom changes **only** when running in the non-compatibility mode. But it's still useful to have this upstream if at some point React native would compile to visionOS natively Reviewed By: cortinico Differential Revision: D52730028 Pulled By: cipolleschi fbshipit-source-id: 711c5c2c6c7fe05b3ff8da7383b5e63e9e04acfa
1 parent f4b2ae5 commit b474bd0

File tree

5 files changed

+10734
-0
lines changed

5 files changed

+10734
-0
lines changed

packages/react-native/Libraries/Utilities/Platform.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ interface PlatformIOSStatic extends PlatformStatic {
5454
OS: 'ios';
5555
isPad: boolean;
5656
isTV: boolean;
57+
isVision: boolean;
58+
isMacCatalyst?: boolean | undefined;
5759
Version: string;
5860
}
5961

packages/react-native/Libraries/Utilities/Platform.flow.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ type IOSPlatform = {
4141
// $FlowFixMe[unsafe-getters-setters]
4242
get isTV(): boolean,
4343
// $FlowFixMe[unsafe-getters-setters]
44+
get isVision(): boolean,
45+
// $FlowFixMe[unsafe-getters-setters]
4446
get isTesting(): boolean,
4547
// $FlowFixMe[unsafe-getters-setters]
4648
get isDisableAnimations(): boolean,

packages/react-native/Libraries/Utilities/Platform.ios.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ const Platform: PlatformType = {
5757
return this.constants.interfaceIdiom === 'tv';
5858
},
5959
// $FlowFixMe[unsafe-getters-setters]
60+
get isVision(): boolean {
61+
// $FlowFixMe[object-this-reference]
62+
return this.constants.interfaceIdiom === 'vision';
63+
},
64+
// $FlowFixMe[unsafe-getters-setters]
6065
get isTesting(): boolean {
6166
if (__DEV__) {
6267
// $FlowFixMe[object-this-reference]

0 commit comments

Comments
 (0)