From ff54eb0c2fb14ca8842a6a41cc0b57699ddf21cf Mon Sep 17 00:00:00 2001 From: Vinicius Souza Date: Wed, 30 Oct 2024 10:55:41 -0300 Subject: [PATCH] feat: add validation to sign in form --- src/screens/SignIn.tsx | 145 ++++++++++++++++++++++++----------------- 1 file changed, 84 insertions(+), 61 deletions(-) diff --git a/src/screens/SignIn.tsx b/src/screens/SignIn.tsx index 167e797..c81aebf 100644 --- a/src/screens/SignIn.tsx +++ b/src/screens/SignIn.tsx @@ -1,84 +1,107 @@ -import { Center, Heading, Image, ScrollView, Text, VStack } from "@gluestack-ui/themed"; -import { useNavigation } from "@react-navigation/native"; +import { Center, Heading, Image, ScrollView, Text, VStack } from '@gluestack-ui/themed'; +import { useNavigation } from '@react-navigation/native'; +import { Controller, useForm } from 'react-hook-form'; import BackgroundImg from '@assets/background.png'; import Logo from '@assets/logo.svg'; -import { Input } from "@components/Input"; -import { Button } from "@components/Button"; -import { AuthNavigatorRoutesProps } from "@routes/auth.routes"; +import { Input } from '@components/Input'; +import { Button } from '@components/Button'; +import { AuthNavigatorRoutesProps } from '@routes/auth.routes'; + +type FormData = { + email: string; + password: string; +}; export function SignIn() { const navigation = useNavigation(); + const { + control, + handleSubmit, + formState: { errors }, + } = useForm(); function handleNewAccount() { navigation.navigate('SignUp'); } + function handleSignIn({ email, password }: FormData) { + console.debug(email, password); + } + return ( - - - Pessoas treinando + + + Pessoas treinando - -
- - - Treine a sua mente e o seu corpo - -
+ +
+ + + Treine a sua mente e o seu corpo + +
-
- - Acesse a conta - +
+ Acesse a conta - + ( + + )} + /> - + ( + + )} + /> -
+
-
- - Ainda não tem acesso? - +
+ + Ainda não tem acesso? + -
+
+
-
- ) + ); }