-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathChangeProfile.tsx
More file actions
256 lines (249 loc) · 9.77 KB
/
ChangeProfile.tsx
File metadata and controls
256 lines (249 loc) · 9.77 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
import React, { useState } from 'react';
import { useWindowDimensions, View, Text, TextInput, TouchableOpacity, PermissionsAndroid, Platform, StyleSheet, ScrollView, Switch} from 'react-native';
import { Divider } from 'react-native-paper';
import Modal from "react-native-modal";
import SwitchToggle from 'react-native-switch-toggle';
import realm from './src/localDB/document';
import * as repository from './src/localDB/document';
import PushNotification from "react-native-push-notification";
import AsyncStorage from '@react-native-async-storage/async-storage';
import DatePicker from 'react-native-date-picker';
import * as amplitude from './AmplitudeAPI';
const ChangeProfile = () => {
const {height,width}=useWindowDimensions();
const [isProfileModalVisible, setIsProfileModalVisible] = useState(false);
const [name, setName] = useState('');
const [job, setJob] = useState('');
const [jobDefault, setJobDefault] = useState('');
const [nameDefault, setNameDefault] = useState('');
const [birthday, setBirthday] = useState(new Date());
const [showingBirthday,setShowingBirthday] = useState('');
const [isDatePickerVisible, setIsDatePickerVisible] = useState(false);
const formatDate = (rawDate:Date) => {
let date = new Date(rawDate);
return `${date.getFullYear()}/${String(date.getMonth()+1).padStart(2,'0')}/${String(date.getDate()).padStart(2,'0')}`
}
AsyncStorage.getItem('@UserInfo:job').then(data => {
setJobDefault(String(data));
})
AsyncStorage.getItem('@UserInfo:userName').then(data => {
setNameDefault(String(data));
})
AsyncStorage.getItem('@UserInfo:birthShow').then(data => {
setShowingBirthday(String(data));
})
return (
<TouchableOpacity onPress={() => {
amplitude.intoProfile();
setIsProfileModalVisible(!isProfileModalVisible);
}}>
<View
style={{
paddingHorizontal: 20,
paddingBottom: 20,
paddingTop: 20,
}}>
<Text style={{fontSize: 17, color:"#495057"}}>프로필 설정 변경</Text>
</View>
<Modal isVisible={isProfileModalVisible}
animationIn={"fadeIn"}
animationInTiming={200}
animationOut={"fadeOut"}
animationOutTiming={200}
onBackdropPress={async ()=>{
var birth;
await AsyncStorage.getItem('@UserInfo:birth').then(data => {
birth=data;
})
AsyncStorage.setItem('@UserInfo:birthShow',String(birth));
amplitude.cancelToChangeProfile();
setIsProfileModalVisible(!isProfileModalVisible);
}}
backdropColor='#CCCCCC'//'#FAFAFA'
backdropOpacity={0.8}
style={{
alignItems:'center'
}}>
<View style={{
backgroundColor:"#FFFAF4",
width:'85%',
height:'70%',
paddingHorizontal: '5%',
paddingBottom: '5%',
paddingTop: '5%',
//justifyContent:'center',
//alignItems:'center',
borderRadius:10
}}>
<View style={{paddingBottom: 40,
}}>
<Text style={{fontSize: 17, color:"#495057"}}>프로필 설정 변경</Text>
</View>
<ScrollView>
<View style={{paddingBottom: 10,
}}>
<Text style={{fontSize: 17, color:'#666666'}}>이름</Text>
</View>
<View style={{paddingBottom: 15,
}}>
<TextInput
style={styles.input}
defaultValue={nameDefault}
placeholderTextColor='#E2E2E2'
onChangeText={(text) => setName(text)}
onFocus={amplitude.setProfileName}
/>
</View>
<View style={{paddingBottom: 25,
}}>
<Text style={{fontSize: 17, color:'#666666'}}>생일</Text>
</View>
<View style={{paddingBottom: 30,
}}>
<TouchableOpacity onPress={() => {
amplitude.setProfileBirthday();
setIsDatePickerVisible(!isDatePickerVisible);
}}
style={{paddingBottom:10}}>
<Text style={{fontSize:20, paddingHorizontal:10, color: '#666666'}}>{showingBirthday}</Text>
</TouchableOpacity>
<Divider style={{backgroundColor:'#E2E2E2',width:'100%'}}/>
<Divider style={{backgroundColor:'#E2E2E2',width:'100%'}}/>
<Divider style={{backgroundColor:'#E2E2E2',width:'100%'}}/>
</View>
<View style={{paddingBottom: 10,
paddingTop:5
}}>
<Text style={{fontSize: 17, color:'#666666'}}>직업</Text>
</View>
<View style={{paddingBottom: 20,
}}>
<TextInput
style={styles.input}
defaultValue={jobDefault}
placeholderTextColor='#E2E2E2'
onChangeText={(text) => setJob(text)}
onFocus={amplitude.setProfileJob}
/>
</View>
</ScrollView>
<View style={{
paddingHorizontal: "5%",
paddingBottom: 10,
flexDirection: 'row',
justifyContent: 'space-between'
}}>
<TouchableOpacity onPress={async ()=>{
var birth;
await AsyncStorage.getItem('@UserInfo:birth').then(data => {
birth=data;
})
AsyncStorage.setItem('@UserInfo:birthShow',String(birth));
amplitude.cancelToChangeProfile();
setIsProfileModalVisible(!isProfileModalVisible);
}}>
<Text style={{fontSize: 17}}>취소</Text>
</TouchableOpacity>
<TouchableOpacity onPress={async ()=>{
if(job!=='') await AsyncStorage.setItem('@UserInfo:job', job);
if(name!=='') await AsyncStorage.setItem('@UserInfo:userName', name);
await AsyncStorage.setItem('@UserInfo:birth', showingBirthday);
amplitude.saveNewProfile();
setIsProfileModalVisible(!isProfileModalVisible);
}}>
<Text style={{fontSize: 17}}>저장</Text>
</TouchableOpacity>
</View>
</View>
</Modal>
<Modal isVisible={isDatePickerVisible}
animationIn={"fadeIn"}
animationInTiming={200}
animationOut={"fadeOut"}
animationOutTiming={200}
onBackdropPress={() => {
setIsDatePickerVisible(!isDatePickerVisible);
}}
backdropColor='#CCCCCC'//'#FAFAFA'
backdropOpacity={0.8}
style={{
alignItems:'center'
}}>
<View style={{
backgroundColor:"#FFFFFF",
width:340,
height:340,
paddingHorizontal: 20,
paddingBottom: 20,
paddingTop: 20,
justifyContent:'space-between',
//alignItems:'center',
borderRadius:10
}}>
<View style={{
paddingBottom: 20,
}}>
<Text style={{fontSize: 17, color:"#495057"}}>생일 입력</Text>
</View>
<View style={{
paddingBottom: 20,
alignItems:'center',
}}>
<DatePicker date={birthday}
onDateChange={(changedDate) => {
setBirthday(changedDate);}}
mode='date'
theme='light'/>
</View>
<TouchableOpacity style={{alignItems:'center',}}
onPress={async ()=>{
await AsyncStorage.setItem('@UserInfo:birthShow', formatDate(birthday));
setIsDatePickerVisible(!isDatePickerVisible);
}}>
<Text style={{paddingBottom: 20, fontSize: 17,}}>저장</Text>
</TouchableOpacity>
</View>
</Modal>
</TouchableOpacity>);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
view: {
position: 'relative',
backgroundColor: '#ffffff',
justifyContent: 'center',
alignItems: 'center',
flex:1,
},
title: {
fontSize: 25,
fontWeight: 'bold',
marginBottom: 10,
paddingBottom: 15
},
input: {
fontSize:20,
color: '#666666',
width: '100%',
padding: 10,
marginBottom: 20,
borderBottomWidth:1,
borderBottomColor:'#E2E2E2',
},
button: {
position: 'absolute',
bottom: 20,
width: '90%',
alignItems: 'center',
backgroundColor: '#EFEFEF',
padding: 10,
borderRadius: 5,
},
buttonText: {
color: '#000000',
fontSize: 16,
},
});
export default ChangeProfile;