@react-native/new-app-screen 0.80.0-nightly-20250429-e486fda10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @react-native/new-app-screen
2
+
3
+ ![npm package](https://img.shields.io/npm/v/@react-native/new-app-screen?color=brightgreen&label=npm%20package)
4
+
5
+ `NewAppScreen` component for React Native.
6
+
7
+ ## Usage
8
+
9
+ ```js
10
+ import { NewAppScreen } from '@react-native/new-app-screen';
11
+
12
+ function MyAppOrTemplate() {
13
+ ...
14
+
15
+ return <NewAppScreen />;
16
+ }
17
+ ```
18
+
19
+ ## Contributing
20
+
21
+ Changes to this package can be made locally and tested against the `rn-tester` app, per the [Contributing guide](https://reactnative.dev/contributing/overview#contributing-code).
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@react-native/new-app-screen",
3
+ "version": "0.80.0-nightly-20250429-e486fda10",
4
+ "description": "NewAppScreen component for React Native",
5
+ "keywords": [
6
+ "react-native"
7
+ ],
8
+ "homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/new-app-screen#readme",
9
+ "bugs": "https://github.com/facebook/react-native/issues",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/facebook/react-native.git",
13
+ "directory": "packages/new-app-screen"
14
+ },
15
+ "license": "MIT",
16
+ "main": "./src/index.js",
17
+ "exports": "./src/index.js",
18
+ "files": [
19
+ "src"
20
+ ],
21
+ "dependencies": {},
22
+ "peerDependencies": {
23
+ "@types/react": "^19.0.0",
24
+ "react": "*",
25
+ "react-native": "*"
26
+ },
27
+ "peerDependenciesMeta": {
28
+ "@types/react": {
29
+ "optional": true
30
+ }
31
+ },
32
+ "engines": {
33
+ "node": ">=18"
34
+ }
35
+ }
package/src/Links.js ADDED
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ const Links: Array<{
12
+ title: string,
13
+ description: string,
14
+ url: string,
15
+ }> = [
16
+ {
17
+ title: 'Hello World',
18
+ description: 'Learn the basics',
19
+ url: 'https://reactnative.dev/docs/tutorial',
20
+ },
21
+ {
22
+ title: 'Fast Refresh',
23
+ description: 'See edits instantly',
24
+ url: 'https://reactnative.dev/docs/fast-refresh',
25
+ },
26
+ {
27
+ title: 'DevTools',
28
+ description: 'View logs & debug your app',
29
+ url: 'https://reactnative.dev/docs/debugging',
30
+ },
31
+ {
32
+ title: 'Components',
33
+ description: 'View components and APIs',
34
+ url: 'https://reactnative.dev/docs/components-and-apis',
35
+ },
36
+ {
37
+ title: 'Style',
38
+ description: 'Use the style prop',
39
+ url: 'https://reactnative.dev/docs/style',
40
+ },
41
+ {
42
+ title: 'Layout',
43
+ description: 'Flexbox & layout techniques',
44
+ url: 'https://reactnative.dev/docs/flexbox',
45
+ },
46
+ {
47
+ title: 'Navigation',
48
+ description: 'Move between screens',
49
+ url: 'https://reactnative.dev/docs/navigation',
50
+ },
51
+ {
52
+ title: 'Networking',
53
+ description: 'Use the Fetch API',
54
+ url: 'https://reactnative.dev/docs/navigation',
55
+ },
56
+ {
57
+ title: 'Showcase',
58
+ description: 'Featured React Native apps',
59
+ url: 'https://reactnative.dev/showcase',
60
+ },
61
+ {
62
+ title: 'Blog',
63
+ description: 'Latest news & updates',
64
+ url: 'https://reactnative.dev/blog',
65
+ },
66
+ {
67
+ title: 'Community',
68
+ description: 'Expore & get help',
69
+ url: 'https://reactnative.dev/community/overview',
70
+ },
71
+ {
72
+ title: 'Follow @reactnative',
73
+ description: 'Stay in touch on X',
74
+ url: 'https://x.com/reactnative',
75
+ },
76
+ ];
77
+
78
+ export default Links;
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ import Links from './Links';
12
+ import {ThemedText, useTheme} from './Theme';
13
+ import * as React from 'react';
14
+ import {
15
+ Image,
16
+ SafeAreaView,
17
+ ScrollView,
18
+ StyleSheet,
19
+ Text,
20
+ TouchableHighlight,
21
+ View,
22
+ useColorScheme,
23
+ useWindowDimensions,
24
+ } from 'react-native';
25
+ import openURLInBrowser from 'react-native/Libraries/Core/Devtools/openURLInBrowser';
26
+ import {version as ReactNativeVersion} from 'react-native/Libraries/Core/ReactNativeVersion';
27
+
28
+ export type NewAppScreenProps = $ReadOnly<{
29
+ templateFileName?: string,
30
+ }>;
31
+
32
+ export default function NewAppScreen({
33
+ templateFileName = 'App.tsx',
34
+ }: NewAppScreenProps): React.Node {
35
+ const {colors} = useTheme();
36
+ const isDarkMode = useColorScheme() === 'dark';
37
+ const isLargeScreen = useWindowDimensions().width > 600;
38
+
39
+ return (
40
+ <SafeAreaView style={{backgroundColor: colors.background}}>
41
+ <ScrollView>
42
+ <View style={styles.container}>
43
+ <View style={styles.header}>
44
+ <Image
45
+ style={styles.logo}
46
+ source={
47
+ isDarkMode
48
+ ? require('./assets/react-dark.png')
49
+ : require('./assets/react-light.png')
50
+ }
51
+ />
52
+ <ThemedText style={styles.title}>
53
+ Welcome to React Native
54
+ </ThemedText>
55
+ {getVersionLabel()}
56
+ {getHermesLabel()}
57
+ <ThemedText
58
+ style={[
59
+ styles.callout,
60
+ {backgroundColor: colors.backgroundHighlight},
61
+ ]}>
62
+ 💡&ensp;Open{' '}
63
+ <Text style={styles.calloutEmphasis}>{templateFileName}</Text> to
64
+ get started
65
+ </ThemedText>
66
+ </View>
67
+ <View style={styles.linksContainer}>
68
+ <ThemedText style={styles.linksTitle}>Learn & Explore</ThemedText>
69
+ {Links.map(({title, description, url}, i) => (
70
+ <TouchableHighlight
71
+ key={i}
72
+ activeOpacity={0.6}
73
+ underlayColor={colors.background}
74
+ onPress={() => openURLInBrowser(url)}
75
+ style={[
76
+ styles.link,
77
+ // eslint-disable-next-line react-native/no-inline-styles
78
+ {
79
+ maxWidth: isLargeScreen ? 240 : 360,
80
+ borderColor: colors.cardOutline,
81
+ backgroundColor: colors.cardBackground,
82
+ },
83
+ ]}>
84
+ <View>
85
+ <ThemedText style={styles.linkText}>{title}</ThemedText>
86
+ <ThemedText style={{color: colors.textSecondary}}>
87
+ {description}
88
+ </ThemedText>
89
+ </View>
90
+ </TouchableHighlight>
91
+ ))}
92
+ </View>
93
+ </View>
94
+ </ScrollView>
95
+ </SafeAreaView>
96
+ );
97
+ }
98
+
99
+ function getVersionLabel(): React.Node {
100
+ const version =
101
+ [
102
+ ReactNativeVersion.major,
103
+ ReactNativeVersion.minor,
104
+ ReactNativeVersion.patch,
105
+ ].join('.') +
106
+ (ReactNativeVersion.prerelease != null
107
+ ? '-' + ReactNativeVersion.prerelease
108
+ : '');
109
+
110
+ return (
111
+ <ThemedText color="secondary" style={styles.label}>
112
+ Version: {version}
113
+ </ThemedText>
114
+ );
115
+ }
116
+
117
+ function getHermesLabel(): React.Node {
118
+ if (global.HermesInternal == null) {
119
+ return null;
120
+ }
121
+
122
+ return (
123
+ <ThemedText color="secondary" style={styles.label}>
124
+ JS Engine: Hermes
125
+ </ThemedText>
126
+ );
127
+ }
128
+
129
+ const styles = StyleSheet.create({
130
+ container: {
131
+ flexGrow: 1,
132
+ alignItems: 'center',
133
+ paddingHorizontal: 24,
134
+ },
135
+ header: {
136
+ width: '100%',
137
+ alignItems: 'center',
138
+ marginTop: 64,
139
+ marginBottom: 48,
140
+ },
141
+ logo: {
142
+ height: 80,
143
+ aspectRatio: 1,
144
+ marginBottom: 24,
145
+ },
146
+ title: {
147
+ fontSize: 24,
148
+ fontWeight: '600',
149
+ marginBottom: 24,
150
+ },
151
+ label: {
152
+ fontSize: 14,
153
+ marginBottom: 8,
154
+ },
155
+ callout: {
156
+ width: '100%',
157
+ maxWidth: 320,
158
+ marginTop: 36,
159
+ paddingVertical: 16,
160
+ paddingHorizontal: 20,
161
+ paddingLeft: 16,
162
+ borderRadius: 12,
163
+ fontSize: 16,
164
+ textAlign: 'center',
165
+ },
166
+ calloutEmphasis: {
167
+ fontWeight: 'bold',
168
+ },
169
+ linksContainer: {
170
+ flex: 1,
171
+ flexWrap: 'wrap',
172
+ flexDirection: 'row',
173
+ justifyContent: 'center',
174
+ columnGap: 12,
175
+ rowGap: 12,
176
+ maxWidth: 800,
177
+ marginBottom: 48,
178
+ },
179
+ linksTitle: {
180
+ width: '100%',
181
+ fontSize: 18,
182
+ fontWeight: '600',
183
+ textAlign: 'center',
184
+ marginBottom: 20,
185
+ },
186
+ link: {
187
+ width: '100%',
188
+ paddingVertical: 20,
189
+ paddingHorizontal: 24,
190
+ borderRadius: 12,
191
+ borderWidth: 1,
192
+ boxShadow: '0 4px 8px rgba(0, 0, 0, .03)',
193
+ },
194
+ linkText: {
195
+ marginBottom: 4,
196
+ fontSize: 16,
197
+ fontWeight: '600',
198
+ },
199
+ });
package/src/Theme.js ADDED
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ import type {TextProps} from 'react-native';
12
+
13
+ import * as React from 'react';
14
+ import {Text, useColorScheme} from 'react-native';
15
+
16
+ const COLORS = {
17
+ light: {
18
+ background: '#f3f3f3',
19
+ backgroundHighlight: '#cfe6ee',
20
+ cardBackground: '#fff',
21
+ cardOutline: '#dae1e7',
22
+ textPrimary: '#000',
23
+ textSecondary: '#404756',
24
+ },
25
+ dark: {
26
+ background: '#000',
27
+ backgroundHighlight: '#193c47',
28
+ cardBackground: '#222',
29
+ cardOutline: '#444',
30
+ textPrimary: '#fff',
31
+ textSecondary: '#c0c1c4',
32
+ },
33
+ };
34
+
35
+ type Theme = {
36
+ colors: {
37
+ background: string,
38
+ backgroundHighlight: string,
39
+ cardBackground: string,
40
+ cardOutline: string,
41
+ textPrimary: string,
42
+ textSecondary: string,
43
+ },
44
+ };
45
+
46
+ export function useTheme(): Theme {
47
+ const colorScheme = useColorScheme();
48
+
49
+ return {
50
+ colors: COLORS[colorScheme === 'dark' ? 'dark' : 'light'],
51
+ };
52
+ }
53
+
54
+ export function ThemedText({
55
+ color,
56
+ style,
57
+ ...props
58
+ }: {
59
+ ...TextProps,
60
+ color?: 'primary' | 'secondary',
61
+ }): React.Node {
62
+ const {colors} = useTheme();
63
+
64
+ return (
65
+ <Text
66
+ style={[
67
+ {
68
+ color:
69
+ color === 'secondary' ? colors.textSecondary : colors.textPrimary,
70
+ },
71
+ style,
72
+ ]}
73
+ {...props}
74
+ />
75
+ );
76
+ }
Binary file
Binary file
package/src/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ */
9
+
10
+ import type * as React from 'react';
11
+
12
+ export type NewAppScreenProps = Readonly<{
13
+ templateFileName?: string | undefined;
14
+ }>;
15
+
16
+ export function NewAppScreen(props: NewAppScreenProps): React.ReactNode;
package/src/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ import NewAppScreen from './NewAppScreen';
12
+
13
+ export {NewAppScreen};