@highbeek/create-rnstarterkit 1.0.2-beta.5 → 1.1.0

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 (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +268 -0
  3. package/dist/bin/create-rnstarterkit.js +205 -7
  4. package/dist/src/generators/appGenerator.js +2474 -58
  5. package/dist/src/generators/codeGenerator.js +289 -0
  6. package/dist/templates/cli-base/App.tsx +199 -21
  7. package/dist/templates/cli-base/assets/images/icon.png +0 -0
  8. package/dist/templates/cli-base/assets/images/partial-react-logo.png +0 -0
  9. package/dist/templates/cli-base/assets/images/react-logo.png +0 -0
  10. package/dist/templates/cli-base/babel.config.js +1 -0
  11. package/dist/templates/cli-base/ios/BaseApp.xcodeproj/project.pbxproj +6 -0
  12. package/dist/templates/cli-base/ios/Podfile +5 -0
  13. package/dist/templates/cli-base/jest.config.js +4 -0
  14. package/dist/templates/cli-base/package.json +7 -4
  15. package/dist/templates/cli-base/tsconfig.json +1 -0
  16. package/dist/templates/expo-base/app/_layout.tsx +7 -18
  17. package/dist/templates/expo-base/app/home.tsx +37 -0
  18. package/dist/templates/expo-base/app/index.tsx +170 -0
  19. package/dist/templates/expo-base/app.json +2 -1
  20. package/dist/templates/expo-base/package.json +7 -3
  21. package/dist/templates/optional/auth-context/components/layout/ScreenLayout.tsx +46 -0
  22. package/dist/templates/optional/auth-context/navigation/ProtectedStack.tsx +33 -5
  23. package/dist/templates/optional/auth-context/screens/HomeScreen.tsx +4 -3
  24. package/dist/templates/optional/auth-context/screens/LoginScreen.tsx +42 -7
  25. package/dist/templates/optional/auth-context/screens/ProfileScreen.tsx +4 -3
  26. package/dist/templates/optional/auth-context/screens/RegisterScreen.tsx +42 -7
  27. package/dist/templates/optional/auth-context/screens/SettingsScreen.tsx +4 -3
  28. package/dist/templates/optional/auth-context/screens/WelcomeScreen.tsx +174 -0
  29. package/dist/templates/optional/auth-redux/components/layout/ScreenLayout.tsx +46 -0
  30. package/dist/templates/optional/auth-redux/navigation/ProtectedStack.tsx +39 -2
  31. package/dist/templates/optional/auth-redux/screens/HomeScreen.tsx +4 -3
  32. package/dist/templates/optional/auth-redux/screens/LoginScreen.tsx +43 -8
  33. package/dist/templates/optional/auth-redux/screens/ProfileScreen.tsx +7 -10
  34. package/dist/templates/optional/auth-redux/screens/RegisterScreen.tsx +61 -11
  35. package/dist/templates/optional/auth-redux/screens/SettingsScreen.tsx +6 -9
  36. package/dist/templates/optional/auth-redux/screens/WelcomeScreen.tsx +174 -0
  37. package/dist/templates/optional/auth-zustand/components/layout/ScreenLayout.tsx +46 -0
  38. package/dist/templates/optional/auth-zustand/navigation/ProtectedStack.tsx +34 -6
  39. package/dist/templates/optional/auth-zustand/screens/HomeScreen.tsx +4 -3
  40. package/dist/templates/optional/auth-zustand/screens/LoginScreen.tsx +42 -7
  41. package/dist/templates/optional/auth-zustand/screens/ProfileScreen.tsx +4 -3
  42. package/dist/templates/optional/auth-zustand/screens/RegisterScreen.tsx +42 -7
  43. package/dist/templates/optional/auth-zustand/screens/SettingsScreen.tsx +4 -3
  44. package/dist/templates/optional/auth-zustand/screens/WelcomeScreen.tsx +174 -0
  45. package/dist/templates/optional/ci/.github/workflows/ci.yml +32 -0
  46. package/dist/templates/optional/error-boundary/components/ErrorBoundary.tsx +83 -0
  47. package/dist/templates/optional/formik/components/formik/FormikInput.tsx +45 -0
  48. package/dist/templates/optional/formik/components/formik/LoginForm.tsx +60 -0
  49. package/dist/templates/optional/formik/schemas/auth.schema.ts +17 -0
  50. package/dist/templates/optional/i18n/src/i18n/hooks/useAppTranslation.ts +28 -0
  51. package/dist/templates/optional/i18n/src/i18n/i18n.ts +30 -0
  52. package/dist/templates/optional/i18n/src/i18n/locales/en.json +32 -0
  53. package/dist/templates/optional/i18n/src/i18n/locales/es.json +32 -0
  54. package/dist/templates/optional/maestro/.maestro/flows/01_welcome.yaml +5 -0
  55. package/dist/templates/optional/maestro-auth/.maestro/flows/01_welcome.yaml +5 -0
  56. package/dist/templates/optional/maestro-auth/.maestro/flows/02_login.yaml +13 -0
  57. package/dist/templates/optional/maestro-auth/.maestro/flows/03_logout.yaml +16 -0
  58. package/dist/templates/optional/mmkv/utils/storage.ts +17 -0
  59. package/dist/templates/optional/react-hook-form/components/rhf/LoginForm.tsx +63 -0
  60. package/dist/templates/optional/react-hook-form/components/rhf/RHFInput.tsx +50 -0
  61. package/dist/templates/optional/react-hook-form/schemas/auth.schema.ts +29 -0
  62. package/dist/templates/optional/react-query/hooks/useAppMutation.ts +16 -0
  63. package/dist/templates/optional/react-query/hooks/useAppQuery.ts +12 -0
  64. package/dist/templates/optional/react-query/services/queryClient.ts +14 -0
  65. package/dist/templates/optional/redux/store/hooks.ts +6 -0
  66. package/dist/templates/optional/redux/store/store.ts +11 -0
  67. package/dist/templates/optional/sentry/src/utils/sentry.ts +24 -0
  68. package/dist/templates/optional/swr/hooks/useSWRFetch.ts +14 -0
  69. package/dist/templates/optional/swr/providers/SWRProvider.tsx +21 -0
  70. package/dist/templates/optional/tsconfig.json +17 -0
  71. package/dist/templates/optional/zustand/store/appStore.ts +13 -0
  72. package/package.json +40 -5
  73. package/dist/templates/expo-base/App.tsx +0 -32
  74. package/dist/templates/expo-base/app/(tabs)/_layout.tsx +0 -35
  75. package/dist/templates/expo-base/app/(tabs)/explore.tsx +0 -112
  76. package/dist/templates/expo-base/app/(tabs)/index.tsx +0 -98
  77. package/dist/templates/expo-base/app/modal.tsx +0 -29
  78. package/dist/templates/expo-base/components/external-link.tsx +0 -25
  79. package/dist/templates/expo-base/components/haptic-tab.tsx +0 -18
  80. package/dist/templates/expo-base/components/hello-wave.tsx +0 -19
  81. package/dist/templates/expo-base/components/parallax-scroll-view.tsx +0 -79
  82. package/dist/templates/expo-base/components/themed-text.tsx +0 -60
  83. package/dist/templates/expo-base/components/themed-view.tsx +0 -14
  84. package/dist/templates/expo-base/components/ui/collapsible.tsx +0 -45
  85. package/dist/templates/expo-base/components/ui/icon-symbol.ios.tsx +0 -32
  86. package/dist/templates/expo-base/components/ui/icon-symbol.tsx +0 -41
  87. package/dist/templates/expo-base/constants/theme.ts +0 -53
  88. package/dist/templates/expo-base/hooks/use-color-scheme.ts +0 -1
  89. package/dist/templates/expo-base/hooks/use-color-scheme.web.ts +0 -21
  90. package/dist/templates/expo-base/hooks/use-theme-color.ts +0 -21
  91. package/dist/templates/expo-base/scripts/reset-project.js +0 -112
  92. package/dist/templates/optional/apiClient/api/client.axios.ts +0 -124
  93. /package/dist/templates/optional/auth-context/api/{authApi.ts → endpoints/auth.ts} +0 -0
  94. /package/dist/templates/optional/auth-redux/api/{authApi.ts → endpoints/auth.ts} +0 -0
  95. /package/dist/templates/optional/auth-zustand/api/{authApi.ts → endpoints/auth.ts} +0 -0
@@ -0,0 +1,174 @@
1
+ import React, { useRef, useState } from "react";
2
+ import {
3
+ FlatList,
4
+ Image,
5
+ ImageSourcePropType,
6
+ Pressable,
7
+ StyleSheet,
8
+ Text,
9
+ useWindowDimensions,
10
+ View,
11
+ ViewToken,
12
+ } from "react-native";
13
+ import { SafeAreaView } from "react-native-safe-area-context";
14
+
15
+ type WelcomeScreenProps = {
16
+ onContinue: () => void;
17
+ };
18
+
19
+ type Slide = {
20
+ id: string;
21
+ title: string;
22
+ description: string;
23
+ image: ImageSourcePropType;
24
+ };
25
+
26
+ const slides: Slide[] = [
27
+ {
28
+ id: "1",
29
+ title: "Welcome to RN Starter Kit",
30
+ description: "Build faster with a clean, production-ready app foundation.",
31
+ image: require("../assets/images/react-logo.png"),
32
+ },
33
+ {
34
+ id: "2",
35
+ title: "Structure That Scales",
36
+ description: "Auth, state, and API setup are organized for real-world apps.",
37
+ image: require("../assets/images/partial-react-logo.png"),
38
+ },
39
+ {
40
+ id: "3",
41
+ title: "Make It Yours",
42
+ description: "Swap this welcome flow with your own brand and product journey.",
43
+ image: require("../assets/images/icon.png"),
44
+ },
45
+ ];
46
+
47
+ export default function WelcomeScreen({ onContinue }: WelcomeScreenProps) {
48
+ const { width } = useWindowDimensions();
49
+ const [activeIndex, setActiveIndex] = useState(0);
50
+ const listRef = useRef<FlatList<Slide>>(null);
51
+
52
+ const onViewableItemsChanged = useRef(
53
+ ({ viewableItems }: { viewableItems: Array<ViewToken> }) => {
54
+ if (viewableItems[0]?.index != null) {
55
+ setActiveIndex(viewableItems[0].index);
56
+ }
57
+ },
58
+ ).current;
59
+
60
+ const viewabilityConfig = useRef({ viewAreaCoveragePercentThreshold: 60 }).current;
61
+
62
+ const handleNext = () => {
63
+ const nextIndex = activeIndex + 1;
64
+ if (nextIndex < slides.length) {
65
+ listRef.current?.scrollToIndex({ index: nextIndex, animated: true });
66
+ return;
67
+ }
68
+ onContinue();
69
+ };
70
+
71
+ const isLastSlide = activeIndex === slides.length - 1;
72
+
73
+ return (
74
+ <SafeAreaView style={styles.safeArea}>
75
+ <FlatList
76
+ ref={listRef}
77
+ data={slides}
78
+ horizontal
79
+ pagingEnabled
80
+ bounces={false}
81
+ keyExtractor={(item) => item.id}
82
+ showsHorizontalScrollIndicator={false}
83
+ renderItem={({ item }) => (
84
+ <View style={[styles.slide, { width }]}>
85
+ <Image source={item.image} style={styles.image} resizeMode="contain" />
86
+ <Text style={styles.title}>{item.title}</Text>
87
+ <Text style={styles.description}>{item.description}</Text>
88
+ </View>
89
+ )}
90
+ onViewableItemsChanged={onViewableItemsChanged}
91
+ viewabilityConfig={viewabilityConfig}
92
+ />
93
+
94
+ <View style={styles.footer}>
95
+ <View style={styles.dotsRow}>
96
+ {slides.map((slide, index) => (
97
+ <View
98
+ key={slide.id}
99
+ style={[styles.dot, index === activeIndex && styles.dotActive]}
100
+ />
101
+ ))}
102
+ </View>
103
+
104
+ <Pressable style={styles.button} onPress={handleNext}>
105
+ <Text style={styles.buttonLabel}>{isLastSlide ? "Get Started" : "Next"}</Text>
106
+ </Pressable>
107
+ </View>
108
+ </SafeAreaView>
109
+ );
110
+ }
111
+
112
+ const styles = StyleSheet.create({
113
+ safeArea: {
114
+ flex: 1,
115
+ backgroundColor: "#F7F7F9",
116
+ },
117
+ slide: {
118
+ flex: 1,
119
+ paddingHorizontal: 24,
120
+ justifyContent: "center",
121
+ alignItems: "center",
122
+ },
123
+ image: {
124
+ width: 220,
125
+ height: 220,
126
+ marginBottom: 28,
127
+ },
128
+ title: {
129
+ fontSize: 28,
130
+ fontWeight: "700",
131
+ color: "#111827",
132
+ textAlign: "center",
133
+ marginBottom: 12,
134
+ },
135
+ description: {
136
+ fontSize: 16,
137
+ lineHeight: 24,
138
+ color: "#4B5563",
139
+ textAlign: "center",
140
+ maxWidth: 320,
141
+ },
142
+ footer: {
143
+ paddingHorizontal: 24,
144
+ paddingBottom: 28,
145
+ gap: 20,
146
+ },
147
+ dotsRow: {
148
+ flexDirection: "row",
149
+ justifyContent: "center",
150
+ gap: 8,
151
+ },
152
+ dot: {
153
+ width: 8,
154
+ height: 8,
155
+ borderRadius: 999,
156
+ backgroundColor: "#D1D5DB",
157
+ },
158
+ dotActive: {
159
+ width: 24,
160
+ backgroundColor: "#111827",
161
+ },
162
+ button: {
163
+ height: 52,
164
+ borderRadius: 12,
165
+ backgroundColor: "#111827",
166
+ alignItems: "center",
167
+ justifyContent: "center",
168
+ },
169
+ buttonLabel: {
170
+ color: "#FFFFFF",
171
+ fontSize: 16,
172
+ fontWeight: "600",
173
+ },
174
+ });
@@ -0,0 +1,46 @@
1
+ import React from "react";
2
+ import { StyleProp, StyleSheet, ViewStyle } from "react-native";
3
+ import { Edge, SafeAreaView } from "react-native-safe-area-context";
4
+
5
+ type ScreenLayoutProps = {
6
+ children: React.ReactNode;
7
+ padded?: boolean;
8
+ centered?: boolean;
9
+ edges?: Edge[];
10
+ style?: StyleProp<ViewStyle>;
11
+ };
12
+
13
+ export default function ScreenLayout({
14
+ children,
15
+ padded = true,
16
+ centered = false,
17
+ edges = ["top", "left", "right"],
18
+ style,
19
+ }: ScreenLayoutProps) {
20
+ return (
21
+ <SafeAreaView
22
+ edges={edges}
23
+ style={[
24
+ styles.container,
25
+ padded && styles.padded,
26
+ centered && styles.centered,
27
+ style,
28
+ ]}
29
+ >
30
+ {children}
31
+ </SafeAreaView>
32
+ );
33
+ }
34
+
35
+ const styles = StyleSheet.create({
36
+ container: {
37
+ flex: 1,
38
+ },
39
+ padded: {
40
+ padding: 20,
41
+ },
42
+ centered: {
43
+ alignItems: "center",
44
+ justifyContent: "center",
45
+ },
46
+ });
@@ -1,15 +1,52 @@
1
- import React from "react";
1
+ import React, { useEffect, useState } from "react";
2
+ import { ActivityIndicator } from "react-native";
3
+ import AsyncStorage from "@react-native-async-storage/async-storage";
2
4
  import { createNativeStackNavigator } from "@react-navigation/native-stack";
3
5
  import { useSelector } from "react-redux";
4
- import type { RootState } from "../store/store";
6
+ import ScreenLayout from "../components/layout/ScreenLayout";
5
7
  import LoginScreen from "../screens/LoginScreen";
6
8
  import RegisterScreen from "../screens/RegisterScreen";
9
+ import WelcomeScreen from "../screens/WelcomeScreen";
10
+ import type { RootState } from "../store/store";
7
11
  import BottomTabs from "./BottomTabs";
8
12
 
9
13
  const Stack = createNativeStackNavigator();
14
+ const WELCOME_SEEN_KEY = "@rnskit_has_seen_welcome";
10
15
 
11
16
  export default function ProtectedStack() {
12
17
  const token = useSelector((state: RootState) => state.auth.token);
18
+ const [showWelcome, setShowWelcome] = useState(false);
19
+ const [isCheckingWelcome, setIsCheckingWelcome] = useState(true);
20
+
21
+ useEffect(() => {
22
+ const readWelcomeState = async () => {
23
+ try {
24
+ const seen = await AsyncStorage.getItem(WELCOME_SEEN_KEY);
25
+ setShowWelcome(seen !== "true");
26
+ } finally {
27
+ setIsCheckingWelcome(false);
28
+ }
29
+ };
30
+
31
+ void readWelcomeState();
32
+ }, []);
33
+
34
+ const handleWelcomeContinue = async () => {
35
+ await AsyncStorage.setItem(WELCOME_SEEN_KEY, "true");
36
+ setShowWelcome(false);
37
+ };
38
+
39
+ if (isCheckingWelcome) {
40
+ return (
41
+ <ScreenLayout centered padded={false}>
42
+ <ActivityIndicator />
43
+ </ScreenLayout>
44
+ );
45
+ }
46
+
47
+ if (showWelcome) {
48
+ return <WelcomeScreen onContinue={() => void handleWelcomeContinue()} />;
49
+ }
13
50
 
14
51
  return (
15
52
  <Stack.Navigator>
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- import { View, Text, Button } from "react-native";
2
+ import { Text, Button } from "react-native";
3
+ import ScreenLayout from "../components/layout/ScreenLayout";
3
4
  import { useDispatch } from "react-redux";
4
5
  import { logout } from "../store/authSlice";
5
6
 
@@ -7,9 +8,9 @@ export default function HomeScreen() {
7
8
  const dispatch = useDispatch();
8
9
 
9
10
  return (
10
- <View style={{ padding: 20 }}>
11
+ <ScreenLayout>
11
12
  <Text>Welcome Home!</Text>
12
13
  <Button title="Logout" onPress={() => dispatch(logout())} />
13
- </View>
14
+ </ScreenLayout>
14
15
  );
15
16
  }
@@ -1,29 +1,64 @@
1
1
  import React, { useState } from "react";
2
- import { View, TextInput, Button } from "react-native";
2
+ import { TextInput, Button, Text } from "react-native";
3
+ import ScreenLayout from "../components/layout/ScreenLayout";
3
4
  import { useDispatch } from "react-redux";
4
5
  import { login } from "../store/authSlice";
5
- import { loginApi } from "../api/authApi";
6
+ import { loginApi } from "../api";
6
7
 
7
8
  export default function LoginScreen() {
8
9
  const dispatch = useDispatch();
9
10
  const [email, setEmail] = useState("");
10
11
  const [password, setPassword] = useState("");
12
+ const [error, setError] = useState("");
11
13
 
12
14
  const handleLogin = async () => {
13
- const token = await loginApi(email, password);
14
- dispatch(login(token));
15
+ try {
16
+ setError("");
17
+ const token = await loginApi(email, password);
18
+ dispatch(login(token));
19
+ } catch (err) {
20
+ setError(err instanceof Error ? err.message : "Login failed");
21
+ }
15
22
  };
16
23
 
17
24
  return (
18
- <View>
19
- <TextInput placeholder="Email" value={email} onChangeText={setEmail} />
25
+ <ScreenLayout>
26
+ <TextInput
27
+ placeholder="Email"
28
+ value={email}
29
+ onChangeText={setEmail}
30
+ autoCapitalize="none"
31
+ autoCorrect={false}
32
+ keyboardType="email-address"
33
+ placeholderTextColor="#888"
34
+ style={{
35
+ borderWidth: 1,
36
+ borderColor: "#ccc",
37
+ borderRadius: 8,
38
+ paddingHorizontal: 12,
39
+ paddingVertical: 10,
40
+ color: "#111",
41
+ marginBottom: 12,
42
+ }}
43
+ />
20
44
  <TextInput
21
45
  placeholder="Password"
22
46
  value={password}
23
47
  onChangeText={setPassword}
24
48
  secureTextEntry
49
+ placeholderTextColor="#888"
50
+ style={{
51
+ borderWidth: 1,
52
+ borderColor: "#ccc",
53
+ borderRadius: 8,
54
+ paddingHorizontal: 12,
55
+ paddingVertical: 10,
56
+ color: "#111",
57
+ marginBottom: 12,
58
+ }}
25
59
  />
26
- <Button title="Login" onPress={handleLogin} />
27
- </View>
60
+ {!!error && <Text style={{ color: "red", marginBottom: 8 }}>{error}</Text>}
61
+ <Button title="Login" onPress={() => void handleLogin()} />
62
+ </ScreenLayout>
28
63
  );
29
64
  }
@@ -1,14 +1,11 @@
1
- import { StyleSheet, Text, View } from 'react-native'
2
- import React from 'react'
1
+ import React from "react";
2
+ import { Text } from "react-native";
3
+ import ScreenLayout from "../components/layout/ScreenLayout";
3
4
 
4
- const ProfileScreen = () => {
5
+ export default function ProfileScreen() {
5
6
  return (
6
- <View>
7
+ <ScreenLayout>
7
8
  <Text>ProfileScreen</Text>
8
- </View>
9
- )
9
+ </ScreenLayout>
10
+ );
10
11
  }
11
-
12
- export default ProfileScreen
13
-
14
- const styles = StyleSheet.create({})
@@ -1,14 +1,64 @@
1
- import { StyleSheet, Text, View } from "react-native";
2
- import React from "react";
1
+ import React, { useState } from "react";
2
+ import { TextInput, Button, Text } from "react-native";
3
+ import ScreenLayout from "../components/layout/ScreenLayout";
4
+ import { useDispatch } from "react-redux";
5
+ import { login } from "../store/authSlice";
6
+ import { registerApi } from "../api";
3
7
 
4
- const RegisterScreen = () => {
5
- return (
6
- <View>
7
- <Text>RegisterScreen</Text>
8
- </View>
9
- );
10
- };
8
+ export default function RegisterScreen() {
9
+ const dispatch = useDispatch();
10
+ const [email, setEmail] = useState("");
11
+ const [password, setPassword] = useState("");
12
+ const [error, setError] = useState("");
11
13
 
12
- export default RegisterScreen;
14
+ const handleRegister = async () => {
15
+ try {
16
+ setError("");
17
+ const token = await registerApi(email, password);
18
+ dispatch(login(token));
19
+ } catch (err) {
20
+ setError(err instanceof Error ? err.message : "Registration failed");
21
+ }
22
+ };
13
23
 
14
- const styles = StyleSheet.create({});
24
+ return (
25
+ <ScreenLayout>
26
+ <TextInput
27
+ placeholder="Email"
28
+ value={email}
29
+ onChangeText={setEmail}
30
+ autoCapitalize="none"
31
+ autoCorrect={false}
32
+ keyboardType="email-address"
33
+ placeholderTextColor="#888"
34
+ style={{
35
+ borderWidth: 1,
36
+ borderColor: "#ccc",
37
+ borderRadius: 8,
38
+ paddingHorizontal: 12,
39
+ paddingVertical: 10,
40
+ color: "#111",
41
+ marginBottom: 12,
42
+ }}
43
+ />
44
+ <TextInput
45
+ placeholder="Password"
46
+ value={password}
47
+ onChangeText={setPassword}
48
+ secureTextEntry
49
+ placeholderTextColor="#888"
50
+ style={{
51
+ borderWidth: 1,
52
+ borderColor: "#ccc",
53
+ borderRadius: 8,
54
+ paddingHorizontal: 12,
55
+ paddingVertical: 10,
56
+ color: "#111",
57
+ marginBottom: 12,
58
+ }}
59
+ />
60
+ {!!error && <Text style={{ color: "red", marginBottom: 8 }}>{error}</Text>}
61
+ <Button title="Register" onPress={() => void handleRegister()} />
62
+ </ScreenLayout>
63
+ );
64
+ }
@@ -1,14 +1,11 @@
1
- import { StyleSheet, Text, View } from "react-native";
2
1
  import React from "react";
2
+ import { Text } from "react-native";
3
+ import ScreenLayout from "../components/layout/ScreenLayout";
3
4
 
4
- const SettingsScreen = () => {
5
+ export default function SettingsScreen() {
5
6
  return (
6
- <View>
7
+ <ScreenLayout>
7
8
  <Text>SettingsScreen</Text>
8
- </View>
9
+ </ScreenLayout>
9
10
  );
10
- };
11
-
12
- export default SettingsScreen;
13
-
14
- const styles = StyleSheet.create({});
11
+ }
@@ -0,0 +1,174 @@
1
+ import React, { useRef, useState } from "react";
2
+ import {
3
+ FlatList,
4
+ Image,
5
+ ImageSourcePropType,
6
+ Pressable,
7
+ StyleSheet,
8
+ Text,
9
+ useWindowDimensions,
10
+ View,
11
+ ViewToken,
12
+ } from "react-native";
13
+ import { SafeAreaView } from "react-native-safe-area-context";
14
+
15
+ type WelcomeScreenProps = {
16
+ onContinue: () => void;
17
+ };
18
+
19
+ type Slide = {
20
+ id: string;
21
+ title: string;
22
+ description: string;
23
+ image: ImageSourcePropType;
24
+ };
25
+
26
+ const slides: Slide[] = [
27
+ {
28
+ id: "1",
29
+ title: "Welcome to RN Starter Kit",
30
+ description: "Build faster with a clean, production-ready app foundation.",
31
+ image: require("../assets/images/react-logo.png"),
32
+ },
33
+ {
34
+ id: "2",
35
+ title: "Structure That Scales",
36
+ description: "Auth, state, and API setup are organized for real-world apps.",
37
+ image: require("../assets/images/partial-react-logo.png"),
38
+ },
39
+ {
40
+ id: "3",
41
+ title: "Make It Yours",
42
+ description: "Swap this welcome flow with your own brand and product journey.",
43
+ image: require("../assets/images/icon.png"),
44
+ },
45
+ ];
46
+
47
+ export default function WelcomeScreen({ onContinue }: WelcomeScreenProps) {
48
+ const { width } = useWindowDimensions();
49
+ const [activeIndex, setActiveIndex] = useState(0);
50
+ const listRef = useRef<FlatList<Slide>>(null);
51
+
52
+ const onViewableItemsChanged = useRef(
53
+ ({ viewableItems }: { viewableItems: Array<ViewToken> }) => {
54
+ if (viewableItems[0]?.index != null) {
55
+ setActiveIndex(viewableItems[0].index);
56
+ }
57
+ },
58
+ ).current;
59
+
60
+ const viewabilityConfig = useRef({ viewAreaCoveragePercentThreshold: 60 }).current;
61
+
62
+ const handleNext = () => {
63
+ const nextIndex = activeIndex + 1;
64
+ if (nextIndex < slides.length) {
65
+ listRef.current?.scrollToIndex({ index: nextIndex, animated: true });
66
+ return;
67
+ }
68
+ onContinue();
69
+ };
70
+
71
+ const isLastSlide = activeIndex === slides.length - 1;
72
+
73
+ return (
74
+ <SafeAreaView style={styles.safeArea}>
75
+ <FlatList
76
+ ref={listRef}
77
+ data={slides}
78
+ horizontal
79
+ pagingEnabled
80
+ bounces={false}
81
+ keyExtractor={(item) => item.id}
82
+ showsHorizontalScrollIndicator={false}
83
+ renderItem={({ item }) => (
84
+ <View style={[styles.slide, { width }]}>
85
+ <Image source={item.image} style={styles.image} resizeMode="contain" />
86
+ <Text style={styles.title}>{item.title}</Text>
87
+ <Text style={styles.description}>{item.description}</Text>
88
+ </View>
89
+ )}
90
+ onViewableItemsChanged={onViewableItemsChanged}
91
+ viewabilityConfig={viewabilityConfig}
92
+ />
93
+
94
+ <View style={styles.footer}>
95
+ <View style={styles.dotsRow}>
96
+ {slides.map((slide, index) => (
97
+ <View
98
+ key={slide.id}
99
+ style={[styles.dot, index === activeIndex && styles.dotActive]}
100
+ />
101
+ ))}
102
+ </View>
103
+
104
+ <Pressable style={styles.button} onPress={handleNext}>
105
+ <Text style={styles.buttonLabel}>{isLastSlide ? "Get Started" : "Next"}</Text>
106
+ </Pressable>
107
+ </View>
108
+ </SafeAreaView>
109
+ );
110
+ }
111
+
112
+ const styles = StyleSheet.create({
113
+ safeArea: {
114
+ flex: 1,
115
+ backgroundColor: "#F7F7F9",
116
+ },
117
+ slide: {
118
+ flex: 1,
119
+ paddingHorizontal: 24,
120
+ justifyContent: "center",
121
+ alignItems: "center",
122
+ },
123
+ image: {
124
+ width: 220,
125
+ height: 220,
126
+ marginBottom: 28,
127
+ },
128
+ title: {
129
+ fontSize: 28,
130
+ fontWeight: "700",
131
+ color: "#111827",
132
+ textAlign: "center",
133
+ marginBottom: 12,
134
+ },
135
+ description: {
136
+ fontSize: 16,
137
+ lineHeight: 24,
138
+ color: "#4B5563",
139
+ textAlign: "center",
140
+ maxWidth: 320,
141
+ },
142
+ footer: {
143
+ paddingHorizontal: 24,
144
+ paddingBottom: 28,
145
+ gap: 20,
146
+ },
147
+ dotsRow: {
148
+ flexDirection: "row",
149
+ justifyContent: "center",
150
+ gap: 8,
151
+ },
152
+ dot: {
153
+ width: 8,
154
+ height: 8,
155
+ borderRadius: 999,
156
+ backgroundColor: "#D1D5DB",
157
+ },
158
+ dotActive: {
159
+ width: 24,
160
+ backgroundColor: "#111827",
161
+ },
162
+ button: {
163
+ height: 52,
164
+ borderRadius: 12,
165
+ backgroundColor: "#111827",
166
+ alignItems: "center",
167
+ justifyContent: "center",
168
+ },
169
+ buttonLabel: {
170
+ color: "#FFFFFF",
171
+ fontSize: 16,
172
+ fontWeight: "600",
173
+ },
174
+ });