-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
147 lines (141 loc) · 3.69 KB
/
App.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import React from 'react';
import {
StyleSheet,
Text,
View,
StatusBar,
Image,
TextInput,
TouchableOpacity,
Alert,
Platform,
Dimensions
} from 'react-native';
import axios from 'axios';
import Main from './Main.js';
const { width, height } = Dimensions.get("window");
var id, password;
export default class extends React.Component {
state = {
login: false
};
render() {
return (
this.state.login ? <Main data={this.state.data}></Main> :
<View style={styles.container}>
<StatusBar barStyle="dark-content"></StatusBar>
<View style={styles.halfContainer1}>
<Image style={styles.logo} source={require('./assets/logo_column.png')}></Image>
</View>
<View style={{ width: '100%', alignItems: 'flex-start' }}>
<Text style={styles.id}>ID</Text>
</View>
<TextInput style={styles.input}
underlineColorAndroid="transparent"
placeholder="영문 소문자, 숫자 조합, 6-13자"
placeholderTextColor="#c2c2c2"
onChangeText={text => id = text}
></TextInput>
<View style={{ width: '100%', alignItems: 'flex-start' }}>
<Text style={styles.pw}>Password</Text>
</View>
<TextInput style={styles.input}
secureTextEntry={true}
underlineColorAndroid="transparent"
placeholder="영문, 숫자, 특수 문자 조합, 8-12자 내외"
placeholderTextColor="#c2c2c2"
onChangeText={text => password = text}
></TextInput>
<TouchableOpacity style={styles.loginButton} onPressOut={this._loginAuth}>
<Text style={{ color: '#fff', fontWeight: '500', fontSize: 19 }}>로그인</Text>
</TouchableOpacity>
</View>
);
}
_loginAuth = () => {
if (id == undefined || id == "" || password == undefined || password == "") {
Alert.alert("Enter your ID and password")
}
else {
axios({
method: 'post',
url: 'http://15.164.220.109/Api/Home/Login',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
data: {
id: id,
pw: password
}
})
.then(json => {
if (json.status == 200) {
this.setState({ login: true, data: json.data });
}
})
.catch(err => {console.log(err); Alert.alert("ID or Password does not match") });
}
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
},
halfContainer1: {
marginTop: height * 0.108,
alignItems: 'center',
justifyContent: 'center'
},
logo: {
width: width * (2 / 5),
height: height * (1 / 8),
resizeMode: 'contain'
},
id: {
fontSize: 20,
marginTop: height * 0.05,
marginLeft: width * 0.1
},
pw: {
fontSize: 20,
marginTop: height * 0.029,
marginLeft: width * 0.1
},
input: {
marginTop: height * 0.013,
width: width * 0.8,
height: height * 0.061,
paddingHorizontal: 10,
borderWidth: 1,
borderColor: "#e2e2e2",
borderRadius: 3,
fontSize: 16,
color: '#5276F6'
},
loginButton: {
marginTop: height * 0.054,
width: width * 0.8,
height: height * 0.064,
backgroundColor: '#4b74ff',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 3,
...Platform.select({
ios: {
shadowColor: "rgba(75, 116, 255, 0.6)",
shadowOpacity: 1,
shadowOffset: {
width: 0,
height: 3
},
shadowRadius: 10,
},
android: {
elevation: 10
}
})
}
});