|
@ -1,5 +1,5 @@ |
|
|
import React, { useState, useContext } from "react"; |
|
|
import React, { useState, useContext } from "react"; |
|
|
import { StyleSheet, View } from "react-native"; |
|
|
|
|
|
|
|
|
import { StyleSheet, View, Text } from "react-native"; |
|
|
import * as Yup from "yup"; |
|
|
import * as Yup from "yup"; |
|
|
import { |
|
|
import { |
|
|
Form, |
|
|
Form, |
|
@ -15,6 +15,8 @@ import jwdDecode from "jwt-decode"; |
|
|
import { AuthContext } from "../auth/context"; |
|
|
import { AuthContext } from "../auth/context"; |
|
|
import authStorage from "../auth/storage"; |
|
|
import authStorage from "../auth/storage"; |
|
|
import assets from "../config/assets"; |
|
|
import assets from "../config/assets"; |
|
|
|
|
|
import Button from "../components/Button"; |
|
|
|
|
|
import { TouchableNativeFeedback } from "react-native-gesture-handler"; |
|
|
|
|
|
|
|
|
const phoneRegex = RegExp( |
|
|
const phoneRegex = RegExp( |
|
|
/^\(?[\(]?([0-9]{2})?\)?[)\b]?([0-9]{4,5})[-. ]?([0-9]{4})$/ |
|
|
/^\(?[\(]?([0-9]{2})?\)?[)\b]?([0-9]{4,5})[-. ]?([0-9]{4})$/ |
|
@ -30,6 +32,46 @@ const validationSchema = Yup.object().shape({ |
|
|
.matches(/[a-zA-Z]/, "A senha só pode conter letras"), |
|
|
.matches(/[a-zA-Z]/, "A senha só pode conter letras"), |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function DashedOrSeparator() { |
|
|
|
|
|
return ( |
|
|
|
|
|
<View |
|
|
|
|
|
style={{ |
|
|
|
|
|
flexDirection: "row", |
|
|
|
|
|
marginVertical: 20, |
|
|
|
|
|
alignItems: "center", |
|
|
|
|
|
paddingHorizontal: 14, |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
<View |
|
|
|
|
|
style={{ |
|
|
|
|
|
flex: 1, |
|
|
|
|
|
height: 1, |
|
|
|
|
|
backgroundColor: colors.subText, |
|
|
|
|
|
}} |
|
|
|
|
|
></View> |
|
|
|
|
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
style={{ |
|
|
|
|
|
marginHorizontal: 10, |
|
|
|
|
|
fontSize: 14, |
|
|
|
|
|
fontWeight: "bold", |
|
|
|
|
|
color: colors.subText, |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
OU |
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
|
|
|
|
<View |
|
|
|
|
|
style={{ |
|
|
|
|
|
height: 1, |
|
|
|
|
|
flex: 1, |
|
|
|
|
|
backgroundColor: colors.subText, |
|
|
|
|
|
}} |
|
|
|
|
|
></View> |
|
|
|
|
|
</View> |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export default function LoginScreen(props) { |
|
|
export default function LoginScreen(props) { |
|
|
const authContext = useContext(AuthContext); |
|
|
const authContext = useContext(AuthContext); |
|
|
|
|
|
|
|
@ -47,7 +89,7 @@ export default function LoginScreen(props) { |
|
|
|
|
|
|
|
|
const [loginFailed, setLoginFailed] = useState(false); |
|
|
const [loginFailed, setLoginFailed] = useState(false); |
|
|
return ( |
|
|
return ( |
|
|
<Screen style={styles.containter}> |
|
|
|
|
|
|
|
|
<Screen style={[styles.containter, { backgroundColor: colors.grayBG }]}> |
|
|
<Form |
|
|
<Form |
|
|
initialValues={{ |
|
|
initialValues={{ |
|
|
name: "", |
|
|
name: "", |
|
@ -58,7 +100,7 @@ export default function LoginScreen(props) { |
|
|
handleSubmit(name, password, setLoginFailed) |
|
|
handleSubmit(name, password, setLoginFailed) |
|
|
} |
|
|
} |
|
|
> |
|
|
> |
|
|
<View> |
|
|
|
|
|
|
|
|
<View paddingHorizontal={14}> |
|
|
<assets.AppLogoTitle |
|
|
<assets.AppLogoTitle |
|
|
preserveAspectRatio="xMidYMid meet" |
|
|
preserveAspectRatio="xMidYMid meet" |
|
|
width={300} |
|
|
width={300} |
|
@ -93,17 +135,30 @@ export default function LoginScreen(props) { |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<SubmitButton title="entrar" backgroundColor={colors.primary} /> |
|
|
<SubmitButton title="entrar" backgroundColor={colors.primary} /> |
|
|
</View> |
|
|
|
|
|
{/* <TouchableNativeFeedback |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<TouchableNativeFeedback |
|
|
onPress={() => { |
|
|
onPress={() => { |
|
|
props.navigation.navigate("Register"); |
|
|
|
|
|
|
|
|
props.navigation.navigate("ForgotPassword"); |
|
|
}} |
|
|
}} |
|
|
> |
|
|
> |
|
|
<View flexDirection="row" alignSelf="center"> |
|
|
<View flexDirection="row" alignSelf="center"> |
|
|
<Text>Não tem uma conta? </Text> |
|
|
|
|
|
<Text style={{ color: colors.lightBlue }}>Cadastre-se</Text> |
|
|
|
|
|
|
|
|
<Text style={{ color: colors.lightBlue, fontWeight: "bold" }}> |
|
|
|
|
|
Esqueceu a senha? |
|
|
|
|
|
</Text> |
|
|
|
|
|
</View> |
|
|
|
|
|
</TouchableNativeFeedback> |
|
|
|
|
|
|
|
|
|
|
|
<DashedOrSeparator /> |
|
|
|
|
|
|
|
|
|
|
|
<Button |
|
|
|
|
|
title="cadastrar-se" |
|
|
|
|
|
color={colors.green} |
|
|
|
|
|
style={{ paddingHorizontal: 16 }} |
|
|
|
|
|
onPress={() => { |
|
|
|
|
|
props.navigation.navigate("Register"); |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
</View> |
|
|
</View> |
|
|
</TouchableNativeFeedback>*/} |
|
|
|
|
|
</Form> |
|
|
</Form> |
|
|
</Screen> |
|
|
</Screen> |
|
|
); |
|
|
); |
|
|