lucy-cli 2.0.0-alpha.2 → 2.0.0-alpha.3

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.
Files changed (51) hide show
  1. package/dist/init.js +29 -11
  2. package/files/expo/.prettierrc.js +16 -0
  3. package/files/expo/.yarnrc.yml +1 -1
  4. package/files/expo/app/(tabs)/_layout.tsx +38 -33
  5. package/files/expo/app/(tabs)/explore.tsx +114 -0
  6. package/files/expo/app/(tabs)/index.tsx +80 -0
  7. package/files/expo/app/+not-found.tsx +37 -0
  8. package/files/expo/app/_layout.tsx +39 -30
  9. package/files/expo/assets/fonts/SpaceMono-Regular.ttf +0 -0
  10. package/files/expo/assets/images/adaptive-icon.png +0 -0
  11. package/files/expo/assets/images/favicon.png +0 -0
  12. package/files/expo/assets/images/icon.png +0 -0
  13. package/files/expo/assets/images/partial-react-logo.png +0 -0
  14. package/files/expo/assets/images/react-logo.png +0 -0
  15. package/files/expo/assets/images/react-logo@2x.png +0 -0
  16. package/files/expo/assets/images/react-logo@3x.png +0 -0
  17. package/files/expo/assets/images/splash-icon.png +0 -0
  18. package/files/expo/babel.config.js +7 -6
  19. package/files/expo/components/Collapsible.tsx +52 -0
  20. package/files/expo/components/ExternalLink.tsx +32 -0
  21. package/files/expo/components/HapticTab.tsx +24 -0
  22. package/files/expo/components/HelloWave.tsx +35 -0
  23. package/files/expo/components/ParallaxScrollView.tsx +85 -0
  24. package/files/expo/components/ThemedText.tsx +70 -0
  25. package/files/expo/components/ThemedView.tsx +23 -0
  26. package/files/expo/components/ui/IconSymbol.ios.tsx +32 -0
  27. package/files/expo/components/ui/IconSymbol.tsx +41 -0
  28. package/files/expo/components/ui/TabBarBackground.ios.tsx +19 -0
  29. package/files/expo/components/ui/TabBarBackground.tsx +6 -0
  30. package/files/expo/constants/Colors.ts +17 -17
  31. package/files/expo/constants/theme.ts +17 -17
  32. package/files/expo/{eslint.config.js → eslint.config.mjs} +15 -19
  33. package/files/expo/hooks/useColorScheme.ts +13 -7
  34. package/files/expo/hooks/useColorScheme.web.ts +12 -9
  35. package/files/expo/hooks/useThemeColor.ts +19 -10
  36. package/files/expo/lib/data.ts +36 -33
  37. package/files/expo/lib/utils/index.ts +7 -2
  38. package/files/expo/lib/utils/polyfills.ts +1 -1
  39. package/files/expo/lib/wix/client.ts +3 -5
  40. package/files/expo/lib/wix/error.ts +3 -0
  41. package/files/expo/lib/wix/index.ts +1 -0
  42. package/files/expo/metro.config.js +31 -0
  43. package/files/expo/patches/@wix-sdk-npm-1.15.24-1adbec98e9.patch +20 -0
  44. package/files/expo/scripts/reset-project.ts +116 -0
  45. package/files/expo/tailwind.config.js +61 -196
  46. package/files/expo/tsconfig.json +31 -26
  47. package/package.json +1 -1
  48. package/src/init.ts +41 -16
  49. package/files/expo/.prettierrc.json +0 -16
  50. /package/files/expo/{readme.md → README.md} +0 -0
  51. /package/files/expo/{types/nativewind-env.d.ts → nativewind-env.d.ts} +0 -0
package/dist/init.js CHANGED
@@ -157,19 +157,19 @@ import { JsonSchema } from "./schemas/index.js";
157
157
  // console.log(blue.underline(`🐕 => Updated file ${orange(filePath)}`));
158
158
  // }
159
159
  // }
