From cc44ceea8bc558c286956d44086b5c5610417fea Mon Sep 17 00:00:00 2001 From: GabrielTrettel Date: Tue, 23 Mar 2021 21:49:02 -0300 Subject: [PATCH] Changing app logo in login and register. --- src/App.js | 13 +++----- src/app/auth/storage.js | 8 ++++- src/app/screens/LoginScreen.js | 13 ++++---- src/app/screens/RegisterScreen.js | 52 +++++++++++++++++-------------- 4 files changed, 48 insertions(+), 38 deletions(-) diff --git a/src/App.js b/src/App.js index 683f1e5..4a12611 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,4 @@ -import React, { useState, useContext, useEffect } from "react"; +import React, { useState } from "react"; import { NavigationContainer } from "@react-navigation/native"; import navigationTheme from "./app/navigation/navigationTheme"; @@ -14,22 +14,19 @@ import CurrentLocationProvider from "./app/context/CurrentLocationContext"; import AuthNavigator from "./app/navigation/AuthNavigator"; import { AuthContext } from "./app/auth/context"; import authStorage from "./app/auth/storage"; -import jwtDecode from "jwt-decode"; export default function App() { const [user, setUser] = useState(); const [isReady, setIsReady] = useState(); - const restoreToken = async () => { - const token = await authStorage.getToken(); - if (!token) return; - - return setUser(jwtDecode(token)); + const restoreUser = async () => { + const user = await authStorage.getUser(); + if (user) setUser(user); }; if (!isReady) return ( - setIsReady(true)} /> + setIsReady(true)} /> ); global.userDataBase = openDatabase(); diff --git a/src/app/auth/storage.js b/src/app/auth/storage.js index 8af5ba1..ce28423 100644 --- a/src/app/auth/storage.js +++ b/src/app/auth/storage.js @@ -1,4 +1,5 @@ import * as SecureStore from "expo-secure-store"; +import jwtDecode from "jwt-decode"; const key = "authToke"; @@ -26,4 +27,9 @@ const removeToken = async () => { } }; -export default { setToken, getToken, removeToken }; +const getUser = async () => { + const token = await getToken(); + return token ? jwtDecode(token) : null; +}; + +export default { setToken, getUser, removeToken }; diff --git a/src/app/screens/LoginScreen.js b/src/app/screens/LoginScreen.js index 12dbd70..32a36d7 100644 --- a/src/app/screens/LoginScreen.js +++ b/src/app/screens/LoginScreen.js @@ -59,8 +59,13 @@ export default function LoginScreen(props) { handleSubmit(name, password, setLoginFailed) } > - {/* Pega Chuva */} - + { - if(password !== confirmPassword){ + if (password !== confirmPassword) { setSingUpFailed(true); - console.log("Senhas Diferentes") - } - else{ + console.log("Senhas Diferentes"); + } else { setSingUpFailed(false); } - } + }; return ( @@ -58,19 +55,26 @@ export default function RegisterScreen(props) { password: "", confirmPassword: "", }} - onSubmit={({name, number, password, confirmPassword}) => { + onSubmit={({ name, number, password, confirmPassword }) => { comparePassword(password, confirmPassword); - console.log("cadastro ainda não implementado") + console.log("cadastro ainda não implementado"); }} validationSchema={validationSchema} > - + - Pega Chuva + - + Nome Completo: - - + + - + { @@ -125,7 +136,7 @@ export default function RegisterScreen(props) { - + ); } @@ -136,11 +147,6 @@ const styles = StyleSheet.create({ textAlign: "center", padding: 10, }, - title: { - fontSize: dimensions.text.header, - marginBottom: dimensions.spacing.big_padding, - textAlign: "center", - }, labelStyle: { fontSize: dimensions.text.secondary, fontWeight: "bold",