@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,37 @@
1
+ import React from "react";
2
+ import { StyleSheet, Text, View } from "react-native";
3
+ import { SafeAreaView } from "react-native-safe-area-context";
4
+
5
+ export default function HomeScreen() {
6
+ return (
7
+ <SafeAreaView style={styles.safeArea}>
8
+ <View style={styles.container}>
9
+ <Text style={styles.title}>{{projectName}}</Text>
10
+ <Text style={styles.subtitle}>Your app starts here.</Text>
11
+ </View>
12
+ </SafeAreaView>
13
+ );
14
+ }
15
+
16
+ const styles = StyleSheet.create({
17
+ safeArea: {
18
+ flex: 1,
19
+ backgroundColor: "#F7F7F9",
20
+ },
21
+ container: {
22
+ flex: 1,
23
+ alignItems: "center",
24
+ justifyContent: "center",
25
+ paddingHorizontal: 24,
26
+ },
27
+ title: {
28
+ fontSize: 32,
29
+ fontWeight: "700",
30
+ color: "#111827",
31
+ marginBottom: 8,
32
+ },
33
+ subtitle: {
34
+ fontSize: 16,
35
+ color: "#6B7280",
36
+ },
37
+ });
@@ -0,0 +1,170 @@
1
+ import { router } from "expo-router";
2
+ import React, { useRef, useState } from "react";
3
+ import {
4
+ FlatList,
5
+ Image,
6
+ ImageSourcePropType,
7
+ Pressable,
8
+ StyleSheet,
9
+ Text,
10
+ useWindowDimensions,
11
+ View,
12
+ ViewToken,
13
+ } from "react-native";
14
+ import { SafeAreaView } from "react-native-safe-area-context";
15
+
16
+ type Slide = {
17
+ id: string;
18
+ title: string;
19
+ description: string;
20
+ image: ImageSourcePropType;
21
+ };
22
+
23
+ const slides: Slide[] = [
24
+ {
25
+ id: "1",
26
+ title: "Welcome to RN Starter Kit",
27
+ description: "Kickstart your app with Expo and a clean production-ready baseline.",
28
+ image: require("../assets/images/react-logo.png"),
29
+ },
30
+ {
31
+ id: "2",
32
+ title: "Built for Real Projects",
33
+ description: "State, auth, API layers, and folder structure are ready for scaling.",
34
+ image: require("../assets/images/partial-react-logo.png"),
35
+ },
36
+ {
37
+ id: "3",
38
+ title: "Customize and Ship",
39
+ description: "Replace this screen with your own brand and ship faster.",
40
+ image: require("../assets/images/icon.png"),
41
+ },
42
+ ];
43
+
44
+ export default function WelcomeScreen() {
45
+ const { width } = useWindowDimensions();
46
+ const [activeIndex, setActiveIndex] = useState(0);
47
+ const listRef = useRef<FlatList<Slide>>(null);
48
+
49
+ const onViewableItemsChanged = useRef(
50
+ ({ viewableItems }: { viewableItems: Array<ViewToken> }) => {
51
+ if (viewableItems[0]?.index != null) {
52
+ setActiveIndex(viewableItems[0].index);
53
+ }
54
+ },
55
+ ).current;
56
+
57
+ const viewabilityConfig = useRef({ viewAreaCoveragePercentThreshold: 60 }).current;
58
+
59
+ const isLastSlide = activeIndex === slides.length - 1;
60
+
61
+ const goNext = () => {
62
+ if (isLastSlide) {
63
+ router.replace("/home");
64
+ return;
65
+ }
66
+ listRef.current?.scrollToIndex({ index: activeIndex + 1, animated: true });
67
+ };
68
+
69
+ return (
70
+ <SafeAreaView style={styles.safeArea}>
71
+ <FlatList
72
+ ref={listRef}
73
+ data={slides}
74
+ horizontal
75
+ pagingEnabled
76
+ bounces={false}
77
+ keyExtractor={(item) => item.id}
78
+ showsHorizontalScrollIndicator={false}
79
+ renderItem={({ item }) => (
80
+ <View style={[styles.slide, { width }]}>
81
+ <Image source={item.image} style={styles.image} resizeMode="contain" />
82
+ <Text style={styles.title}>{item.title}</Text>
83
+ <Text style={styles.description}>{item.description}</Text>
84
+ </View>
85
+ )}
86
+ onViewableItemsChanged={onViewableItemsChanged}
87
+ viewabilityConfig={viewabilityConfig}
88
+ />
89
+
90
+ <View style={styles.footer}>
91
+ <View style={styles.dotsRow}>
92
+ {slides.map((slide, index) => (
93
+ <View
94
+ key={slide.id}
95
+ style={[styles.dot, index === activeIndex && styles.dotActive]}
96
+ />
97
+ ))}
98
+ </View>
99
+
100
+ <Pressable style={styles.button} onPress={goNext}>
101
+ <Text style={styles.buttonLabel}>{isLastSlide ? "Get Started" : "Next"}</Text>
102
+ </Pressable>
103
+ </View>
104
+ </SafeAreaView>
105
+ );
106
+ }
107
+
108
+ const styles = StyleSheet.create({
109
+ safeArea: {
110
+ flex: 1,
111
+ backgroundColor: "#F7F7F9",
112
+ },
113
+ slide: {
114
+ flex: 1,
115
+ paddingHorizontal: 24,
116
+ justifyContent: "center",
117
+ alignItems: "center",
118
+ },
119
+ image: {
120
+ width: 220,
121
+ height: 220,
122
+ marginBottom: 28,
123
+ },
124
+ title: {
125
+ fontSize: 28,
126
+ fontWeight: "700",
127
+ color: "#111827",
128
+ textAlign: "center",
129
+ marginBottom: 12,
130
+ },
131
+ description: {
132
+ fontSize: 16,
133
+ lineHeight: 24,
134
+ color: "#4B5563",
135
+ textAlign: "center",
136
+ maxWidth: 320,
137
+ },
138
+ footer: {
139
+ paddingHorizontal: 24,
140
+ paddingBottom: 28,
141
+ gap: 20,
142
+ },
143
+ dotsRow: {
144
+ flexDirection: "row",
145
+ justifyContent: "center",
146
+ gap: 8,
147
+ },
148
+ dot: {
149
+ width: 8,
150
+ height: 8,
151
+ borderRadius: 999,
152
+ backgroundColor: "#D1D5DB",
153
+ },
154
+ dotActive: {
155
+ width: 24,
156
+ backgroundColor: "#111827",
157
+ },
158
+ button: {
159
+ height: 52,
160
+ borderRadius: 12,
161
+ backgroundColor: "#111827",
162
+ alignItems: "center",
163
+ justifyContent: "center",
164
+ },
165
+ buttonLabel: {
166
+ color: "#FFFFFF",
167
+ fontSize: 16,
168
+ fontWeight: "600",
169
+ },
170
+ });
@@ -26,6 +26,7 @@
26
26
  "favicon": "./assets/images/favicon.png"