160
- const yarn = Command.make("yarn").pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
161
- Command.exitCode // Get the exit code
162
- );
163
160
  const init_expo = () => {
164
161
  return Effect.gen(function* () {
165
162
  const config = yield* Config;
166
163
  const terminal = yield* Terminal.Terminal;
167
164
  const fs = yield* FileSystem.FileSystem;
168
165
  const path = yield* Path.Path;
169
- const yarn = Command.make("yarn", "add", "nativewind", "react-native-reanimated@~3.17.4", "react-native-safe-area-context@5.4.0", "@wix/sdk", "@wix/data", "expo-standard-web-crypto", "effect").pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
166
+ const resolutions = {
167
+ "@wix/sdk@1.15.24": "patch:@wix/sdk@npm:1.15.24#./patches/@wix-sdk-npm-1.15.24-1adbec98e9.patch",
168
+ };
169
+ const yarn = Command.make("yarn", "add", "nativewind", "react-native-reanimated@~3.17.4", "react-native-safe-area-context@5.4.0", "@wix/sdk@1.15.24", "@wix/data", "expo-standard-web-crypto", "effect", "node-libs-react-native", "util", "events").pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
170
170
  Command.exitCode // Get the exit code
171
171
  );
172
- const yarnDev = Command.make("yarn", "add", "--dev", "tailwindcss@^3.4.17", "prettier-plugin-tailwindcss@^0.5.11", "@styled/typescript-styled-plugin", "typescript-eslint-language-service", "eslint-config-prettier", "eslint-plugin-jsdoc", "eslint-plugin-named-import-spacing", "eslint-plugin-only-warn", "eslint-plugin-react", "eslint-plugin-react-hooks", "eslint-plugin-simple-import-sort", "@next/eslint-plugin-next", "@styled/typescript-styled-plugin", "@stylelint/postcss-css-in-js", "@typescript-eslint/parser", "typescript-eslint", "typescript-eslint-language-service", "@total-typescript/ts-reset").pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
172
+ const yarnDev = Command.make("yarn", "add", "--dev", "tailwindcss@^3.4.17", "prettier-plugin-tailwindcss@^0.5.11", "@styled/typescript-styled-plugin", "typescript-eslint-language-service", "eslint-config-prettier", "eslint-plugin-jsdoc", "eslint-plugin-named-import-spacing", "eslint-plugin-only-warn", "eslint-plugin-react", "eslint-plugin-react-hooks", "eslint-plugin-simple-import-sort", "@next/eslint-plugin-next", "@styled/typescript-styled-plugin", "@stylelint/postcss-css-in-js", "@typescript-eslint/parser", "typescript-eslint", "typescript-eslint-language-service", "@total-typescript/ts-reset", "expo-doctor", "tsx").pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
173
173
  Command.exitCode // Get the exit code
174
174
  );
175
175
  const npx = Command.make("npx", "expo", "install", "tailwindcss-animate", "class-variance-authority", "clsx", "tailwind-merge", "expo-crypto").pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
@@ -206,34 +206,52 @@ const init_expo = () => {
206
206
  if (lucyInitialized)
207
207
  return yield* Effect.logError("Lucy is already initialized in this project. Please run this command in an empty directory.");
208
208
  console.log("Expo project initialized with app.json:", projectName);
209
+ const baseFiles = yield* fs.readDirectory(config.config.filesFolder + '/expo');
210
+ yield* Effect.forEach(baseFiles, (file) => fs.copy(path.join(config.config.filesFolder, 'expo', file), path.join(config.config.cwd, file), { overwrite: true }));
209
211
  let res = yield* npx;
210
212
  res = yield* yarn;
211
213
  res = yield* yarnDev;
212
214
  if (res !== 0) {
213
215
  return yield* Effect.logError("Failed to install Expo dependencies. Please check the error message above.");
214
216
  }
215
- const baseFiles = yield* fs.readDirectory(config.config.filesFolder + '/expo');
216
- yield* Effect.forEach(baseFiles, (file) => fs.copy(path.join(config.config.filesFolder, 'expo', file), path.join(config.config.cwd, file), { overwrite: true }));
217
217
  const newScripts = {
218
218
  "dev": "expo start",
219
219
  "start": "expo start",
220
220
  "android": "expo start --android",
221
221
  "ios": "expo start --ios",
222
222
  "web": "expo start --web",
223
+ "reset": "tsx ./scripts/reset-project.ts",
223
224
  "format": "prettier --write \"./*.json\" \"**/*.{ts,tsx,md,json,jsonc,json5}\"",
224
- "build:ios": "eas build --platform ios --local --profile preview",
225
- "build:android": "eas build --platform android --local --profile preview",
226
- "build:web": "eas build --platform web --local --profile preview",
225
+ "build:dev": "eas build --local --profile development",
226
+ "build:sim": "eas build --local --profile simulator",
227
+ "build:prev": "eas build --local --profile preview",
228
+ "build:prod": "eas build --local --profile production",
229
+ "build:web": "expo export --platform web",
230
+ "doctor": "expo-doctor"
227
231
  };
228
232
  const packageJsonPath = path.join(config.config.cwd, "package.json");
229
233
  const packageJsonRaw = yield* fs.readFile(packageJsonPath);
230
234
  const packageJson = Schema.decodeUnknownSync(JsonSchema)(packageJsonRaw.toString());
231
235
  packageJson.scripts = {
232
236
  ...packageJson.scripts,
233
- ...newScripts
237
+ ...newScripts,
238
+ };
239
+ packageJson.resolutions = {
240
+ ...packageJson.resolutions,
241
+ ...resolutions,
242
+ };
243
+ packageJson.expo = {
244
+ doctor: {
245
+ reactNativeDirectoryCheck: {
246
+ listUnknownPackages: false,
247
+ },
248
+ }
234
249
  };
235
250
  yield* fs.writeFileString(path.join(config.config.cwd, 'package.json'), JSON.stringify(packageJson, null, 2));
236
251
  yield* fs.remove(path.join(config.config.cwd, "package-lock.json"), { force: true });
252
+ yield* Command.make("yarn").pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
253
+ Command.exitCode // Get the exit code
254
+ );
237
255
  });
