Skip to content

Commit df6ff9d

Browse files
feat: add visionOS template (#34)
* Update CLI to v12.1.1 * feat: implement visionos react-native template * feat: modify template look * feat: add `@callstack/out-of-tree-platforms` to metro config * fix: metro config * feat: update supported platforms --------- Co-authored-by: szymonrybczak <[email protected]>
1 parent 9046e32 commit df6ff9d

File tree

18 files changed

+1164
-50
lines changed

18 files changed

+1164
-50
lines changed

packages/react-native/Libraries/NewAppScreen/components/Header.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const Header = (): Node => {
4242
]}>
4343
Welcome to
4444
{'\n'}
45-
React Native
45+
React Native visionOS
4646
</Text>
4747
</ImageBackground>
4848
);
@@ -56,7 +56,7 @@ const styles = StyleSheet.create({
5656
},
5757
logo: {
5858
opacity: 0.2,
59-
overflow: 'visible',
59+
overflow: 'hidden',
6060
resizeMode: 'cover',
6161
/*
6262
* These negative margins allow the image to be offset similarly across screen sizes and component sizes.
@@ -65,7 +65,6 @@ const styles = StyleSheet.create({
6565
* source image's size.
6666
*/
6767
marginLeft: -128,
68-
marginBottom: -192,
6968
},
7069
text: {
7170
fontSize: 40,

packages/react-native/template/App.tsx

Lines changed: 20 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@
77

88
import React from 'react';
99
import type {PropsWithChildren} from 'react';
10-
import {
11-
SafeAreaView,
12-
ScrollView,
13-
StatusBar,
14-
StyleSheet,
15-
Text,
16-
useColorScheme,
17-
View,
18-
} from 'react-native';
10+
import {ScrollView, StyleSheet, Text, useColorScheme, View} from 'react-native';
1911

2012
import {
2113
Colors,
@@ -56,43 +48,26 @@ function Section({children, title}: SectionProps): React.JSX.Element {
5648
}
5749

5850
function App(): React.JSX.Element {
59-
const isDarkMode = useColorScheme() === 'dark';
60-
61-
const backgroundStyle = {
62-
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
63-
};
64-
6551
return (
66-
<SafeAreaView style={backgroundStyle}>
67-
<StatusBar
68-
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
69-
backgroundColor={backgroundStyle.backgroundColor}
70-
/>
71-
<ScrollView
72-
contentInsetAdjustmentBehavior="automatic"
73-
style={backgroundStyle}>
74-
<Header />
75-
<View
76-
style={{
77-
backgroundColor: isDarkMode ? Colors.black : Colors.white,
78-
}}>
79-
<Section title="Step One">
80-
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
81-
screen and then come back to see your edits.
82-
</Section>
83-
<Section title="See Your Changes">
84-
<ReloadInstructions />
85-
</Section>
86-
<Section title="Debug">
87-
<DebugInstructions />
88-
</Section>
89-
<Section title="Learn More">
90-
Read the docs to discover what to do next:
91-
</Section>
92-
<LearnMoreLinks />
93-
</View>
94-
</ScrollView>
95-
</SafeAreaView>
52+
<ScrollView contentInsetAdjustmentBehavior="automatic">
53+
<Header />
54+
<View>
55+
<Section title="Step One">
56+
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
57+
screen and then come back to see your edits.
58+
</Section>
59+
<Section title="See Your Changes">
60+
<ReloadInstructions />
61+
</Section>
62+
<Section title="Debug">
63+
<DebugInstructions />
64+
</Section>
65+
<Section title="Learn More">
66+
Read the docs to discover what to do next:
67+
</Section>
68+
<LearnMoreLinks />
69+
</View>
70+
</ScrollView>
9671
);
9772
}
9873

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
2+
const {getPlatformResolver} = require('@callstack/out-of-tree-platforms');
23

34
/**
45
* Metro configuration
56
* https://reactnative.dev/docs/metro
67
*
78
* @type {import('metro-config').MetroConfig}
89
*/
9-
const config = {};
10+
11+
12+
const config = {
13+
resolver: {
14+
resolveRequest: getPlatformResolver({
15+
platformNameMap: {visionos: '@callstack/react-native-visionos'},
16+
}),
17+
},
18+
};
1019

1120
module.exports = mergeConfig(getDefaultConfig(__dirname), config);

packages/react-native/template/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@react-native/eslint-config": "0.75.0-main",
2323
"@react-native/metro-config": "0.75.0-main",
2424
"@react-native/typescript-config": "0.75.0-main",
25+
"@callstack/out-of-tree-platforms": "0.75.0-main",
2526
"@types/react": "^18.2.6",
2627
"@types/react-test-renderer": "^18.0.0",
2728
"babel-jest": "^29.6.3",

0 commit comments

Comments
 (0)