Modal2Component.js
4.93 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
import React from 'react';
import {View, Text} from 'react-native';
import {useDispatch} from "react-redux";
import {setStartLocationSaga, setEndLocationSaga} from "../../reducers/location";
import TextInputComponent from "../Base/TextInputComponent";
import SquareButtonComponent from "../Base/SquareButtonComponent";
import {BUTTON_COLOR} from "../../constant";
const Modal2Component = (props) => {
// 데이터
const {closeModal, setShowButtons, setModalVisible, serviceStates, setModalNumber, startTextLocation, endTextLocation, setStartTextLocation, setEndTextLocation} = props;
// 함수
const dispatch = useDispatch();
const onChangeStartLocation = (text) => {
setStartTextLocation(text);
};
const onChangeFinishLocation = (text) => {
setEndTextLocation(text);
};
const setLocation = async () => {
try {
if (startTextLocation && endTextLocation) {
await dispatch({
type: setStartLocationSaga,
data: {
startTextLocation,
}
});
await dispatch({
type: setEndLocationSaga,
data: {
endTextLocation
}
});
if (serviceStates.findIndex(serviceState => serviceState) === -1) {
setModalNumber(2);
setShowButtons(false);
setModalVisible(true);
} else {
setModalNumber(0);
setShowButtons(true);
setModalVisible(false);
}
}
} catch (e) {
console.error(e);
}
};
const close = () => {
closeModal();
};
// 렌더링
return (
<View style={{'flex': 1, width: 270}}>
<View style={{'flex': 1, 'flexDirection': 'column', marginBottom: 15}}>
<Text style={{fontSize: 24, fontWeight: 'bold', textAlign: 'center', color: '#373737'}}>
출발 및 도착 설정
</Text>
</View>
<View style={{'flex': 9, 'flexDirection': 'column'}}>
<TextInputComponent
onChangeText={onChangeStartLocation}
value={startTextLocation}
secureTextEntry={false}
placeholder={'출발 장소를 입력하세요'}
style1={{
marginLeft: 0,
marginRight: 0,
marginTop: 0,
marginBottom: 0,
padding: 15,
}}
style2={{
marginLeft: 15,
marginRight: 15,
}}
/>
<TextInputComponent
onChangeText={onChangeFinishLocation}
value={endTextLocation}
secureTextEntry={false}
placeholder={'도착 장소를 입력하세요'}
style1={{
marginLeft: 0,
marginRight: 0,
marginTop: 0,
marginBottom: 0,
padding: 15,
}}
style2={{
marginLeft: 15,
marginRight: 15,
}}
/>
<SquareButtonComponent
onPress={setLocation}
text={'출발지와 도착지 결정'}
style1={{
marginLeft: 0,
marginRight: 0,
marginTop: 10,
marginBottom: 0,
padding: 10,
borderRadius: 3,
backgroundColor: BUTTON_COLOR
}}
style2={{
fontSize: 16,
fontWeight: 'bold',
textAlign: 'center',
color: '#ffffff'
}}
/>
<SquareButtonComponent
onPress={close}
text={'닫기'}
style1={{
marginLeft: 0,
marginRight: 0,
marginTop: 10,
marginBottom: 0,
padding: 10,
borderRadius: 3,
backgroundColor: BUTTON_COLOR
}}
style2={{
fontSize: 16,
fontWeight: 'bold',
textAlign: 'center',
color: '#ffffff'
}}
/>
</View>
</View>
)
};
export default Modal2Component;