238
256
  };
239
257
  export const init = () => {
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ printWidth: 80,
3
+ tabWidth: 4,
4
+ useTabs: true,
5
+ singleQuote: true,
6
+ trailingComma: 'all',
7
+ plugins: ['prettier-plugin-tailwindcss'],
8
+ overrides: [
9
+ {
10
+ files: ['**/*.{json,jsonc,json5}', '*.{json,jsonc,json5}'],
11
+ options: {
12
+ useTabs: true
13
+ }
14
+ }
15
+ ]
16
+ };
@@ -1,3 +1,3 @@
1
1
  nodeLinker: node-modules
2
-
3
2
  npmRegistryServer: "https://registry.npmjs.org/"
3
+ patchFolder: patches
@@ -5,41 +5,46 @@ import { Platform } from 'react-native';
5
5
  import { HapticTab } from '@/components/HapticTab';
6
6
  import { IconSymbol } from '@/components/ui/IconSymbol';
7
7
  import TabBarBackground from '@/components/ui/TabBarBackground.ios';
8
- import { Colors } from '@/constants/Colors';
8
+ import { colors } from '@/constants/Colors';
9
9
  import { useColorScheme } from '@/hooks/useColorSchemeRN';
10
10
 
11
+ /**
12
+ * Renders the tab layout for the application.
13
+ * This includes the home and explore tabs with haptic feedback on press.
14
+ * @returns The tab layout component.
15
+ */
11
16
  export default function TabLayout() {
12
- const colorScheme = useColorScheme();
17
+ const colorScheme = useColorScheme();
13
18
 
14
- return (
15
- <Tabs
16
- screenOptions={{
17
- tabBarActiveTintColor: Colors[colorScheme ?? 'light'].tint,
18
- headerShown: false,
19
- tabBarButton: HapticTab,
20
- tabBarBackground: TabBarBackground,
21
- tabBarStyle: Platform.select({
22
- ios: {
23
- // Use a transparent background on iOS to show the blur effect
24
- position: 'absolute',
25
- },
26
- default: {},
27
- }),
28
- }}>
29
- <Tabs.Screen
30
- name="index"
31
- options={{
32
- title: 'Home',
33
- tabBarIcon: ({ color }) => <IconSymbol size={28} name="house.fill" color={color} />,
34
- }}
35
- />
36
- <Tabs.Screen
37
- name="explore"
38
- options={{
39
- title: 'Explore',
40
- tabBarIcon: ({ color }) => <IconSymbol size={28} name="paperplane.fill" color={color} />,
41
- }}
42
- />
43
- </Tabs>
44
- );
19
+ return (
20
+ <Tabs
21
+ screenOptions={{
22
+ tabBarActiveTintColor: colors[colorScheme ?? 'light'].tint,
23
+ headerShown: false,
24
+ tabBarButton: HapticTab,
25
+ tabBarBackground: TabBarBackground,
26
+ tabBarStyle: Platform.select({
27
+ ios: {
28
+ // Use a transparent background on iOS to show the blur effect
29
+ position: 'absolute',
30
+ },
31
+ default: {},
32
+ }),
33
+ }}>
34
+ <Tabs.Screen
35
+ name="index"
36
+ options={{
37
+ title: 'Home',
38
+ tabBarIcon: ({ color }) => <IconSymbol size={28} name="house.fill" color={color} />,
39
+ }}
40
+ />
41
+ <Tabs.Screen
42
+ name="explore"
43
+ options={{
44
+ title: 'Explore',
45
+ tabBarIcon: ({ color }) => <IconSymbol size={28} name="paperplane.fill" color={color} />,
46
+ }}
47
+ />
48
+ </Tabs>
49
+ );
45
50
  }
