From 142eec96b4c2e661920347f64c5a22b28165a1b7 Mon Sep 17 00:00:00 2001 From: alguilhot Date: Fri, 21 Oct 2022 19:04:55 +0200 Subject: [PATCH] ADD: ajout du contenu du screen signIn --- bob_party/src/screens/SignIn.tsx | 35 ++++++++++++++++++--- bob_party/src/screens/style/SignIn.style.js | 5 +++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/bob_party/src/screens/SignIn.tsx b/bob_party/src/screens/SignIn.tsx index 953a3e2..00666cf 100644 --- a/bob_party/src/screens/SignIn.tsx +++ b/bob_party/src/screens/SignIn.tsx @@ -1,24 +1,49 @@ import { StatusBar } from 'expo-status-bar' import { StyleSheet, View, ImageSourcePropType, Pressable, Text} from 'react-native' -import React from 'react'; +import React, { useState } from 'react'; import stylesScreen from './style/screens.style' import { TextInput } from 'react-native-gesture-handler'; import { CustomTextInput } from '../components/CustomTextInput'; import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice'; +import { User } from "../core/user"; +import tabUS from "../constUser"; import styles from "./style/SignIn.style" +import { useDispatch, useSelector } from 'react-redux'; +import { RootState } from '../redux/store'; +import { loginUser } from '../redux/features/currentUserSlice'; + + + + function SignIn(props: { navigation: any; }) { const { navigation } = props + + const [pseudo, setPseudo] = useState(''); + const [password, setPassword] = useState(''); + + const dispatch=useDispatch(); + + function userVerif(login: string, password: string, nav: any){ + if((tabUS.map((User) => User.getUsername()).indexOf(login)) !== -1){ + let id = (tabUS.map((User) => User.getUsername()).indexOf(login)) + if ((tabUS.map((User) => User.getUsername()).indexOf(login) === id) && ( tabUS[id].getPassword() === password) ){ + dispatch(loginUser(tabUS[id])); + nav.navigate('HomeTab'); + } + } + } + return ( - - - + setPseudo(val)} autoCapitalize='none' /> + setPassword(val)} autoCapitalize='none' /> + userVerif(pseudo, password, navigation)}> Se connecter - + navigation.navigate('SignUp')}> Pas de compte? Inscrivez vous ! diff --git a/bob_party/src/screens/style/SignIn.style.js b/bob_party/src/screens/style/SignIn.style.js index e8abeb6..881500f 100644 --- a/bob_party/src/screens/style/SignIn.style.js +++ b/bob_party/src/screens/style/SignIn.style.js @@ -24,4 +24,9 @@ export default StyleSheet.create({ color:'white', textDecorationLine:"underline", }, + textInput: { + width: '50%', + height: '5%', + backgroundColor: 'white', + } }); \ No newline at end of file