diff options
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/(auth)/login.tsx | 52 | ||||
| -rw-r--r-- | src/app/(auth)/register.tsx | 85 |
2 files changed, 117 insertions, 20 deletions
diff --git a/src/app/(auth)/login.tsx b/src/app/(auth)/login.tsx index bf4eda7..8dbac8b 100644 --- a/src/app/(auth)/login.tsx +++ b/src/app/(auth)/login.tsx @@ -1,8 +1,9 @@ import { Link } from 'expo-router'; -import { Pressable, StyleSheet, Text, TextInput, View } from 'react-native'; +import { Alert, Platform, Pressable, StyleSheet, Text, TextInput, View } from 'react-native'; import { MaterialIcons } from '@expo/vector-icons'; import theme from '@/theme'; import { useLogin } from '@/features/auth/hooks/useLogin'; +import { useState } from 'react'; import { StatusMessage } from '@/shared/ui/StatusMessage'; const { colors, spacing, radius, typography, fontWeight, layout, shadows } = theme; @@ -11,6 +12,22 @@ export default function LoginScreen() { // hook de login const { email, password, setEmail, setPassword, submit, isSubmitting, error } = useLogin(); + // controla si la contraseña se muestra o se oculta + const [showPassword, setShowPassword] = useState(false); + + // mensaje temporal para recuperar contraseña + const handleForgotPassword = () => { + const message = + 'La recuperación de contraseña todavía no está disponible en esta versión.'; + + if (Platform.OS === 'web') { + window.alert(message); + return; + } + + Alert.alert('Próximamente', message); + }; + return ( <View style={styles.container}> {/* contenido central acotado */} @@ -42,17 +59,32 @@ export default function LoginScreen() { {/* campo contraseña */} <Text style={styles.label}>Contraseña</Text> - <TextInput - style={styles.input} - placeholder="••••••••" - placeholderTextColor={colors.textSecondary} - secureTextEntry - value={password} - onChangeText={setPassword} - /> + <View style={styles.inputWrapper}> + <TextInput + style={styles.inputWithIcon} + placeholder="••••••••" + placeholderTextColor={colors.textSecondary} + secureTextEntry={!showPassword} + value={password} + onChangeText={setPassword} + /> + + <Pressable + onPress={() => setShowPassword((prev) => !prev)} + style={styles.iconButton} + > + <MaterialIcons + name={showPassword ? 'visibility-off' : 'visibility'} + size={20} + color={colors.textSecondary} + /> + </Pressable> + </View> {/* enlace visual de recuperar contraseña */} - <Text style={styles.forgotPassword}>¿Olvidaste tu contraseña?</Text> + <Pressable onPress={handleForgotPassword}> + <Text style={styles.forgotPassword}>¿Olvidaste tu contraseña?</Text> + </Pressable> {/* mensaje de error */} {error ? <StatusMessage message={error} /> : null} diff --git a/src/app/(auth)/register.tsx b/src/app/(auth)/register.tsx index 0b57ce5..902c752 100644 --- a/src/app/(auth)/register.tsx +++ b/src/app/(auth)/register.tsx @@ -1,6 +1,7 @@ import { Link } from 'expo-router'; import { Pressable, StyleSheet, Text, TextInput, View } from 'react-native'; import { MaterialIcons } from '@expo/vector-icons'; +import { useState } from 'react'; import theme from '@/theme'; import { useRegister } from '@/features/auth/hooks/useRegister'; import { StatusMessage } from '@/shared/ui/StatusMessage'; @@ -21,6 +22,27 @@ export default function RegisterScreen() { error, } = useRegister(); + // estado para confirmar contraseña + const [confirmPassword, setConfirmPassword] = useState(''); + + // estados para mostrar/ocultar contraseña + const [showPassword, setShowPassword] = useState(false); + const [showConfirmPassword, setShowConfirmPassword] = useState(false); + + // error local (frontend) + const [localError, setLocalError] = useState<string | null>(null); + + const handleSubmit = () => { + setLocalError(null); + + if (password !== confirmPassword) { + setLocalError('Las contraseñas no coinciden'); + return; + } + + submit(); + }; + return ( <View style={styles.container}> {/* contenido central acotado */} @@ -62,20 +84,62 @@ export default function RegisterScreen() { {/* campo contraseña */} <Text style={styles.label}>Contraseña</Text> - <TextInput - style={styles.input} - placeholder="Mínimo 8 caracteres" - placeholderTextColor={colors.textSecondary} - secureTextEntry - value={password} - onChangeText={setPassword} - /> + <View style={styles.inputWrapper}> + <TextInput + style={styles.inputWithIcon} + placeholder="Mínimo 8 caracteres" + placeholderTextColor={colors.textSecondary} + secureTextEntry={!showPassword} + value={password} + onChangeText={setPassword} + /> + + <Pressable + onPress={() => setShowPassword((prev) => !prev)} + style={styles.iconButton} + > + <MaterialIcons + name={showPassword ? 'visibility-off' : 'visibility'} + size={20} + color={colors.textSecondary} + /> + </Pressable> + </View> + + {/* campo confirmar contraseña */} + <Text style={styles.label}>Confirmar contraseña</Text> + <View style={styles.inputWrapper}> + <TextInput + style={styles.inputWithIcon} + placeholder="Repite la contraseña" + placeholderTextColor={colors.textSecondary} + secureTextEntry={!showConfirmPassword} + value={confirmPassword} + onChangeText={setConfirmPassword} + /> + + <Pressable + onPress={() => setShowConfirmPassword((prev) => !prev)} + style={styles.iconButton} + > + <MaterialIcons + name={showConfirmPassword ? 'visibility-off' : 'visibility'} + size={20} + color={colors.textSecondary} + /> + </Pressable> + </View> {/* mensaje de error */} + {localError ? <StatusMessage message={localError} /> : null} {error ? <StatusMessage message={error} /> : null} {/* boton principal */} - <Pressable style={styles.button} onPress={submit} disabled={isSubmitting}> + <Pressable + style={styles.button} + onPress={handleSubmit} + disabled={isSubmitting} + > <Text style={styles.buttonText}> {isSubmitting ? 'Registrando...' : 'Crear cuenta'} </Text> @@ -84,7 +148,8 @@ export default function RegisterScreen() { {/* enlace inferior a login */} <Link href="/(auth)/login" style={styles.link}> - ¿Ya tienes cuenta? <Text style={styles.linkHighlight}>Inicia sesión</Text> + ¿Ya tienes cuenta?{' '} + <Text style={styles.linkHighlight}>Inicia sesión</Text> </Link> </View> </View> |