@@ -0,0 +1,114 @@
1
+ import { Image } from 'expo-image';
2
+ import { Platform, StyleSheet } from 'react-native';
3
+
4
+ import { Collapsible } from '@/components/Collapsible';
5
+ import { ExternalLink } from '@/components/ExternalLink';
6
+ import ParallaxScrollView from '@/components/ParallaxScrollView';
7
+ import { ThemedText } from '@/components/ThemedText';
8
+ import { ThemedView } from '@/components/ThemedView';
9
+ import { IconSymbol } from '@/components/ui/IconSymbol';
10
+
11
+ /**
12
+ * Renders the Explore screen with various examples and explanations of features.
13
+ * @returns The Explore screen component.
14
+ */
15
+ export default function TabTwoScreen() {
16
+ return (
17
+ <ParallaxScrollView
18
+ headerBackgroundColor={{ light: '#D0D0D0', dark: '#353636' }}
19
+ headerImage={
20
+ <IconSymbol
21
+ size={310}
22
+ color="#808080"
23
+ name="chevron.left.forwardslash.chevron.right"
24
+ style={styles.headerImage}
25
+ />
26
+ }>
27
+ <ThemedView style={styles.titleContainer}>
28
+ <ThemedText type="title">Explore</ThemedText>
29
+ </ThemedView>
30
+ <ThemedText>This app includes example code to help you get started.</ThemedText>
31
+ <Collapsible title="File-based routing">
32
+ <ThemedText>
33
+ This app has two screens:{' '}
34
+ <ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> and{' '}
35
+ <ThemedText type="defaultSemiBold">app/(tabs)/explore.tsx</ThemedText>
36
+ </ThemedText>
37
+ <ThemedText>
38
+ The layout file in <ThemedText type="defaultSemiBold">app/(tabs)/_layout.tsx</ThemedText>{' '}
39
+ sets up the tab navigator.
40
+ </ThemedText>
41
+ <ExternalLink href="https://docs.expo.dev/router/introduction">
42
+ <ThemedText type="link">Learn more</ThemedText>
43
+ </ExternalLink>
44
+ </Collapsible>
45
+ <Collapsible title="Android, iOS, and web support">
46
+ <ThemedText>
47
+ You can open this project on Android, iOS, and the web. To open the web version, press{' '}
48
+ <ThemedText type="defaultSemiBold">w</ThemedText> in the terminal running this project.
49
+ </ThemedText>
50
+ </Collapsible>
51
+ <Collapsible title="Images">
52
+ <ThemedText>
53
+ For static images, you can use the <ThemedText type="defaultSemiBold">@2x</ThemedText> and{' '}
54
+ <ThemedText type="defaultSemiBold">@3x</ThemedText> suffixes to provide files for
55
+ different screen densities
56
+ </ThemedText>
57
+ <Image source={require('@/assets/images/react-logo.png')} style={{ alignSelf: 'center' }} />
58
+ <ExternalLink href="https://reactnative.dev/docs/images">
59
+ <ThemedText type="link">Learn more</ThemedText>
60
+ </ExternalLink>
61
+ </Collapsible>
62
+ <Collapsible title="Custom fonts">
63
+ <ThemedText>
64
+ Open <ThemedText type="defaultSemiBold">app/_layout.tsx</ThemedText> to see how to load{' '}
65
+ <ThemedText style={{ fontFamily: 'SpaceMono' }}>
66
+ custom fonts such as this one.
67
+ </ThemedText>
68
+ </ThemedText>
69
+ <ExternalLink href="https://docs.expo.dev/versions/latest/sdk/font">
70
+ <ThemedText type="link">Learn more</ThemedText>
71
+ </ExternalLink>
72
+ </Collapsible>
73
+ <Collapsible title="Light and dark mode components">
74
+ <ThemedText>
75
+ This template has light and dark mode support. The{' '}
76
+ <ThemedText type="defaultSemiBold">useColorScheme()</ThemedText> hook lets you inspect
77
+ what the user&apos;s current color scheme is, and so you can adjust UI colors accordingly.
78
+ </ThemedText>
79
+ <ExternalLink href="https://docs.expo.dev/develop/user-interface/color-themes/">
80
+ <ThemedText type="link">Learn more</ThemedText>
81
+ </ExternalLink>
82
+ </Collapsible>
83
+ <Collapsible title="Animations">
84
+ <ThemedText>
85
+ This template includes an example of an animated component. The{' '}
86
+ <ThemedText type="defaultSemiBold">components/HelloWave.tsx</ThemedText> component uses
87
+ the powerful <ThemedText type="defaultSemiBold">react-native-reanimated</ThemedText>{' '}
88
+ library to create a waving hand animation.
89
+ </ThemedText>
90
+ {Platform.select({
91
+ ios: (
92
+ <ThemedText>
93
+ The <ThemedText type="defaultSemiBold">components/ParallaxScrollView.tsx</ThemedText>{' '}
94
+ component provides a parallax effect for the header image.
95
+ </ThemedText>
96
+ ),
97
+ })}
98
+ </Collapsible>
99
+ </ParallaxScrollView>
100
+ );
101
+ }
102
+
103
+ const styles = StyleSheet.create({
104
+ headerImage: {
105
+ color: '#808080',
106
+ bottom: -90,
107
+ left: -35,
108
+ position: 'absolute',
109
+ },
110
+ titleContainer: {
111
+ flexDirection: 'row',
112
+ gap: 8,
113
+ },
114
+ });
@@ -0,0 +1,80 @@
1
+ import { Image } from 'expo-image';
2
+ import { Platform, StyleSheet } from 'react-native';
3
+
4
+ import { HelloWave } from '@/components/HelloWave';
5
+ import ParallaxScrollView from '@/components/ParallaxScrollView';
6
+ import { ThemedText } from '@/components/ThemedText';
7
+ import { ThemedView } from '@/components/ThemedView';
8
+
9
+ /**
10
+ * Home screen component.
11
+ * This screen serves as the landing page for the app,
12
+ * @returns The home screen component.
13
+ */
14
+ export default function HomeScreen() {
15
+ return (
16
+ <ParallaxScrollView
17
+ headerBackgroundColor={{ light: '#A1CEDC', dark: '#1D3D47' }}
18
+ headerImage={
19
+ <Image
20
+ source={require('@/assets/images/partial-react-logo.png')}
21
+ style={styles.reactLogo}
22
+ />
23
+ }>
24
+ <ThemedView style={styles.titleContainer}>
25
+ <ThemedText type="title">Welcome!</ThemedText>
26
+ <HelloWave />
27
+ </ThemedView>
28
+ <ThemedView style={styles.stepContainer}>
29
+ <ThemedText type="subtitle">Step 1: Try it</ThemedText>
30
+ <ThemedText>
31
+ Edit <ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> to see changes.
32
+ Press{' '}
33
+ <ThemedText type="defaultSemiBold">
34
+ {Platform.select({
35
+ ios: 'cmd + d',
36
+ android: 'cmd + m',
37
+ web: 'F12',
38
+ })}
39
+ </ThemedText>{' '}
40
+ to open developer tools.
41
+ </ThemedText>
42
+ </ThemedView>
43
+ <ThemedView style={styles.stepContainer}>
44
+ <ThemedText type="subtitle">Step 2: Explore</ThemedText>
45
+ <ThemedText>
46
+ {`Tap the Explore tab to learn more about what's included in this starter app.`}
47
+ </ThemedText>
48
+ </ThemedView>
49
+ <ThemedView style={styles.stepContainer}>
50
+ <ThemedText type="subtitle">Step 3: Get a fresh start</ThemedText>
51
+ <ThemedText>
52
+ {`When you're ready, run `}
53
+ <ThemedText type="defaultSemiBold">yarn reset-project</ThemedText> to get a fresh{' '}
54
+ <ThemedText type="defaultSemiBold">app</ThemedText> directory. This will move the current{' '}
55
+ <ThemedText type="defaultSemiBold">app</ThemedText> to{' '}
56
+ <ThemedText type="defaultSemiBold">app-example</ThemedText>.
57
+ </ThemedText>
58
+ </ThemedView>
59
+ </ParallaxScrollView>
60
+ );
61
+ }
62
+
63
+ const styles = StyleSheet.create({
64
+ titleContainer: {
65
+ flexDirection: 'row',
66
+ alignItems: 'center',
67
+ gap: 8,
68
+ },
69
+ stepContainer: {
70
+ gap: 8,
71
+ marginBottom: 8,
72
+ },
73
+ reactLogo: {
74
+ height: 178,
75
+ width: 290,
76
+ bottom: 0,
77
+ left: 0,
78
+ position: 'absolute',
79
+ },
80
+ });
@@ -0,0 +1,37 @@
1
+ import { Link, Stack } from 'expo-router';
2
+ import { StyleSheet } from 'react-native';
3
+
4
+ import { ThemedText } from '@/components/ThemedText';
5
+ import { ThemedView } from '@/components/ThemedView';
6
+
7
+ /**
8
+ * Renders a not found screen when a route does not exist.
9
+ * This screen provides a link to navigate back to the home screen.
10
+ * @returns The not found screen component.
11
+ */
12
+ export default function NotFoundScreen() {
13
+ return (
14
+ <>
15
+ <Stack.Screen options={{ title: 'Oops!' }} />
16
+ <ThemedView style={styles.container}>
17
+ <ThemedText type="title">This screen does not exist.</ThemedText>
18
+ <Link href="/" style={styles.link}>
19
+ <ThemedText type="link">Go to home screen!</ThemedText>
20
+ </Link>
21
+ </ThemedView>
22
+ </>
23
+ );
24
+ }
25
+
26
+ const styles = StyleSheet.create({
27
+ container: {
28
+ flex: 1,
29
+ alignItems: 'center',
30
+ justifyContent: 'center',
31
+ padding: 20,
32
+ },
33
+ link: {
34
+ marginTop: 15,
35
+ paddingVertical: 15,
36
+ },
37
+ });
@@ -1,45 +1,54 @@
1
1
  import '@/global.css';
