99 lines
2.3 KiB
JavaScript
99 lines
2.3 KiB
JavaScript
import { StatusBar } from 'expo-status-bar';
|
|
import React, { useState, useEffect } from 'react';
|
|
import { Text, View, StyleSheet, Image } from 'react-native';
|
|
import { TextInput, Button } from 'react-native-paper';
|
|
import API from './../API.js';
|
|
import { useNavigation } from '@react-navigation/native';
|
|
import GlobalState from '../contexts/GlobalState.js';
|
|
|
|
|
|
let LoginForm = () => {
|
|
let [email, setEmail] = useState('');
|
|
let [password, setPassword] = useState('');
|
|
const navigation = useNavigation();
|
|
|
|
const loginCall = async ()=>{
|
|
let r = await API.logIn(email, password);
|
|
if (r.status === "ok") return navigation.reset({
|
|
index: 0,
|
|
routes: [{ name: 'MainNavigation' }],
|
|
});
|
|
alert('Please review the information')
|
|
};
|
|
|
|
return (
|
|
<View style={styles.mainView}>
|
|
<Image
|
|
style={styles.logo}
|
|
source={require('./../assets/icon.png')}
|
|
/>
|
|
<Text style={styles.header}>EMI Social</Text>
|
|
<Text >Login</Text>
|
|
<TextInput
|
|
style={styles.input}
|
|
onChangeText={text => setEmail(text)}
|
|
defaultValue={email}
|
|
placeholder="email"
|
|
autoCapitalize='none'
|
|
autoComplete='email'
|
|
autoCorrect={false}
|
|
mode="outlined"
|
|
/>
|
|
<TextInput
|
|
style={styles.input}
|
|
onChangeText={text => setPassword(text)}
|
|
defaultValue={password}
|
|
placeholder="password"
|
|
textContentType="password"
|
|
secureTextEntry={true}
|
|
autoCapitalize='none'
|
|
autoComplete='email'
|
|
autoCorrect={false}
|
|
mode="outlined"
|
|
/>
|
|
<Button
|
|
style={styles.button}
|
|
onPress={async () => {
|
|
await loginCall();
|
|
}}
|
|
>submit</Button>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
export default LoginForm;
|
|
|
|
const styles = StyleSheet.create({
|
|
mainView: {
|
|
backgroundColor: 'white',
|
|
flex: 1,
|
|
flexDirection: "column",
|
|
justifyContent: "flex-start",
|
|
padding: 15,
|
|
width: "100%",
|
|
alignContent: 'center',
|
|
alignItems: 'center',
|
|
},
|
|
header: {
|
|
fontFamily: 'Helvetica-Bold',
|
|
fontSize: 42,
|
|
textAlign: "left",
|
|
paddingBottom: 15,
|
|
color: '#777',
|
|
alignContent: 'center'
|
|
},
|
|
logo:{
|
|
width: 250,
|
|
height: 250,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
},
|
|
input:{
|
|
backgroundColor: 'white',
|
|
width: "80%"
|
|
},
|
|
button:{
|
|
marginTop: 10,
|
|
|
|
}
|
|
}); |