import { useState } from 'react'; import { View, Text, TextInput, Pressable, KeyboardAvoidingView, Platform, ScrollView, ActivityIndicator, } from 'react-native'; import { useRouter } from 'expo-router'; import { SafeAreaView } from 'react-native-safe-area-context'; import Svg, { Path } from 'react-native-svg'; import { useTranslation } from 'react-i18next'; import { useAuthStore } from '../../stores/auth'; function GoogleIcon() { return ( ); } function AppleIcon() { return ( ); } type OAuthProvider = 'google' | 'apple' | null; const INPUT_STYLE = { fontSize: 16, lineHeight: 22, paddingVertical: 14, paddingHorizontal: 16, color: '#0a0a0a', fontFamily: 'Nunito_400Regular', } as const; export default function SignInScreen() { const router = useRouter(); const { t } = useTranslation(); const { signInWithPassword, signInWithOAuth } = useAuthStore(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(null); const [submitting, setSubmitting] = useState(false); const [oauthLoading, setOauthLoading] = useState(null); const onSubmit = async () => { if (!email.trim() || !password) return; setError(null); setSubmitting(true); const res = await signInWithPassword(email.trim(), password); setSubmitting(false); if (res.error) { setError(res.error); return; } router.replace('/(app)'); }; const onOAuth = async (provider: 'google' | 'apple') => { setError(null); setOauthLoading(provider); const res = await signInWithOAuth(provider); setOauthLoading(null); if (res.error) { setError(res.error); return; } router.replace('/(app)'); }; const isLoading = submitting || oauthLoading !== null; return ( {t('auth.welcomeBack')} {t('auth.signinSubtitle')} {/* OAuth Buttons */} onOAuth('google')} disabled={isLoading} className="flex-row items-center justify-center gap-3 bg-white border border-neutral-200 rounded-xl mb-3 active:opacity-80 disabled:opacity-40" style={{ paddingVertical: 14 }} > {oauthLoading === 'google' ? ( ) : ( )} {t('auth.googleSignin')} onOAuth('apple')} disabled={isLoading} className="flex-row items-center justify-center gap-3 bg-neutral-900 rounded-xl mb-6 active:opacity-80 disabled:opacity-40" style={{ paddingVertical: 14 }} > {oauthLoading === 'apple' ? ( ) : ( )} {t('auth.appleSignin')} {/* Divider */} {t('auth.orWithEmail')} {/* Email + Password */} router.push('/forgot-password')} className="self-end py-2 mb-4" > {t('auth.forgotPassword')} {error && ( {error} )} {submitting ? ( ) : ( {t('auth.signin')} )} router.push('/signup')} className="py-4 items-center mt-2" > {t('auth.noAccount')}{' '} {t('auth.signup')} ); }