2
- import "@/lib/utils/polyfills";
2
+ import '@/lib/utils/polyfills';
3
3
 
4
- import { NAV_THEME } from '@/constants/theme';
5
- import { useColorScheme } from '@/hooks/useColorScheme';
6
4
  import { DarkTheme, DefaultTheme, Theme, ThemeProvider } from '@react-navigation/native';
7
5
  import { Stack } from 'expo-router';
8
6
  import { StatusBar } from 'expo-status-bar';
9
7
  import * as React from 'react';
10
8
  import { Platform } from 'react-native';
9
+
10
+ import { NAV_THEME } from '@/constants/theme';
11
+ import { useColorScheme } from '@/hooks/useColorScheme';
12
+
11
13
  const LIGHT_THEME: Theme = {
12
- ...DefaultTheme,
13
- colors: NAV_THEME.light,
14
+ ...DefaultTheme,
15
+ colors: NAV_THEME.light,
14
16
  };
15
17
  const DARK_THEME: Theme = {
16
- ...DarkTheme,
17
- colors: NAV_THEME.dark,
18
+ ...DarkTheme,
19
+ colors: NAV_THEME.dark,
18
20
  };
19
21
  export { ErrorBoundary } from 'expo-router';
22
+ /**
23
+ * Root layout component for the application.
24
+ * This component sets up the theme provider and status bar style based on the user's color scheme preference
25
+ * @returns The root layout component.
26
+ */
20
27
  export default function RootLayout() {
21
- const hasMounted = React.useRef(false);
22
- const { colorScheme, isDarkColorScheme } = useColorScheme();
23
- const [isColorSchemeLoaded, setIsColorSchemeLoaded] = React.useState(false);
24
- useIsomorphicLayoutEffect(() => {
25
- if (hasMounted.current) {
26
- return;
27
- }
28
- if (Platform.OS === 'web') {
29
- // Adds the background color to the html element to prevent white background on overscroll.
30
- document.documentElement.classList.add('bg-background');
31
- }
32
- setIsColorSchemeLoaded(true);
33
- hasMounted.current = true;
34
- }, []);
35
- if (!isColorSchemeLoaded) {
36
- return null;
37
- }
38
- return (
39
- <ThemeProvider value={isDarkColorScheme ? DARK_THEME : LIGHT_THEME}>
40
- <StatusBar style={isDarkColorScheme ? 'light' : 'dark'} />
41
- <Stack />
42
- </ThemeProvider>
43
- );
28
+ const hasMounted = React.useRef(false);
29
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
+ const { colorScheme, isDarkColorScheme } = useColorScheme();
31
+ const [isColorSchemeLoaded, setIsColorSchemeLoaded] = React.useState(false);
32
+ useIsomorphicLayoutEffect(() => {
33
+ if (hasMounted.current) {
34
+ return;
35
+ }
36
+ if (Platform.OS === 'web') {
37
+ // Adds the background color to the html element to prevent white background on overscroll.
38
+ document.documentElement.classList.add('bg-background');
39
+ }
40
+ setIsColorSchemeLoaded(true);
41
+ hasMounted.current = true;
42
+ }, []);
43
+ if (!isColorSchemeLoaded) {
44
+ return null;
45
+ }
46
+
47
+ return (
48
+ <ThemeProvider value={isDarkColorScheme ? DARK_THEME : LIGHT_THEME}>
49
+ <StatusBar style={isDarkColorScheme ? 'light' : 'dark'} />
50
+ <Stack />
51
+ </ThemeProvider>
52
+ );
44
53
  }
