From 7eb8ccae48b0cc18a9dcaa9c3626a02df8e6d919 Mon Sep 17 00:00:00 2001 From: JustZvan Date: Fri, 6 Feb 2026 13:22:33 +0100 Subject: feat: initial commit! --- app/(auth)/signup.tsx | 185 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 app/(auth)/signup.tsx (limited to 'app/(auth)/signup.tsx') diff --git a/app/(auth)/signup.tsx b/app/(auth)/signup.tsx new file mode 100644 index 0000000..127ea9f --- /dev/null +++ b/app/(auth)/signup.tsx @@ -0,0 +1,185 @@ +import { Ionicons } from "@expo/vector-icons"; +import { router } from "expo-router"; +import { useState } from "react"; +import { + KeyboardAvoidingView, + Platform, + ScrollView, + StyleSheet, + Text, + TouchableOpacity, + View, +} from "react-native"; +import { SafeAreaView } from "react-native-safe-area-context"; +import { useAuth } from "../../lib/auth"; +import { t } from "../../lib/locales"; +import { colors } from "../../lib/theme"; +import { Button, H1, Muted, TextInput } from "../../lib/ui"; + +export default function SignUp() { + const { signUp } = useAuth(); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [confirmPassword, setConfirmPassword] = useState(""); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(""); + const [emailError, setEmailError] = useState(""); + const [passwordError, setPasswordError] = useState(""); + const [confirmPasswordError, setConfirmPasswordError] = useState(""); + + const validateForm = () => { + let valid = true; + setEmailError(""); + setPasswordError(""); + setConfirmPasswordError(""); + + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + if (!emailRegex.test(email)) { + setEmailError(t("invalidEmail")); + valid = false; + } + + if (!password) { + setPasswordError(t("passwordRequired")); + valid = false; + } else if (password.length < 8) { + setPasswordError(t("passwordTooShort")); + valid = false; + } + + if (password !== confirmPassword) { + setConfirmPasswordError(t("passwordsDoNotMatch")); + valid = false; + } + + return valid; + }; + + const handleSignUp = async () => { + if (!validateForm()) return; + + setLoading(true); + setError(""); + + try { + const result = await signUp(email, password); + if (!result.success) { + setError(result.reason || t("signUpError")); + } + } catch (e) { + setError(t("signUpError")); + } finally { + setLoading(false); + } + }; + + return ( + + + + router.back()} + > + + + + +

{t("createAccount")}

+
+ + + + + + + + + {error ? {error} : null} + +