27
27
  },
28
28
  "plugins": [
29
+ "expo-router",
29
30
  [
30
31
  "expo-splash-screen",
31
32
  {
@@ -40,7 +41,7 @@
40
41
  ]
41
42
  ],
42
43
  "experiments": {
43
- "reactCompiler": true
44
+ "typedRoutes": true
44
45
  }
45
46
  }
46
47
  }
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "{{projectName}}",
3
- "main": "node_modules/expo/AppEntry.js",
3
+ "main": "expo-router/entry",
4
4
  "version": "1.0.0",
5
5
  "scripts": {
6
6
  "start": "expo start",
7
7
  "android": "expo start --android",
8
8
  "ios": "expo start --ios",
9
9
  "web": "expo start --web",
10
- "lint": "expo lint"
10
+ "lint": "expo lint",
11
+ "format": "prettier --write .",
12
+ "type-check": "tsc --noEmit"
11
13
  },
12
14
  "dependencies": {
13
15
  "@expo/vector-icons": "^15.0.3",
@@ -20,6 +22,7 @@
20
22
  "expo-haptics": "~15.0.8",
21
23
  "expo-image": "~3.0.11",
22
24
  "expo-linking": "~8.0.11",
25
+ "expo-router": "~6.0.23",
23
26
  "expo-splash-screen": "~31.0.13",
24
27
  "expo-status-bar": "~3.0.9",
25
28
  "expo-symbols": "~1.0.8",
@@ -39,7 +42,8 @@
39
42
  "@types/react": "~19.1.0",
40
43
  "typescript": "~5.9.2",
41
44
  "eslint": "^9.25.0",
42
- "eslint-config-expo": "~10.0.0"
45
+ "eslint-config-expo": "~10.0.0",
46
+ "prettier": "^3.5.0"
43
47
  },
