|
@@ -0,0 +1,103 @@
|
|
|
+import { useRouter, Link } from "expo-router";
|
|
|
+import { useState } from "react";
|
|
|
+import { ActivityIndicator, Alert, StyleSheet, TextInput, TouchableOpacity, View, Text } from "react-native";
|
|
|
+
|
|
|
+export default function Login(){
|
|
|
+ const [email, setEmail] = useState("ifcadriely@gmail.com")
|
|
|
+ const [password, setPassword] = useState("123456")
|
|
|
+ const router = useRouter()
|
|
|
+ const [loading, setLoading] = useState(false)
|
|
|
+
|
|
|
+ const fazerLogin = () => {
|
|
|
+ if (email && password) {
|
|
|
+ setLoading(true)
|
|
|
+ setTimeout(() => {
|
|
|
+ setLoading(false);
|
|
|
+ if (router.canDismiss()) {
|
|
|
+ router.dismissAll()
|
|
|
+ }
|
|
|
+ router.replace({
|
|
|
+ pathname: '/',
|
|
|
+ params: {
|
|
|
+ logado: true
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }, 1000);
|
|
|
+ }else{
|
|
|
+ Alert.alert("Preencha todos os campos.")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (loading) {
|
|
|
+ return(
|
|
|
+ <View style={styles.container}>
|
|
|
+ <ActivityIndicator size="large" color="#db7093" />
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ return(
|
|
|
+ <View style={styles.container}>
|
|
|
+ <TextInput
|
|
|
+ value={email}
|
|
|
+ onChangeText={setEmail}
|
|
|
+ style={styles.input}
|
|
|
+ placeholder="Informe seu E-mail"
|
|
|
+ keyboardType="email-address"
|
|
|
+ autoCapitalize="none"
|
|
|
+ />
|
|
|
+ <TextInput
|
|
|
+ style={styles.input}
|
|
|
+ placeholder="Informe sua Senha"
|
|
|
+ value={password}
|
|
|
+ onChangeText={setPassword}
|
|
|
+ secureTextEntry
|
|
|
+ />
|
|
|
+ <TouchableOpacity style={styles.button}
|
|
|
+ onPress={fazerLogin}
|
|
|
+ >
|
|
|
+ <Text style={styles.text}>Entrar</Text>
|
|
|
+ </TouchableOpacity>
|
|
|
+ <Link href="/cadastro" style={styles.link}>
|
|
|
+ <Text>Não tem conta? Cadastre-se</Text>
|
|
|
+ </Link>
|
|
|
+ <Link href="/" style={styles.link}
|
|
|
+ >
|
|
|
+ <Text>Ir para Inicio (sem login)</Text>
|
|
|
+ </Link>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+const styles = StyleSheet.create({
|
|
|
+ container: {
|
|
|
+ flex: 1,
|
|
|
+ justifyContent: 'center',
|
|
|
+ padding: 20
|
|
|
+ },
|
|
|
+ input: {
|
|
|
+ heigth: 50,
|
|
|
+ borderColor: 'pink',
|
|
|
+ borderWidth: 1,
|
|
|
+ fontSize: 16,
|
|
|
+ padding: 10,
|
|
|
+ marginBottom: 10,
|
|
|
+ borderRadius: 5
|
|
|
+ },
|
|
|
+ link: {
|
|
|
+ marginTop: 10,
|
|
|
+ textAlign: 'center',
|
|
|
+ color: '#db7093'
|
|
|
+ },
|
|
|
+ button: {
|
|
|
+ backgroundColor: "#007AFF",
|
|
|
+ padding: 10,
|
|
|
+ borderRadius: 5,
|
|
|
+ alignItems: 'center'
|
|
|
+ },
|
|
|
+ text: {
|
|
|
+ color: 'white',
|
|
|
+ fontSize: 18
|
|
|
+ }
|
|
|
+})
|