-
Notifications
You must be signed in to change notification settings - Fork 0
/
Login.js
97 lines (89 loc) · 2.57 KB
/
Login.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import React, { useState } from 'react';
import { StyleSheet, View, TextInput, Dimensions, Image, TouchableOpacity, ImageBackground, StatusBar } from 'react-native';
import Loading from './Loading';
const { width, height } = Dimensions.get('window')
export default function Login({ navigation }) {
const [isLoading, setIsLoading] = useState(true)
const [idNumber, setIdNumber] = useState('')
const [identified, setIdentified] = useState(true)
const loginCheck = async () => {
try {
let response = await fetch('http://220.90.200.172:3000/user/signin', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: idNumber
}),
})
let json = await response.json();
if (json.statusCode == 200) {
return navigation.replace('Ranking', { userIdx: json.data.user_idx })
}
else {
setIdentified(false)
return
}
} catch (error) {
console.error(error);
}
};
setTimeout(() => { setIsLoading(false) }, 3000);
if(isLoading) {
return <Loading/>
}
return (
<ImageBackground source={require('./assets/모든배경.jpg')} style={styles.container}>
<StatusBar barStyle='light-content'></StatusBar>
<View style={styles.idInputView}>
<TextInput
style={styles.idInput}
onChangeText={idNumber => setIdNumber(idNumber)}
value={idNumber}
maxLength={15}
placeholder='아이디를 입력해주세요 :-)'
placeholderTextColor='#595757'
autoCorrect={false}
/>
<TouchableOpacity onPress={loginCheck}>
<Image style={styles.loginButton} source={require('./assets/login/클릭-창.png')}/>
</TouchableOpacity>
</View>
<Image style={identified ? styles.transparent : styles.loginFail} source={require('./assets/login/로그인-실패-창.png')}/>
</ImageBackground>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center'
},
idInputView: {
marginTop: height / 2 - 25,
marginBottom: 30,
flexDirection: 'row',
alignItems: 'center'
},
idInput: {
backgroundColor: '#d8e1e3',
height: 48,
width: 250,
paddingLeft: 10,
marginRight: 13,
fontSize: 17, // 17이외의 fontSize는 ios에서 입력할 때 글자 크기 변하는 에러 존재
borderRadius: 7
},
loginButton: {
width: 55,
height: 50
},
transparent: {
width: 0,
height: 0
},
loginFail: {
width: 318,
height: 25
}
});