import React, { useState } from 'react'; import { View, Text, TextInput, TouchableOpacity, StyleSheet, KeyboardAvoidingView, Platform, Alert } from 'react-native'; import { useRouter } from 'expo-router'; import { useAuthStore } from '../../store/authStore'; import { colors, spacing, borderRadius } from '../../constants/theme'; export default function LoginScreen() { const router = useRouter(); const { login } = useAuthStore(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [isLoading, setIsLoading] = useState(false); const handleLogin = async () => { if (!username || !password) { Alert.alert('Error', 'Por favor ingresa usuario y contraseña'); return; } setIsLoading(true); try { await login(username, password); router.replace('/(tabs)'); } catch (error) { Alert.alert('Error', 'Credenciales incorrectas'); } finally { setIsLoading(false); } }; return ( Iniciar Sesión Ingresa tus credenciales para continuar Usuario Contraseña {isLoading ? 'Ingresando...' : 'Iniciar Sesión'} router.push('/auth/register')} > ¿No tienes cuenta? Regístrate ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: colors.background, }, form: { flex: 1, justifyContent: 'center', padding: spacing.xl, }, title: { fontSize: 28, fontWeight: 'bold', color: colors.text, marginBottom: spacing.sm, }, subtitle: { fontSize: 16, color: colors.textSecondary, marginBottom: spacing.xl, }, inputContainer: { marginBottom: spacing.md, }, label: { fontSize: 14, fontWeight: '500', color: colors.text, marginBottom: spacing.xs, }, input: { backgroundColor: colors.card, borderRadius: borderRadius.md, padding: spacing.md, fontSize: 16, color: colors.text, }, button: { backgroundColor: colors.primary, borderRadius: borderRadius.md, padding: spacing.md, alignItems: 'center', marginTop: spacing.md, }, buttonDisabled: { opacity: 0.6, }, buttonText: { color: colors.textInverse, fontSize: 16, fontWeight: '600', }, linkButton: { marginTop: spacing.lg, alignItems: 'center', }, linkText: { color: colors.primary, fontSize: 14, }, });