45
54
  const useIsomorphicLayoutEffect = Platform.OS === 'web' && typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;
@@ -1,9 +1,10 @@
1
1
  module.exports = function(api) {
2
- api.cache(true);
2
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
3
+ api.cache(true);
3
4
 
4
- return {
5
- presets: [["babel-preset-expo", {
6
- jsxImportSource: "nativewind"
7
- }], "nativewind/babel"],
8
- };
5
+ return {
6
+ presets: [['babel-preset-expo', {
7
+ jsxImportSource: 'nativewind'
8
+ }], 'nativewind/babel'],
9
+ };
9
10
  };
@@ -0,0 +1,52 @@
1
+ import { PropsWithChildren, useState } from 'react';
2
+ import { StyleSheet, TouchableOpacity } from 'react-native';
3
+
4
+ import { ThemedText } from '@/components/ThemedText';
5
+ import { ThemedView } from '@/components/ThemedView';
6
+ import { IconSymbol } from '@/components/ui/IconSymbol';
7
+ import { colors } from '@/constants/Colors';
8
+ import { useColorScheme } from '@/hooks/useColorScheme';
9
+
10
+ /**
11
+ * Renders a collapsible section with a heading and content.
12
+ * @param root0 - The props for the collapsible component.
13
+ * @param root0.children - The content to display when the section is expanded.
14
+ * @param root0.title - The title of the collapsible section.
15
+ * @returns The collapsible component.
16
+ */
17
+ export function Collapsible({ children, title }: PropsWithChildren & { title: string }) {
18
+ const [isOpen, setIsOpen] = useState(false);
19
+ const theme = useColorScheme() ?? 'light';
20
+
21
+ return (
22
+ <ThemedView>
23
+ <TouchableOpacity
24
+ style={styles.heading}
25
+ onPress={() => setIsOpen((value) => !value)}
26
+ activeOpacity={0.8}>
27
+ <IconSymbol
28
+ name="chevron.right"
29
+ size={18}
30
+ weight="medium"
31
+ color={theme === 'light' ? colors.light.icon : colors.dark.icon}
32
+ style={{ transform: [{ rotate: isOpen ? '90deg' : '0deg' }] }}
33
+ />
34
+
35
+ <ThemedText type="defaultSemiBold">{title}</ThemedText>
36
+ </TouchableOpacity>
37
+ {isOpen && <ThemedView style={styles.content}>{children}</ThemedView>}
38
+ </ThemedView>
39
+ );
40
+ }
41
+
42
+ const styles = StyleSheet.create({
43
+ heading: {
44
+ flexDirection: 'row',
45
+ alignItems: 'center',
46
+ gap: 6,
47
+ },
48
+ content: {
49
+ marginTop: 6,
50
+ marginLeft: 24,
51
+ },
52
+ });
@@ -0,0 +1,32 @@
1
+ import { Href, Link } from 'expo-router';
2
+ import { openBrowserAsync } from 'expo-web-browser';
3
+ import { type ComponentProps } from 'react';
4
+ import { Platform } from 'react-native';
5
+
6
+ type Props = Omit<ComponentProps<typeof Link>, 'href'> & { href: Href & string };
7
+
8
+ /**
9
+ * Renders an external link that opens in an in-app browser on native platforms.
10
+ * @param root0 - The props for the external link component.
11
+ * @param root0.href - The URL to link to.
12
+ * @param root0.rest - Additional props for the link component.
13
+ * @returns The external link component.
14
+ */
15
+ export function ExternalLink({ href, ...rest }: Props) {
16
+ return (
17
+ <Link
18
+ target="_blank"
19
+ {...rest}
20
+ href={href}
21
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
22
+ onPress={async (event) => {
23
+ if (Platform.OS !== 'web') {
24
+ // Prevent the default behavior of linking to the default browser on native.
25
+ event.preventDefault();
26
+ // Open the link in an in-app browser.
27
+ await openBrowserAsync(href);
28
+ }
29
+ }}
30
+ />
31
+ );
32
+ }
@@ -0,0 +1,24 @@
1
+ import { BottomTabBarButtonProps } from '@react-navigation/bottom-tabs';
2
+ import { PlatformPressable } from '@react-navigation/elements';
3
+ import * as Haptics from 'expo-haptics';
4
+
5
+ /**
6
+ * Renders a tab button with haptic feedback on press.
7
+ * @param props - The props for the tab button.
8
+ * @returns The tab button component with haptic feedback.
9
+ */
10
+ export function HapticTab(props: BottomTabBarButtonProps) {
11
+ return (
12
+ <PlatformPressable
13
+ {...props}
14
+ onPressIn={(ev) => {
15
+ if (process.env.EXPO_OS === 'ios') {
16
+ // Add a soft haptic feedback when pressing down on the tabs.
17
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
18
+ Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
19
+ }
20
+ props.onPressIn?.(ev);
21
+ }}
22
+ />
23
+ );
24
+ }