import React, { useState } from 'react'; import { View, Text, TextInput, TouchableOpacity, StyleSheet, SafeAreaView, KeyboardAvoidingView, Platform, ScrollView, StatusBar, Alert, ActivityIndicator, } from 'react-native'; import { LinearGradient } from 'expo-linear-gradient'; import { useTranslation } from 'react-i18next'; import { useAuth } from '../contexts/AuthContext'; import { KurdistanColors } from '../theme/colors'; interface SignUpScreenProps { onSignUp: () => void; onNavigateToSignIn: () => void; } const SignUpScreen: React.FC = ({ onSignUp, onNavigateToSignIn }) => { const { t } = useTranslation(); const { signUp } = useAuth(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [username, setUsername] = useState(''); const [isLoading, setIsLoading] = useState(false); const handleSignUp = async () => { if (!email || !password || !username) { Alert.alert('Error', 'Please fill all required fields'); return; } if (password !== confirmPassword) { Alert.alert('Error', 'Passwords do not match'); return; } setIsLoading(true); try { const { error } = await signUp(email, password, username); if (error) { Alert.alert('Sign Up Failed', error.message); return; } // Success - navigate to app onSignUp(); } catch (error) { Alert.alert('Error', 'An unexpected error occurred'); if (__DEV__) console.error('Sign up error:', error); } finally { setIsLoading(false); } }; return ( {/* Header */} PZK {t('auth.getStarted')} {t('auth.createAccount')} {/* Form */} {t('auth.email')} {t('auth.username')} {t('auth.password')} {t('auth.confirmPassword')} {isLoading ? ( ) : ( {t('auth.signUp')} )} or {t('auth.haveAccount')}{' '} {t('auth.signIn')} ); }; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: KurdistanColors.sor, }, gradient: { flex: 1, }, keyboardView: { flex: 1, }, scrollContent: { flexGrow: 1, padding: 20, paddingTop: 60, }, header: { alignItems: 'center', marginBottom: 40, }, logoContainer: { width: 80, height: 80, borderRadius: 40, backgroundColor: KurdistanColors.spi, justifyContent: 'center', alignItems: 'center', marginBottom: 16, boxShadow: '0px 4px 8px rgba(0, 0, 0, 0.3)', elevation: 8, }, logoText: { fontSize: 28, fontWeight: 'bold', color: KurdistanColors.sor, }, title: { fontSize: 24, fontWeight: 'bold', color: KurdistanColors.spi, marginBottom: 8, }, subtitle: { fontSize: 16, color: KurdistanColors.spi, opacity: 0.9, }, form: { backgroundColor: KurdistanColors.spi, borderRadius: 20, padding: 24, boxShadow: '0px 4px 8px rgba(0, 0, 0, 0.2)', elevation: 8, }, inputGroup: { marginBottom: 20, }, label: { fontSize: 14, fontWeight: '600', color: KurdistanColors.reş, marginBottom: 8, }, input: { backgroundColor: '#F5F5F5', borderRadius: 12, padding: 16, fontSize: 16, borderWidth: 1, borderColor: '#E0E0E0', }, signUpButton: { backgroundColor: KurdistanColors.sor, borderRadius: 12, padding: 16, alignItems: 'center', marginTop: 8, boxShadow: '0px 4px 6px rgba(255, 0, 0, 0.3)', elevation: 6, }, signUpButtonText: { fontSize: 18, fontWeight: 'bold', color: KurdistanColors.spi, }, buttonDisabled: { opacity: 0.6, }, divider: { flexDirection: 'row', alignItems: 'center', marginVertical: 24, }, dividerLine: { flex: 1, height: 1, backgroundColor: '#E0E0E0', }, dividerText: { marginHorizontal: 12, fontSize: 14, color: '#999', }, signInPrompt: { alignItems: 'center', }, signInPromptText: { fontSize: 14, color: '#666', }, signInLink: { color: KurdistanColors.sor, fontWeight: 'bold', }, }); export default SignUpScreen;