import React, { useState } from 'react'; import { View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator, Alert, KeyboardAvoidingView, Platform, ScrollView, } from 'react-native'; import { useTheme } from '@react-navigation/native'; import { useRouter } from 'expo-router'; import { Ionicons } from '@expo/vector-icons'; import { useAuth } from '~/context/AuthProvider'; import { useAppTheme } from '~/theme/ThemeProvider'; export default function ResetPasswordScreen() { const { colors } = useTheme(); const { isDarkMode } = useAppTheme(); const router = useRouter(); const { resetPassword } = useAuth(); const [email, setEmail] = useState(''); const [loading, setLoading] = useState(false); const [sent, setSent] = useState(false); const handleResetPassword = async () => { if (!email) { Alert.alert('Error', 'Please enter your email address.'); return; } try { setLoading(true); const { error } = await resetPassword(email); if (error) { Alert.alert('Error', error.message || 'Unknown error'); } else { setSent(true); } } catch (error) { console.error('Reset password error:', error); Alert.alert('Error', 'An error occurred. Please try again.'); } finally { setLoading(false); } }; if (sent) { return ( Check Your Email We've sent a password reset link to {email} router.replace('/auth/login')} > Back to Sign In ); } return ( router.back()}> Reset Password Enter your email and we'll send you a reset link Email {loading ? ( ) : ( Send Reset Link )} ); } const styles = StyleSheet.create({ container: { flexGrow: 1, padding: 24, }, backButton: { marginTop: 40, marginBottom: 20, }, header: { alignItems: 'center', marginBottom: 40, }, iconContainer: { width: 80, height: 80, borderRadius: 20, justifyContent: 'center', alignItems: 'center', marginBottom: 20, }, title: { fontSize: 28, fontWeight: 'bold', marginBottom: 8, }, subtitle: { fontSize: 16, textAlign: 'center', paddingHorizontal: 20, }, form: { width: '100%', }, inputContainer: { marginBottom: 24, }, label: { fontSize: 16, fontWeight: '600', marginBottom: 8, }, inputWrapper: { flexDirection: 'row', alignItems: 'center', borderWidth: 1, borderRadius: 12, paddingHorizontal: 16, paddingVertical: 12, }, input: { flex: 1, fontSize: 16, marginLeft: 12, }, button: { height: 56, borderRadius: 12, justifyContent: 'center', alignItems: 'center', }, buttonText: { color: '#FFFFFF', fontSize: 16, fontWeight: '600', }, successContent: { flex: 1, justifyContent: 'center', alignItems: 'center', }, });