Skip to content

Commit 9d9eb0f

Browse files
feat: add visionOS template (#34)
* Update CLI to v12.1.1 # Conflicts: # packages/community-cli-plugin/package.json # packages/react-native/cli.js # packages/react-native/package.json * 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 b239899 commit 9d9eb0f

File tree

23 files changed

+1246
-130
lines changed

23 files changed

+1246
-130
lines changed

packages/community-cli-plugin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
],
2424
"dependencies": {
2525
"@react-native/dev-middleware": "^0.74.0",
26-
"@react-native-community/cli-server-api": "12.0.0",
27-
"@react-native-community/cli-tools": "12.0.0",
26+
"@react-native-community/cli-server-api": "12.1.1",
27+
"@react-native-community/cli-tools": "12.1.1",
2828
"@react-native/metro-babel-transformer": "^0.74.0",
2929
"chalk": "^4.0.0",
3030
"execa": "^5.1.1",

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/cli.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010

1111
'use strict';
1212

13-
const {version: currentVersion} = require('./package.json');
14-
const cli = require('@react-native-community/cli');
15-
const chalk = require('chalk');
1613
const {get} = require('https');
1714
const {URL} = require('url');
15+
const chalk = require('chalk');
16+
const cli = require('@react-native-community/cli');
17+
18+
const {version: currentVersion, name} = require('./package.json');
1819

1920
const isNpxRuntime = process.env.npm_lifecycle_event === 'npx';
2021
const DEFAULT_REGISTRY_HOST =
@@ -40,7 +41,7 @@ async function getLatestVersion(registryHost = DEFAULT_REGISTRY_HOST) {
4041
}
4142

4243
/**
43-
* npx react-native -> @react-native-community/cli
44+
* npx react-native -> @react-native-comminity/cli
4445
*
4546
* Will perform a version check and warning if you're not running the latest community cli when executed using npx. If
4647
* you know what you're doing, you can skip this check:
@@ -66,7 +67,7 @@ async function main() {
6667
// Ignore errors, since it's a nice to have warning
6768
}
6869
}
69-
return cli.run();
70+
return cli.run(name);
7071
}
7172

7273
if (require.main === module) {

packages/react-native/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@
9494
},
9595
"dependencies": {
9696
"@jest/create-cache-key-function": "^29.6.3",
97-
"@react-native-community/cli": "12.0.0",
98-
"@react-native-community/cli-platform-android": "12.0.0",
99-
"@react-native-community/cli-platform-ios": "12.0.0",
97+
"@react-native-community/cli": "12.1.1",
98+
"@react-native-community/cli-platform-android": "12.1.1",
99+
"@react-native-community/cli-platform-ios": "12.1.1",
100100
"@react-native/assets-registry": "^0.74.0",
101101
"@react-native/community-cli-plugin": "^0.74.0",
102102
"@react-native/codegen": "^0.74.0",

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

packages/react-native/template/_gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ yarn-error.log
5757

5858
# Ruby / CocoaPods
5959
/ios/Pods/
60+
/visionos/Pods/
6061
/vendor/bundle/
6162

6263
# Temporary files created by Metro to check the health of the file watcher
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://facebook.github.io/metro/docs/configuration
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.74.0",
2323
"@react-native/metro-config": "^0.74.0",
2424
"@react-native/typescript-config": "^0.74.0",
25+
"@callstack/out-of-tree-platforms": "^0.74.0",
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)