44
48
  "private": true
45
49
  }
@@ -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,24 +1,52 @@
1
- import React, { useContext } from "react";
2
- import { ActivityIndicator, View } from "react-native";
1
+ import React, { useContext, useEffect, useState } from "react";
2
+ import { ActivityIndicator } from "react-native";
3
+ import AsyncStorage from "@react-native-async-storage/async-storage";
3
4
  import { createNativeStackNavigator } from "@react-navigation/native-stack";
5
+ import ScreenLayout from "../components/layout/ScreenLayout";
4
6
  import { AuthContext } from "../context/AuthContext";
5
7
  import LoginScreen from "../screens/LoginScreen";
6
8
  import RegisterScreen from "../screens/RegisterScreen";
9
+ import WelcomeScreen from "../screens/WelcomeScreen";
7
10
  import BottomTabs from "./BottomTabs";
8
11
 
9
12
  const Stack = createNativeStackNavigator();
13
+ const WELCOME_SEEN_KEY = "@rnskit_has_seen_welcome";
10
14
 
11
15
  export default function ProtectedStack() {
12
16
  const { token, isHydrated } = useContext(AuthContext);
17
+ const [showWelcome, setShowWelcome] = useState(false);
18
+ const [isCheckingWelcome, setIsCheckingWelcome] = useState(true);
13
19
 
14
- if (!isHydrated) {
20
+ useEffect(() => {
21
+ const readWelcomeState = async () => {
22
+ try {
23
+ const seen = await AsyncStorage.getItem(WELCOME_SEEN_KEY);
24
+ setShowWelcome(seen !== "true");
25
+ } finally {
26
+ setIsCheckingWelcome(false);
27
+ }
28
+ };
29
+
30
+ void readWelcomeState();
31
+ }, []);
32
+
33
+ const handleWelcomeContinue = async () => {
34
+ await AsyncStorage.setItem(WELCOME_SEEN_KEY, "true");
35
+ setShowWelcome(false);
36
+ };
37
+
38
+ if (!isHydrated || isCheckingWelcome) {
15
39
  return (
16
- <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
40
+ <ScreenLayout centered padded={false}>
17
41
  <ActivityIndicator />
18
- </View>
42
+ </ScreenLayout>
19
43
  );
20
44
  }
21
45
 
46
+ if (showWelcome) {
47
+ return <WelcomeScreen onContinue={() => void handleWelcomeContinue()} />;
48
+ }
49
+
22
50
  return (
23
51
  <Stack.Navigator>
24
52
  {token ? (
@@ -1,14 +1,15 @@
1
1
  import React, { useContext } 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 { AuthContext } from "../context/AuthContext";
4
5
 
5
6
  export default function HomeScreen() {
6
7
  const { logout } = useContext(AuthContext);
7
8
 
8
9
  return (
9
- <View style={{ padding: 20 }}>
10
+ <ScreenLayout>
10
11
  <Text>Welcome Home!</Text>
11
12
  <Button title="Logout" onPress={() => void logout()} />
12
- </View>
13
+ </ScreenLayout>
13
14
  );
14
15
  }
@@ -1,28 +1,63 @@
1
1
  import React, { useContext, 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 { AuthContext } from "../context/AuthContext";
4
- import { loginApi } from "../api/authApi";
5
+ import { loginApi } from "../api";
5
6
 
6
7
  export default function LoginScreen() {
7
8
  const { login } = useContext(AuthContext);
8
9
  const [email, setEmail] = useState("");
9
10
  const [password, setPassword] = useState("");
11
+ const [error, setError] = useState("");
10
12
 
11
13
  const handleLogin = async () => {
12
- const token = await loginApi(email, password);
13
- await login(token);
14
+ try {
15
+ setError("");
16
+ const token = await loginApi(email, password);
17
+ await login(token);
18
+ } catch (err) {
19
+ setError(err instanceof Error ? err.message : "Login failed");
20
+ }
14
21
  };
15
22
 
16
23
  return (
17
- <View style={{ padding: 20 }}>
18
- <TextInput placeholder="Email" value={email} onChangeText={setEmail} />
24
+ <ScreenLayout>
25
+ <TextInput
26
+ placeholder="Email"
27
+ value={email}
28
+ onChangeText={setEmail}
29
+ autoCapitalize="none"
30
+ autoCorrect={false}
31
+ keyboardType="email-address"
32
+ placeholderTextColor="#888"
33
+ style={{
34
+ borderWidth: 1,
35
+ borderColor: "#ccc",
36
+ borderRadius: 8,
37
+ paddingHorizontal: 12,
38
+ paddingVertical: 10,
39
+ color: "#111",
40
+ marginBottom: 12,
41
+ }}
42
+ />
19
43
  <TextInput
20
44
  placeholder="Password"
21
45
  value={password}
22
46
  onChangeText={setPassword}
23
47
  secureTextEntry
48
+ placeholderTextColor="#888"
49
+ style={{
50
+ borderWidth: 1,
51
+ borderColor: "#ccc",
52
+ borderRadius: 8,
53
+ paddingHorizontal: 12,
54
+ paddingVertical: 10,
55
+ color: "#111",
56
+ marginBottom: 12,
57
+ }}
24
58
  />
59
+ {!!error && <Text style={{ color: "red", marginBottom: 8 }}>{error}</Text>}
25
60
  <Button title="Login" onPress={() => void handleLogin()} />
26
- </View>
61
+ </ScreenLayout>
27
62
  );
28
63
  }
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
- import { View, Text } from "react-native";
2
+ import { Text } from "react-native";
3
+ import ScreenLayout from "../components/layout/ScreenLayout";
3
4
 
4
5
  export default function ProfileScreen() {
5
6
  return (
6
- <View style={{ padding: 20 }}>
7
+ <ScreenLayout>
7
8
  <Text>This is the Profile Screen</Text>
8
- </View>
9
+ </ScreenLayout>
9
10
  );
10
11
  }
@@ -1,28 +1,63 @@
1
1
  import React, { useContext, 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 { AuthContext } from "../context/AuthContext";
4
- import { registerApi } from "../api/authApi";
5
+ import { registerApi } from "../api";
5
6
 
6
7
  export default function RegisterScreen() {
7
8
  const { login } = useContext(AuthContext);
8
9
  const [email, setEmail] = useState("");
9
10
  const [password, setPassword] = useState("");
11
+ const [error, setError] = useState("");
10
12
 
11
13
  const handleRegister = async () => {
12
- const token = await registerApi(email, password);
13
- await login(token);
14
+ try {
15
+ setError("");
16
+ const token = await registerApi(email, password);
17
+ await login(token);
18
+ } catch (err) {
19
+ setError(err instanceof Error ? err.message : "Registration failed");
20
+ }
14
21
  };
15
22
 
16
23
  return (
17
- <View style={{ padding: 20 }}>
18
- <TextInput placeholder="Email" value={email} onChangeText={setEmail} />
24
+ <ScreenLayout>
25
+ <TextInput
26
+ placeholder="Email"
27
+ value={email}
28
+ onChangeText={setEmail}
29
+ autoCapitalize="none"
30
+ autoCorrect={false}
31
+ keyboardType="email-address"
32
+ placeholderTextColor="#888"
33
+ style={{
34
+ borderWidth: 1,
35
+ borderColor: "#ccc",
36
+ borderRadius: 8,
37
+ paddingHorizontal: 12,
38
+ paddingVertical: 10,
39
+ color: "#111",
40
+ marginBottom: 12,
41
+ }}
42
+ />
19
43
  <TextInput
20
44
  placeholder="Password"
21
45
  value={password}
22
46
  onChangeText={setPassword}
23
47
  secureTextEntry
48
+ placeholderTextColor="#888"
49
+ style={{
50
+ borderWidth: 1,
51
+ borderColor: "#ccc",
52
+ borderRadius: 8,
53
+ paddingHorizontal: 12,
54
+ paddingVertical: 10,
55
+ color: "#111",
56
+ marginBottom: 12,
57
+ }}
24
58
  />
59
+ {!!error && <Text style={{ color: "red", marginBottom: 8 }}>{error}</Text>}
25
60
  <Button title="Register" onPress={() => void handleRegister()} />
26
- </View>
61
+ </ScreenLayout>
27
62
  );
28
63
  }
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
- import { View, Text } from "react-native";
2
+ import { Text } from "react-native";
3
+ import ScreenLayout from "../components/layout/ScreenLayout";
3
4
 
4
5
  export default function SettingsScreen() {
5
6
  return (
6
- <View style={{ padding: 20 }}>
7
+ <ScreenLayout>
7
8
  <Text>This is the Settings Screen</Text>
8
- </View>
9
+ </ScreenLayout>
9
10
  );
10
11
  }