create-expo-stack 2.6.5 → 2.7.0-next.0c1b767
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 +23 -9
- package/build/templates/base/App.tsx.ejs +3 -0
- package/build/templates/base/babel.config.js.ejs +1 -1
- package/build/templates/base/package.json.ejs +15 -3
- package/build/templates/base/prettier.config.js.ejs +1 -1
- package/build/templates/base/tsconfig.json.ejs +10 -6
- package/build/templates/packages/expo-router/drawer/app/_layout.tsx.ejs +4 -1
- package/build/templates/packages/expo-router/stack/app/_layout.tsx.ejs +4 -1
- package/build/templates/packages/expo-router/tabs/app/_layout.tsx.ejs +4 -1
- package/build/templates/packages/nativewindui/app/+not-found.tsx.ejs +18 -0
- package/build/templates/packages/nativewindui/app/_layout.tsx.ejs +85 -0
- package/build/templates/packages/nativewindui/app/bottom-tabs/_layout.tsx.ejs +34 -0
- package/build/templates/packages/nativewindui/app/bottom-tabs/index.tsx.ejs +11 -0
- package/build/templates/packages/nativewindui/app/bottom-tabs/profile.tsx.ejs +11 -0
- package/build/templates/packages/nativewindui/app/drawer/_layout.tsx.ejs +29 -0
- package/build/templates/packages/nativewindui/app/drawer/index.tsx.ejs +11 -0
- package/build/templates/packages/nativewindui/app/index.tsx.ejs +99 -0
- package/build/templates/packages/nativewindui/app/modal.tsx.ejs +32 -0
- package/build/templates/packages/nativewindui/app/top-tabs/_layout.tsx.ejs +71 -0
- package/build/templates/packages/nativewindui/app/top-tabs/following.tsx.ejs +13 -0
- package/build/templates/packages/nativewindui/app/top-tabs/index.tsx.ejs +13 -0
- package/build/templates/packages/nativewindui/app/top-tabs/my-group.tsx.ejs +13 -0
- package/build/templates/packages/nativewindui/components/ThemeToggle.tsx.ejs +39 -0
- package/build/templates/packages/nativewindui/components/nativewind-ui/Text.tsx.ejs +55 -0
- package/build/templates/packages/nativewindui/expo-env.d.ts.ejs +3 -0
- package/build/templates/packages/nativewindui/global.css.ejs +91 -0
- package/build/templates/packages/nativewindui/lib/cn.ts.ejs +6 -0
- package/build/templates/packages/nativewindui/lib/useColorScheme.tsx.ejs +14 -0
- package/build/templates/packages/nativewindui/lib/useHeaderSearchBar.tsx.ejs +31 -0
- package/build/templates/packages/nativewindui/metro.config.js.ejs +10 -0
- package/build/templates/packages/nativewindui/nativewind-env.d.ts.ejs +1 -0
- package/build/templates/packages/nativewindui/tailwind.config.js.ejs +66 -0
- package/build/templates/packages/nativewindui/theme/colors.ts.ejs +71 -0
- package/build/templates/packages/nativewindui/theme/index.ts.ejs +29 -0
- package/build/templates/packages/react-navigation/App.tsx.ejs +4 -1
- package/build/types/types.d.ts +2 -2
- package/build/types.js +2 -1
- package/build/utilities/configureProjectFiles.js +238 -200
- package/build/utilities/generateProjectFiles.js +18 -13
- package/build/utilities/printOutput.js +5 -5
- package/build/utilities/runCLI.js +45 -22
- package/package.json +67 -67
package/README.md
CHANGED
|
@@ -164,21 +164,28 @@ Thanks go to these wonderful people:
|
|
|
164
164
|
<sub><b>Simon Grimm</b></sub>
|
|
165
165
|
</a>
|
|
166
166
|
</td>
|
|
167
|
+
<td align="center">
|
|
168
|
+
<a href="https://github.com/mrzachnugent">
|
|
169
|
+
<img src="https://avatars.githubusercontent.com/u/63797719?v=4" width="100;" alt="mrzachnugent"/>
|
|
170
|
+
<br />
|
|
171
|
+
<sub><b>Zach Nugent</b></sub>
|
|
172
|
+
</a>
|
|
173
|
+
</td>
|
|
167
174
|
<td align="center">
|
|
168
175
|
<a href="https://github.com/dannyhw">
|
|
169
176
|
<img src="https://avatars.githubusercontent.com/u/3481514?v=4" width="100;" alt="dannyhw"/>
|
|
170
177
|
<br />
|
|
171
178
|
<sub><b>Daniel Williams</b></sub>
|
|
172
179
|
</a>
|
|
173
|
-
</td>
|
|
180
|
+
</td></tr>
|
|
181
|
+
<tr>
|
|
174
182
|
<td align="center">
|
|
175
183
|
<a href="https://github.com/todevmilen">
|
|
176
184
|
<img src="https://avatars.githubusercontent.com/u/78319110?v=4" width="100;" alt="todevmilen"/>
|
|
177
185
|
<br />
|
|
178
186
|
<sub><b>Milen Todev</b></sub>
|
|
179
187
|
</a>
|
|
180
|
-
</td
|
|
181
|
-
<tr>
|
|
188
|
+
</td>
|
|
182
189
|
<td align="center">
|
|
183
190
|
<a href="https://github.com/alitnk">
|
|
184
191
|
<img src="https://avatars.githubusercontent.com/u/35243344?v=4" width="100;" alt="alitnk"/>
|
|
@@ -213,15 +220,15 @@ Thanks go to these wonderful people:
|
|
|
213
220
|
<br />
|
|
214
221
|
<sub><b>Andrew Levy</b></sub>
|
|
215
222
|
</a>
|
|
216
|
-
</td>
|
|
223
|
+
</td></tr>
|
|
224
|
+
<tr>
|
|
217
225
|
<td align="center">
|
|
218
226
|
<a href="https://github.com/gialencar">
|
|
219
227
|
<img src="https://avatars.githubusercontent.com/u/11895696?v=4" width="100;" alt="gialencar"/>
|
|
220
228
|
<br />
|
|
221
229
|
<sub><b>Gilson Alencar</b></sub>
|
|
222
230
|
</a>
|
|
223
|
-
</td
|
|
224
|
-
<tr>
|
|
231
|
+
</td>
|
|
225
232
|
<td align="center">
|
|
226
233
|
<a href="https://github.com/mwarger">
|
|
227
234
|
<img src="https://avatars.githubusercontent.com/u/686823?v=4" width="100;" alt="mwarger"/>
|
|
@@ -256,15 +263,15 @@ Thanks go to these wonderful people:
|
|
|
256
263
|
<br />
|
|
257
264
|
<sub><b>Joar Karlsson</b></sub>
|
|
258
265
|
</a>
|
|
259
|
-
</td>
|
|
266
|
+
</td></tr>
|
|
267
|
+
<tr>
|
|
260
268
|
<td align="center">
|
|
261
269
|
<a href="https://github.com/Joehoel">
|
|
262
270
|
<img src="https://avatars.githubusercontent.com/u/31251240?v=4" width="100;" alt="Joehoel"/>
|
|
263
271
|
<br />
|
|
264
272
|
<sub><b>Joël Kuijper</b></sub>
|
|
265
273
|
</a>
|
|
266
|
-
</td
|
|
267
|
-
<tr>
|
|
274
|
+
</td>
|
|
268
275
|
<td align="center">
|
|
269
276
|
<a href="https://github.com/asapMaki">
|
|
270
277
|
<img src="https://avatars.githubusercontent.com/u/30200380?v=4" width="100;" alt="asapMaki"/>
|
|
@@ -279,6 +286,13 @@ Thanks go to these wonderful people:
|
|
|
279
286
|
<sub><b>Sean Boult</b></sub>
|
|
280
287
|
</a>
|
|
281
288
|
</td>
|
|
289
|
+
<td align="center">
|
|
290
|
+
<a href="https://github.com/YounessHassoune">
|
|
291
|
+
<img src="https://avatars.githubusercontent.com/u/36106440?v=4" width="100;" alt="YounessHassoune"/>
|
|
292
|
+
<br />
|
|
293
|
+
<sub><b>YOUNESS HASSOUNE</b></sub>
|
|
294
|
+
</a>
|
|
295
|
+
</td>
|
|
282
296
|
<td align="center">
|
|
283
297
|
<a href="https://github.com/bautistaaa">
|
|
284
298
|
<img src="https://avatars.githubusercontent.com/u/3660667?v=4" width="100;" alt="bautistaaa"/>
|
|
@@ -8,6 +8,9 @@ import { StatusBar } from 'expo-status-bar';
|
|
|
8
8
|
|
|
9
9
|
<% if (props.stylingPackage?.name === "nativewind") { %>
|
|
10
10
|
import './global.css';
|
|
11
|
+
<% } else if (props.stylingPackage?.name === "nativewinui") { %>
|
|
12
|
+
import './global.css';
|
|
13
|
+
import 'expo-dev-client';
|
|
11
14
|
<% } else if (props.stylingPackage?.name === "restyle") { %>
|
|
12
15
|
import { ThemeProvider } from '@shopify/restyle';
|
|
13
16
|
import { theme } from 'theme';
|
|
@@ -17,7 +17,7 @@ module.exports = function(api) {
|
|
|
17
17
|
<% } %>
|
|
18
18
|
|
|
19
19
|
return {
|
|
20
|
-
<% if (props.stylingPackage?.name === "nativewind") { %>
|
|
20
|
+
<% if (props.stylingPackage?.name === "nativewind" || props.stylingPackage?.name === "nativewindui") { %>
|
|
21
21
|
presets: [
|
|
22
22
|
['babel-preset-expo', { jsxImportSource: 'nativewind' }],
|
|
23
23
|
'nativewind/babel',
|
|
@@ -16,9 +16,21 @@
|
|
|
16
16
|
"web": "expo start --web"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
<% if (props.stylingPackage?.name === "nativewind") { %>
|
|
19
|
+
<% if (props.stylingPackage?.name === "nativewind" || props.stylingPackage?.name === "nativewindui") { %>
|
|
20
20
|
"nativewind": "^4.0.1",
|
|
21
21
|
<% } %>
|
|
22
|
+
<% if (props.stylingPackage?.name === "nativewindui") { %>
|
|
23
|
+
"@react-navigation/material-top-tabs": "^6.6.13",
|
|
24
|
+
"@roninoss/icons": "^0.0.3",
|
|
25
|
+
"@shopify/flash-list": "1.6.3",
|
|
26
|
+
"class-variance-authority": "^0.7.0",
|
|
27
|
+
"clsx": "^2.1.0",
|
|
28
|
+
"expo-dev-client": "~3.3.8",
|
|
29
|
+
"tailwind-merge": "^2.2.1",
|
|
30
|
+
"react-native-uitextview": "^1.1.4",
|
|
31
|
+
"react-native-pager-view": "6.2.3",
|
|
32
|
+
"react-native-tab-view": "^3.5.2",
|
|
33
|
+
<% } %>
|
|
22
34
|
|
|
23
35
|
<% if (props.stylingPackage?.name === "restyle") { %>
|
|
24
36
|
"@shopify/restyle": "^2.4.2",
|
|
@@ -112,7 +124,7 @@
|
|
|
112
124
|
"eslint": "^8.50.0",
|
|
113
125
|
"eslint-config-universe": "^12.0.0",
|
|
114
126
|
"prettier": "^3.2.5",
|
|
115
|
-
<% if (props.stylingPackage?.name === "nativewind") { %>
|
|
127
|
+
<% if (props.stylingPackage?.name === "nativewind" || props.stylingPackage?.name === "nativewindui") { %>
|
|
116
128
|
"tailwindcss": "^3.4.0",
|
|
117
129
|
"prettier-plugin-tailwindcss": "^0.5.11",
|
|
118
130
|
<% } %>
|
|
@@ -124,7 +136,7 @@
|
|
|
124
136
|
"eslintConfig": {
|
|
125
137
|
"extends": "universe/native"
|
|
126
138
|
},
|
|
127
|
-
<% if (props.navigationPackage?.name ===
|
|
139
|
+
<% if (props.navigationPackage?.name === "expo-router") { %>
|
|
128
140
|
"resolutions": {
|
|
129
141
|
"expo-modules-core": "~1.11.0"
|
|
130
142
|
},
|
|
@@ -4,7 +4,7 @@ module.exports = {
|
|
|
4
4
|
singleQuote: true,
|
|
5
5
|
bracketSameLine: true,
|
|
6
6
|
trailingComma: 'es5',
|
|
7
|
-
<% if (props.stylingPackage?.name === "nativewind") { %>
|
|
7
|
+
<% if (props.stylingPackage?.name === "nativewind" || props.stylingPackage?.name === "nativewindui") { %>
|
|
8
8
|
plugins: [require.resolve("prettier-plugin-tailwindcss")],
|
|
9
9
|
tailwindAttributes: ["className"],
|
|
10
10
|
<% } %>
|
|
@@ -6,12 +6,16 @@
|
|
|
6
6
|
,
|
|
7
7
|
"baseUrl": ".",
|
|
8
8
|
"paths": {
|
|
9
|
-
<% if
|
|
10
|
-
|
|
11
|
-
<% } else
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
<% if (props.stylingPackage?.name === 'nativewindui') { %>
|
|
10
|
+
"~/*": [ "./*" ]
|
|
11
|
+
<% } else { %>
|
|
12
|
+
<% if (props.navigationPackage?.name === "expo-router" && props.flags.importAlias === true) { %>
|
|
13
|
+
"~/*": ["*"]
|
|
14
|
+
<% } else if (props.flags.importAlias === true) { %>
|
|
15
|
+
"~/*": ["src/*"]
|
|
16
|
+
<% } else { %>
|
|
17
|
+
"<%= props.flags.importAlias %>": ["src/*"]
|
|
18
|
+
<% } %>
|
|
15
19
|
<% } %>
|
|
16
20
|
}
|
|
17
21
|
<% } %>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<% if (props.stylingPackage?.name === "nativewind") { %>
|
|
2
|
-
import '
|
|
2
|
+
import './global.css';
|
|
3
|
+
<% } else if (props.stylingPackage?.name === "nativewinui") { %>
|
|
4
|
+
import './global.css';
|
|
5
|
+
import 'expo-dev-client';
|
|
3
6
|
<% } %>
|
|
4
7
|
<% if (props.stylingPackage?.name === "unistyles") { %>
|
|
5
8
|
import '../unistyles';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<% if (props.stylingPackage?.name === "nativewind") { %>
|
|
2
|
-
import '
|
|
2
|
+
import './global.css';
|
|
3
|
+
<% } else if (props.stylingPackage?.name === "nativewinui") { %>
|
|
4
|
+
import './global.css';
|
|
5
|
+
import 'expo-dev-client';
|
|
3
6
|
<% } %>
|
|
4
7
|
<% if (props.stylingPackage?.name === "unistyles") { %>
|
|
5
8
|
import '../unistyles';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<% if (props.stylingPackage?.name === "nativewind") { %>
|
|
2
|
-
import '
|
|
2
|
+
import './global.css';
|
|
3
|
+
<% } else if (props.stylingPackage?.name === "nativewinui") { %>
|
|
4
|
+
import './global.css';
|
|
5
|
+
import 'expo-dev-client';
|
|
3
6
|
<% } %>
|
|
4
7
|
<% if (props.stylingPackage?.name === "unistyles") { %>
|
|
5
8
|
import '../unistyles';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Link, Stack } from 'expo-router';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Text } from '~/components/nativewind-ui/Text';
|
|
4
|
+
|
|
5
|
+
export default function NotFoundScreen() {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
<Stack.Screen options={{ title: 'Oops!' }} />
|
|
9
|
+
<View className='flex-1 items-center justify-center p-5 bg-background'>
|
|
10
|
+
<Text variant='largeTitle'>This screen doesn't exist.</Text>
|
|
11
|
+
|
|
12
|
+
<Link href='/' className='m-4 py-4'>
|
|
13
|
+
<Text>Go to home screen!</Text>
|
|
14
|
+
</Link>
|
|
15
|
+
</View>
|
|
16
|
+
</>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import '~/global.css';
|
|
2
|
+
import 'expo-dev-client';
|
|
3
|
+
import { ThemeProvider as NavThemeProvider } from '@react-navigation/native';
|
|
4
|
+
import { Icon } from '@roninoss/icons';
|
|
5
|
+
import { Link, Stack } from 'expo-router';
|
|
6
|
+
import { StatusBar } from 'expo-status-bar';
|
|
7
|
+
import { Pressable, View } from 'react-native';
|
|
8
|
+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
9
|
+
|
|
10
|
+
import { ThemeToggle } from '~/components/ThemeToggle';
|
|
11
|
+
import { cn } from '~/lib/cn';
|
|
12
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
13
|
+
import { NAV_THEME } from '~/theme';
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
// Catch any errors thrown by the Layout component.
|
|
17
|
+
ErrorBoundary,
|
|
18
|
+
} from 'expo-router';
|
|
19
|
+
|
|
20
|
+
export default function RootLayout() {
|
|
21
|
+
const { colorScheme, isDarkColorScheme } = useColorScheme();
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<StatusBar
|
|
26
|
+
key={`root-status-bar-${isDarkColorScheme ? 'light' : 'dark'}`}
|
|
27
|
+
style={isDarkColorScheme ? 'light' : 'dark'}
|
|
28
|
+
/>
|
|
29
|
+
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
30
|
+
<NavThemeProvider value={NAV_THEME[colorScheme]}>
|
|
31
|
+
<Stack screenOptions={SCREEN_OPTIONS}>
|
|
32
|
+
<Stack.Screen name="index" options={INDEX_OPTIONS} />
|
|
33
|
+
<Stack.Screen name="top-tabs" options={TOP_TABS_OPTIONS} />
|
|
34
|
+
<Stack.Screen name="drawer" options={DEFAULT_OPTIONS} />
|
|
35
|
+
<Stack.Screen name="bottom-tabs" options={DEFAULT_OPTIONS} />
|
|
36
|
+
<Stack.Screen name="modal" options={MODAL_OPTIONS} />
|
|
37
|
+
</Stack>
|
|
38
|
+
</NavThemeProvider>
|
|
39
|
+
</GestureHandlerRootView>
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const SCREEN_OPTIONS = {
|
|
45
|
+
animation: 'ios', // for android
|
|
46
|
+
} as const;
|
|
47
|
+
|
|
48
|
+
const INDEX_OPTIONS = {
|
|
49
|
+
headerLargeTitle: true,
|
|
50
|
+
title: 'NativeWindUI',
|
|
51
|
+
headerRight: () => <SettingsIcon />,
|
|
52
|
+
} as const;
|
|
53
|
+
|
|
54
|
+
function SettingsIcon() {
|
|
55
|
+
const { colors } = useColorScheme();
|
|
56
|
+
return (
|
|
57
|
+
<Link href="/modal" asChild>
|
|
58
|
+
<Pressable className="opacity-80">
|
|
59
|
+
{({ pressed }) => (
|
|
60
|
+
<View className={cn(pressed ? 'opacity-50' : 'opacity-90')}>
|
|
61
|
+
<Icon name="cog-outline" color={colors.foreground} />
|
|
62
|
+
</View>
|
|
63
|
+
)}
|
|
64
|
+
</Pressable>
|
|
65
|
+
</Link>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const TOP_TABS_OPTIONS = {
|
|
70
|
+
title: 'Top Tabs',
|
|
71
|
+
headerShadowVisible: false,
|
|
72
|
+
headerBackTitle: 'Back',
|
|
73
|
+
headerRight: () => <ThemeToggle />,
|
|
74
|
+
} as const;
|
|
75
|
+
|
|
76
|
+
const MODAL_OPTIONS = {
|
|
77
|
+
presentation: 'modal',
|
|
78
|
+
animation: 'fade_from_bottom', // for android
|
|
79
|
+
title: 'Settings',
|
|
80
|
+
headerRight: () => <ThemeToggle />,
|
|
81
|
+
} as const;
|
|
82
|
+
|
|
83
|
+
const DEFAULT_OPTIONS = {
|
|
84
|
+
headerShown: false,
|
|
85
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ThemeToggle } from '~/components/ThemeToggle';
|
|
2
|
+
import { Icon } from '@roninoss/icons';
|
|
3
|
+
import { Tabs } from 'expo-router';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
export default function TabsLayout() {
|
|
7
|
+
return (
|
|
8
|
+
<Tabs screenOptions={SCREEN_OPTIONS}>
|
|
9
|
+
<Tabs.Screen name='index' options={INDEX_OPTIONS} />
|
|
10
|
+
<Tabs.Screen name='profile' options={PROFILE_OPTIONS} />
|
|
11
|
+
</Tabs>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
const SCREEN_OPTIONS = {
|
|
15
|
+
headerRight: () => (
|
|
16
|
+
<View className='px-4'>
|
|
17
|
+
<ThemeToggle />
|
|
18
|
+
</View>
|
|
19
|
+
),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const INDEX_OPTIONS = {
|
|
23
|
+
title: 'Home',
|
|
24
|
+
tabBarIcon({ color, size }: { color: string; size: number }) {
|
|
25
|
+
return <Icon name='home' color={color} size={size} />;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const PROFILE_OPTIONS = {
|
|
30
|
+
title: 'Profile',
|
|
31
|
+
tabBarIcon({ color, size }: { color: string; size: number }) {
|
|
32
|
+
return <Icon name='person' color={color} size={size} />;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { router } from 'expo-router';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Button, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export default function HomeScreen() {
|
|
6
|
+
return (
|
|
7
|
+
<View className='flex-1 justify-center items-center'>
|
|
8
|
+
<Button title='Go back' onPress={router.back} />
|
|
9
|
+
</View>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { router } from 'expo-router';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Button, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export default function ProfileScreen() {
|
|
6
|
+
return (
|
|
7
|
+
<View className='flex-1 justify-center items-center'>
|
|
8
|
+
<Button color={'orange'} title='Go to home tab' onPress={router.back} />
|
|
9
|
+
</View>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ThemeToggle } from '~/components/ThemeToggle';
|
|
2
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
3
|
+
import { Drawer } from 'expo-router/drawer';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
export default function DrawerLayout() {
|
|
7
|
+
const { colors } = useColorScheme();
|
|
8
|
+
return (
|
|
9
|
+
<Drawer
|
|
10
|
+
screenOptions={{
|
|
11
|
+
headerTintColor: colors.foreground,
|
|
12
|
+
headerRight,
|
|
13
|
+
}}
|
|
14
|
+
>
|
|
15
|
+
<Drawer.Screen name='index' options={EXPLORE_OPTIONS} />
|
|
16
|
+
</Drawer>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function headerRight() {
|
|
21
|
+
return (
|
|
22
|
+
<View className='px-4'>
|
|
23
|
+
<ThemeToggle />
|
|
24
|
+
</View>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const EXPLORE_OPTIONS = {
|
|
28
|
+
title: 'Explore',
|
|
29
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { router } from 'expo-router';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Button, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export default function ExploreScreen() {
|
|
6
|
+
return (
|
|
7
|
+
<View className='flex-1 justify-center items-center'>
|
|
8
|
+
<Button title='Go back' onPress={router.back} />
|
|
9
|
+
</View>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useHeaderHeight } from '@react-navigation/elements';
|
|
2
|
+
import { FlashList } from '@shopify/flash-list';
|
|
3
|
+
import { cssInterop } from 'nativewind';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { Button as RNButton, ButtonProps, Linking, View, Platform } from 'react-native';
|
|
6
|
+
|
|
7
|
+
import { Text } from '~/components/nativewind-ui/Text';
|
|
8
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
9
|
+
import { useHeaderSearchBar } from '~/lib/useHeaderSearchBar';
|
|
10
|
+
|
|
11
|
+
cssInterop(FlashList, {
|
|
12
|
+
className: 'style',
|
|
13
|
+
contentContainerClassName: 'contentContainerStyle',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
function DefaultButton({ color, ...props }: ButtonProps) {
|
|
17
|
+
const { colors } = useColorScheme();
|
|
18
|
+
return <RNButton color={color ?? colors.primary} {...props} />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function Screen() {
|
|
22
|
+
const searchValue = useHeaderSearchBar();
|
|
23
|
+
|
|
24
|
+
const data = searchValue
|
|
25
|
+
? COMPONENTS.filter((c) => c.name.toLowerCase().includes(searchValue.toLowerCase()))
|
|
26
|
+
: COMPONENTS;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<FlashList
|
|
30
|
+
contentInsetAdjustmentBehavior="automatic"
|
|
31
|
+
keyboardShouldPersistTaps="handled"
|
|
32
|
+
data={data}
|
|
33
|
+
estimatedItemSize={200}
|
|
34
|
+
contentContainerClassName="py-4"
|
|
35
|
+
centerContent={data.length === 0}
|
|
36
|
+
extraData={searchValue}
|
|
37
|
+
removeClippedSubviews={false} // used for selecting text on android
|
|
38
|
+
keyExtractor={keyExtractor}
|
|
39
|
+
ItemSeparatorComponent={renderItemSeparator}
|
|
40
|
+
renderItem={renderItem}
|
|
41
|
+
ListEmptyComponent={ListEmptyComponent}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const SEARCH_BAR_HEIGHT = 52;
|
|
47
|
+
|
|
48
|
+
function ListEmptyComponent() {
|
|
49
|
+
const headerHeight = useHeaderHeight();
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
{Platform.OS === 'ios' && <View style={{ height: headerHeight + SEARCH_BAR_HEIGHT }} />}
|
|
53
|
+
<View className="flex-1 items-center justify-center px-4">
|
|
54
|
+
<Text variant="title3" className="pb-1 text-center font-bold">
|
|
55
|
+
Add Components
|
|
56
|
+
</Text>
|
|
57
|
+
<Text color="tertiary" variant="body" className="pb-4 text-center">
|
|
58
|
+
You can install any of the free components from the NativeWindUI website.
|
|
59
|
+
</Text>
|
|
60
|
+
<DefaultButton
|
|
61
|
+
title="Open NativeWindUI"
|
|
62
|
+
onPress={() => Linking.openURL('https://nativewindui.com')}
|
|
63
|
+
/>
|
|
64
|
+
</View>
|
|
65
|
+
</>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type ComponentItem = { name: string; component: () => React.JSX.Element };
|
|
70
|
+
|
|
71
|
+
function keyExtractor(item: ComponentItem) {
|
|
72
|
+
return item.name;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function renderItemSeparator() {
|
|
76
|
+
return <View className="p-2" />;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function renderItem({ item }: { item: ComponentItem }) {
|
|
80
|
+
return (
|
|
81
|
+
<Card title={item.name}>
|
|
82
|
+
<item.component />
|
|
83
|
+
</Card>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function Card({ children, title }: { children: React.ReactNode; title: string }) {
|
|
88
|
+
return (
|
|
89
|
+
<View className="px-4">
|
|
90
|
+
<View className="gap-4 rounded-xl border border-border bg-card p-4 pb-6 shadow-sm shadow-black/10 dark:shadow-none">
|
|
91
|
+
<Text className="text-center text-sm font-medium tracking-wider opacity-60">{title}</Text>
|
|
92
|
+
{children}
|
|
93
|
+
</View>
|
|
94
|
+
</View>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const COMPONENTS: ComponentItem[] = [];
|
|
99
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Text } from '~/components/nativewind-ui/Text';
|
|
2
|
+
import { Link } from 'expo-router';
|
|
3
|
+
import { StatusBar } from 'expo-status-bar';
|
|
4
|
+
import { useColorScheme } from 'nativewind';
|
|
5
|
+
import { Platform, View } from 'react-native';
|
|
6
|
+
|
|
7
|
+
export default function ModalScreen() {
|
|
8
|
+
const { colorScheme } = useColorScheme();
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
<StatusBar
|
|
12
|
+
style={
|
|
13
|
+
Platform.OS === 'ios'
|
|
14
|
+
? 'light'
|
|
15
|
+
: colorScheme === 'dark'
|
|
16
|
+
? 'light'
|
|
17
|
+
: 'dark'
|
|
18
|
+
}
|
|
19
|
+
/>
|
|
20
|
+
<View className='flex-1 justify-center items-center gap-8 pb-12'>
|
|
21
|
+
<View className='items-center gap-2'>
|
|
22
|
+
<Text variant='largeTitle' className='font-bold'>
|
|
23
|
+
NativeWindUI
|
|
24
|
+
</Text>
|
|
25
|
+
<Link href={'https://nativewindui.com/'}>
|
|
26
|
+
<Text className='text-primary'>https://nativewindui.com/</Text>
|
|
27
|
+
</Link>
|
|
28
|
+
</View>
|
|
29
|
+
</View>
|
|
30
|
+
</>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
2
|
+
import type {
|
|
3
|
+
MaterialTopTabNavigationEventMap,
|
|
4
|
+
MaterialTopTabNavigationOptions,
|
|
5
|
+
} from '@react-navigation/material-top-tabs';
|
|
6
|
+
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
|
|
7
|
+
import {
|
|
8
|
+
type ParamListBase,
|
|
9
|
+
type TabNavigationState,
|
|
10
|
+
} from '@react-navigation/native';
|
|
11
|
+
import { withLayoutContext } from 'expo-router';
|
|
12
|
+
import { Dimensions } from 'react-native';
|
|
13
|
+
|
|
14
|
+
const { width } = Dimensions.get('screen');
|
|
15
|
+
|
|
16
|
+
const { Navigator } = createMaterialTopTabNavigator();
|
|
17
|
+
|
|
18
|
+
const TopTabs = withLayoutContext<
|
|
19
|
+
MaterialTopTabNavigationOptions,
|
|
20
|
+
typeof Navigator,
|
|
21
|
+
TabNavigationState<ParamListBase>,
|
|
22
|
+
MaterialTopTabNavigationEventMap
|
|
23
|
+
>(Navigator);
|
|
24
|
+
|
|
25
|
+
const SCREENS = [
|
|
26
|
+
{
|
|
27
|
+
name: 'index',
|
|
28
|
+
title: 'For You',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'following',
|
|
32
|
+
title: 'Following',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'my-group',
|
|
36
|
+
title: 'My Group',
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export default function TopTabsLayout() {
|
|
41
|
+
const { colors } = useColorScheme();
|
|
42
|
+
return (
|
|
43
|
+
<TopTabs
|
|
44
|
+
initialRouteName='index'
|
|
45
|
+
screenOptions={{
|
|
46
|
+
tabBarActiveTintColor: colors.primary,
|
|
47
|
+
tabBarInactiveTintColor: 'grey',
|
|
48
|
+
tabBarLabelStyle: {
|
|
49
|
+
fontSize: 14,
|
|
50
|
+
textTransform: 'capitalize',
|
|
51
|
+
fontWeight: 'bold',
|
|
52
|
+
},
|
|
53
|
+
tabBarIndicatorStyle: {
|
|
54
|
+
backgroundColor: colors.primary,
|
|
55
|
+
},
|
|
56
|
+
tabBarScrollEnabled: true,
|
|
57
|
+
tabBarItemStyle: { width: width / SCREENS.length },
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
{SCREENS.map(({ name, title }) => (
|
|
61
|
+
<TopTabs.Screen
|
|
62
|
+
key={name}
|
|
63
|
+
name={name}
|
|
64
|
+
options={{
|
|
65
|
+
title,
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
))}
|
|
69
|
+
</TopTabs>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Text } from '~/components/nativewind-ui/Text';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export default function FollowingScreen() {
|
|
5
|
+
return (
|
|
6
|
+
<View className='flex-1 justify-center items-center gap-5'>
|
|
7
|
+
<View className='items-center gap-1'>
|
|
8
|
+
<Text variant='title1'>Following Tab</Text>
|
|
9
|
+
<Text>Swipe to see other tabs</Text>
|
|
10
|
+
</View>
|
|
11
|
+
</View>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Text } from '~/components/nativewind-ui/Text';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export default function ForYouScreen() {
|
|
5
|
+
return (
|
|
6
|
+
<View className='flex-1 justify-center items-center gap-5'>
|
|
7
|
+
<View className='items-center gap-1'>
|
|
8
|
+
<Text variant='title1'>For You Tab</Text>
|
|
9
|
+
<Text>Swipe to see other tabs</Text>
|
|
10
|
+
</View>
|
|
11
|
+
</View>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
import { Text } from '~/components/nativewind-ui/Text';
|
|
3
|
+
|
|
4
|
+
export default function MyGroupScreen() {
|
|
5
|
+
return (
|
|
6
|
+
<View className='flex-1 justify-center items-center gap-5'>
|
|
7
|
+
<View className='items-center gap-1'>
|
|
8
|
+
<Text variant='title1'>My Group Tab</Text>
|
|
9
|
+
<Text>Swipe to see other tabs</Text>
|
|
10
|
+
</View>
|
|
11
|
+
</View>
|
|
12
|
+
);
|
|
13
|
+
}
|