import React, { useState } from 'react'; import { View, Text, StyleSheet, Platform, TouchableOpacity, TextInput, ActivityIndicator, } from 'react-native'; import { useRouter } from 'expo-router'; import { Feather } from '@expo/vector-icons'; import { useAuth } from '../../context/AuthContext'; import { useToast } from '../../context/ToastContext'; import { useForm } from '../../hooks/useForm'; import { useAppTheme } from '../../context/ThemeContext'; import { useAppConfig } from '../../context/ConfigContext'; import { AppScreen } from '../../components/AppScreen'; import { AIButton, AIInput } from '../../components/UI'; import { Image } from 'expo-image'; import { useTranslation } from '../../context/LanguageContext'; export default function RegisterScreen() { const router = useRouter(); const { signUp, isLoading } = useAuth(); const { showToast } = useToast(); const { colors, isDark } = useAppTheme(); const { config } = useAppConfig(); const { t } = useTranslation(); const { values, handleChange } = useForm({ name: '', email: '', password: '', password_confirmation: '', }); const handleRegister = async () => { if (!values.name || !values.email || !values.password) { showToast(t('fillAll'), 'error'); return; } if (values.password !== values.password_confirmation) { showToast(t('passMismatch'), 'error'); return; } try { await signUp(values.name, values.email, values.password); showToast(t('accountCreated'), 'success'); router.replace('/(tabs)'); } catch (error: any) { showToast(error.message || t('regFailed'), 'error'); } }; const cardBg = isDark ? '#1A1A1A' : '#FFFFFF'; const inputBg = isDark ? '#222222' : '#F5F5F5'; const border = isDark ? '#2A2A2A' : '#EEEEEE'; return ( {/* Header */} {config?.branding?.logo_url ? ( ) : ( B )} {t('createAccount')} {t('join')} {config?.branding?.app_name || 'biiproject'} ecosystem {/* Form card */} handleChange('name', v)} /> handleChange('email', v)} autoCapitalize="none" keyboardType="email-address" containerStyle={{ marginTop: 14 }} /> handleChange('password', v)} isPassword containerStyle={{ marginTop: 14 }} /> handleChange('password_confirmation', v)} isPassword containerStyle={{ marginTop: 14 }} /> {t('haveAccount')} router.push('/(auth)/login')}> {t('signIn')} ); } const styles = StyleSheet.create({ scroll: { paddingHorizontal: 24, paddingTop: 40 }, header: { alignItems: 'center', marginBottom: 28 }, logoBox: { width: 72, height: 72, borderRadius: 24, alignItems: 'center', justifyContent: 'center', elevation: 8, shadowColor: '#000', shadowOffset: { width: 0, height: 4 }, shadowOpacity: 0.1, shadowRadius: 12, }, logoLetter: { fontSize: 40, fontFamily: 'Outfit_800ExtraBold' }, brandName: { fontSize: 28, fontFamily: 'Outfit_800ExtraBold', marginTop: 14 }, tagline: { fontSize: 13, fontFamily: 'Outfit_400Regular', marginTop: 4 }, card: { borderRadius: 28, padding: 28, borderWidth: 1 }, inputGroup: {}, label: { fontSize: 10, fontFamily: 'Outfit_700Bold', letterSpacing: 1, marginBottom: 8, textTransform: 'uppercase' }, inputRow: { flexDirection: 'row', alignItems: 'center', height: 54, borderRadius: 14, borderWidth: 1, paddingHorizontal: 14, }, inputIcon: { marginRight: 10 }, input: { flex: 1, fontSize: 15, fontFamily: 'Outfit_500Medium' }, mainBtn: { height: 56, borderRadius: 16, alignItems: 'center', justifyContent: 'center' }, btnText: { fontSize: 16, fontFamily: 'Outfit_700Bold' }, footer: { flexDirection: 'row', justifyContent: 'center', marginTop: 24 }, footerText: { fontSize: 14, fontFamily: 'Outfit_400Regular' }, linkText: { fontSize: 14, fontFamily: 'Outfit_700Bold' }, });