From 9034c62a94203caac347ce1b99dc9e656df37dcc Mon Sep 17 00:00:00 2001 From: Vinicius Souza Date: Thu, 31 Oct 2024 09:07:28 -0300 Subject: [PATCH] feat: add loading on sign up screen --- src/screens/SignIn.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/screens/SignIn.tsx b/src/screens/SignIn.tsx index 1140bc7..1a6804c 100644 --- a/src/screens/SignIn.tsx +++ b/src/screens/SignIn.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Center, Heading, Image, ScrollView, Text, useToast, VStack } from '@gluestack-ui/themed'; import { useNavigation } from '@react-navigation/native'; import { Controller, useForm } from 'react-hook-form'; @@ -19,6 +20,8 @@ type FormData = { }; export function SignIn() { + const [isLoading, setLoading] = useState(false); + const { signIn } = useAuth(); const toast = useToast(); const navigation = useNavigation(); @@ -34,6 +37,7 @@ export function SignIn() { async function handleSignIn({ email, password }: FormData) { try { + setLoading(true); await signIn(email, password); console.log('User signed in successfully.'); } catch (error) { @@ -41,6 +45,8 @@ export function SignIn() { const title = isAppError ? error.message : 'Não foi possível entrar. Tente novamente mais tarde.'; + + setLoading(false); toast.show({ placement: 'top', render: ({ id }) => ( @@ -110,7 +116,7 @@ export function SignIn() { )} /> -