-
Notifications
You must be signed in to change notification settings - Fork 0
/
Evaluate.js
197 lines (187 loc) · 8.99 KB
/
Evaluate.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import { registerRootComponent } from 'expo';
import React, { useState, useEffect } from 'react';
import { StyleSheet, View, TouchableOpacity, Image, TextInput, ImageBackground, Dimensions, StatusBar, Text } from 'react-native';
const { width, height } = Dimensions.get('window')
export default function Evaluate({ route, navigation }) {
const [idNumber, setIdNumber] = useState('')
const [available, setAvailable] = useState(true)
const [point, setPoint] = useState([])
const [pointLoading, setPointLoading] = useState(true)
const {userIdx} = route.params
const availableCheck = async () => {
try {
let response = await fetch('http://220.90.200.172:3000/analysis', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
insta_id: idNumber
}),
})
let json = await response.json();
if (json.statusCode == 200) {
return navigation.navigate('Result', {
insta_id: idNumber,
age: json.data.age,
gender: json.data.gender,
region: json.data.region,
interest: json.data.interest
})
}
else {
setAvailable(false)
return
}
} catch (error) {
console.error(error);
}
};
const getPoint = () => {
fetch(`http://220.90.200.172:3000/user/point/${userIdx}`, {
method: 'GET'
})
.then((response) => response.json())
.then((json) => setPoint(json.data))
.catch((error) => console.error('Error:', error))
.finally(() => setPointLoading(false))
}
useEffect(() => {
getPoint();
}, [])
return(
<ImageBackground source={require('./assets/모든배경.jpg')} style={styles.container}>
<StatusBar barStyle='light-content'></StatusBar>
<View style={styles.backToRankingView}>
<TouchableOpacity onPress={() => navigation.goBack()}>
<Image style={styles.rankButton} source={require('./assets/evaluate/랭킹버튼.png')}/>
</TouchableOpacity>
</View>
<View style={styles.pointView}>
<View style={styles.points}>
<Image style={styles.accumulatedPoints} source={require('./assets/points/채집된-물고기.png')}/>
<ImageBackground source={require('./assets/points/회색바.png')} style={styles.pointBar}>
{!pointLoading && (point.stack_point) >= 1 && <Image style={{width:33, height:17}} source={require('./assets/points/파랑배경물고기_8마리중(1).png')}/>}
{!pointLoading && (point.stack_point) >= 2 && <Image style={{width:31, height:17}} source={require('./assets/points/파랑배경물고기_8마리중(2).png')}/>}
{!pointLoading && (point.stack_point) >= 3 && <Image style={{width:31, height:17}} source={require('./assets/points/파랑배경물고기_8마리중(3).png')}/>}
{!pointLoading && (point.stack_point) >= 4 && <Image style={{width:31, height:17}} source={require('./assets/points/파랑배경물고기_8마리중(4).png')}/>}
{!pointLoading && (point.stack_point) >= 5 && <Image style={{width:31, height:17}} source={require('./assets/points/파랑배경물고기_8마리중(5).png')}/>}
{!pointLoading && (point.stack_point) >= 6 && <Image style={{width:31, height:17}} source={require('./assets/points/파랑배경물고기_8마리중(6).png')}/>}
{!pointLoading && (point.stack_point) >= 7 && <Image style={{width:31, height:17}} source={require('./assets/points/파랑배경물고기_8마리중(7).png')}/>}
{!pointLoading && (point.stack_point) >= 8 && <Image style={{width:31, height:17}} source={require('./assets/points/파랑배경물고기_8마리중(8).png')}/>}
{!pointLoading && (point.stack_point) >= 8 && <Image style={{width:19, height:17}} source={require('./assets/points/파랑배경물고기_마지막-숫자표시공간.png')}/>}
{!pointLoading && (point.stack_point) >= 8 && <Text style={styles.pointNumber}>{point.stack_point}</Text>}
</ImageBackground>
<Image style={styles.availablePoints} source={require('./assets/points/사용가능한-물고기.png')}/>
<ImageBackground source={require('./assets/points/회색바.png')} style={styles.pointBar}>
{!pointLoading && (point.point) >= 1 && <Image style={{width:33, height:17}} source={require('./assets/points/분홍배경물고기_8마리중(1).png')}/>}
{!pointLoading && (point.point) >= 2 && <Image style={{width:31, height:17}} source={require('./assets/points/분홍배경물고기_8마리중(2).png')}/>}
{!pointLoading && (point.point) >= 3 && <Image style={{width:31, height:17}} source={require('./assets/points/분홍배경물고기_8마리중(3).png')}/>}
{!pointLoading && (point.point) >= 4 && <Image style={{width:31, height:17}} source={require('./assets/points/분홍배경물고기_8마리중(4).png')}/>}
{!pointLoading && (point.point) >= 5 && <Image style={{width:31, height:17}} source={require('./assets/points/분홍배경물고기_8마리중(5).png')}/>}
{!pointLoading && (point.point) >= 6 && <Image style={{width:31, height:17}} source={require('./assets/points/분홍배경물고기_8마리중(6).png')}/>}
{!pointLoading && (point.point) >= 7 && <Image style={{width:31, height:17}} source={require('./assets/points/분홍배경물고기_8마리중(7).png')}/>}
{!pointLoading && (point.point) >= 8 && <Image style={{width:31, height:17}} source={require('./assets/points/분홍배경물고기_8마리중(8).png')}/>}
{!pointLoading && (point.point) >= 8 && <Image style={{width:19, height:17}} source={require('./assets/points/분홍배경물고기_마지막-숫자표시공간.png')}/>}
{!pointLoading && (point.point) >= 8 && <Text style={styles.pointNumber}>{point.point}</Text>}
</ImageBackground>
</View>
<Image style={{width:87, height: 82}} source={require('./assets/points/그물안에-물고기.png')}/>
</View>
<View style={styles.idInputView}>
<TextInput
style={styles.idInput}
onChangeText={idNumber => setIdNumber(idNumber)}
value={idNumber}
maxLength={15}
placeholder='분석하고 싶은 아이디를 입력해주세요 :-)'
placeholderTextColor='#595757'
/>
<Image style={available ? styles.transparent : styles.searchFail} source={require('./assets/evaluate/없는-아이디-표시.png')}/>
</View>
<View style={styles.buttonView}>
<TouchableOpacity onPress={availableCheck}>
<Image style={styles.evaluateButton} source={require('./assets/evaluate/분석하러가기-클릭버튼.png')}/>
</TouchableOpacity>
</View>
</ImageBackground>
)
}
const styles = StyleSheet.create({
container: {
flex: 1
},
backToRankingView: {
height:'10%',
justifyContent: 'flex-end'
},
rankButton: {
width:62,
height:65,
top: '20%',
},
pointView: {
height: '8%',
flexDirection: 'row',
alignItems: 'flex-end',
justifyContent: 'center'
},
points: {
alignItems: 'flex-end',
marginRight: width / 30
},
accumulatedPoints: {
width:53,
height:9,
marginBottom:1,
marginRight:5
},
availablePoints: {
width:69,
height:10,
marginBottom:1,
marginRight:5
},
pointBar: {
width:265,
height:17,
marginBottom:4,
flexDirection:"row"
},
pointNumber: {
fontSize: 12,
position: 'absolute',
right: '0%',
bottom: '10%'
},
idInputView: {
height:'59%',
alignItems: 'center'
},
idInput: {
backgroundColor: '#d8e1e3',
height: 48,
width: 322,
paddingLeft: 10,
borderRadius: 7,
marginBottom: 25,
marginTop: '58%',
fontSize: 17 // 17이외의 fontSize는 ios에서 입력할 때 글자 크기 변하는 에러 존재
},
buttonView: {
height: '23%',
alignItems: 'center'
},
transparent: {
width: 0,
height: 0
},
searchFail: {
width: 334,
height: 20
},
evaluateButton: {
width:188,
height:48
}
});