import { useAuth } from "@/contexts/AuthContext"; import { Link, useRouter } from "expo-router"; import { useState } from "react"; import { Alert, KeyboardAvoidingView, Platform, StyleSheet, Text, View, } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import * as LocalAuthentication from "expo-local-authentication"; import Animated, { FadeInDown, FadeInUp } from "react-native-reanimated"; import { Colors, Spacing, Typography } from "@/constants/theme"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; export default function LoginScreen() { const insets = useSafeAreaInsets(); const router = useRouter(); const { login } = useAuth(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [isLoading, setIsLoading] = useState(false); async function handleLogin() { if (!email || !password) { Alert.alert("Erro", "Por favor, preencha todos os campos."); return; } try { setIsLoading(true); await login({ email: email.trim(), password }); const hasHardware = await LocalAuthentication.hasHardwareAsync(); const isEnrolled = await LocalAuthentication.isEnrolledAsync(); if (hasHardware && isEnrolled) { router.replace("/biometrics"); } else { router.replace("/"); } } catch (error) { Alert.alert("Erro", "Falha ao fazer login. Verifique suas credenciais e tente novamente."); } finally { setIsLoading(false); } } return ( YABA O seu dinheiro, no seu controle.