Skip to content

Commit

Permalink
feat: add visionOS template (#34)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
okwasniewski and szymonrybczak committed Dec 12, 2023
1 parent a2723fb commit 3dee764
Show file tree
Hide file tree
Showing 19 changed files with 1,165 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Header = (): Node => {
]}>
Welcome to
{'\n'}
React Native
React Native visionOS
</Text>
</ImageBackground>
);
Expand All @@ -56,7 +56,7 @@ const styles = StyleSheet.create({
},
logo: {
opacity: 0.2,
overflow: 'visible',
overflow: 'hidden',
resizeMode: 'cover',
/*
* These negative margins allow the image to be offset similarly across screen sizes and component sizes.
Expand All @@ -65,7 +65,6 @@ const styles = StyleSheet.create({
* source image's size.
*/
marginLeft: -128,
marginBottom: -192,
},
text: {
fontSize: 40,
Expand Down
65 changes: 20 additions & 45 deletions packages/react-native/template/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@

import React from 'react';
import type {PropsWithChildren} from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';
import {ScrollView, StyleSheet, Text, useColorScheme, View} from 'react-native';

import {
Colors,
Expand Down Expand Up @@ -56,43 +48,26 @@ function Section({children, title}: SectionProps): React.JSX.Element {
}

function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';

const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};

return (
<SafeAreaView style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
<ScrollView contentInsetAdjustmentBehavior="automatic">
<Header />
<View>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
</View>
</ScrollView>
);
}

Expand Down
1 change: 1 addition & 0 deletions packages/react-native/template/_gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ yarn-error.log

# Ruby / CocoaPods
/ios/Pods/
/visionos/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
Expand Down
11 changes: 10 additions & 1 deletion packages/react-native/template/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const {getPlatformResolver} = require('@callstack/out-of-tree-platforms');

/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('metro-config').MetroConfig}
*/
const config = {};


const config = {
resolver: {
resolveRequest: getPlatformResolver({
platformNameMap: {visionos: '@callstack/react-native-visionos'},
}),
},
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);
1 change: 1 addition & 0 deletions packages/react-native/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@react-native/eslint-config": "^0.74.0",
"@react-native/metro-config": "^0.74.0",
"@react-native/typescript-config": "^0.74.0",
"@callstack/out-of-tree-platforms": "^0.74.0",
"@types/react": "^18.2.6",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
Expand Down
Loading

0 comments on commit 3dee764

Please sign in to comment.