Modal1Component.js
5.73 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
import React, {useState} from "react";
import {View, Text, Alert} from "react-native";
import {CheckBox} from "native-base";
import SquareButtonComponent from "../Base/SquareButtonComponent";
import {BUTTON_COLOR} from "../../constant";
import {resetLaneReducer} from "../../reducers/location";
import {useDispatch} from "react-redux";
const Modal1Component = (props) => {
// 데이터
const {setModalNumber, setShowButtons, setModalVisible, serviceStates, setServiceStates, selectKickServices} = props;
const [showDetail, setShowDetail] = useState(true);
// 함수
const dispatch = useDispatch();
const onPressCheckBox = (indexOfService) => {
if (indexOfService === 1) {
setServiceStates([...serviceStates.slice(0, indexOfService), !serviceStates[indexOfService], ...serviceStates.slice(indexOfService + 1)]);
} else {
setServiceStates([...serviceStates.slice(0, indexOfService), serviceStates[indexOfService], ...serviceStates.slice(indexOfService + 1)]);
}
};
const onShowDetail = () => {
setShowDetail(!showDetail);
};
const onDecideServices = () => {
if (serviceStates.findIndex(v => v) === -1) {
return Alert.alert('최소 하나 이상의 서비스를 선택하세요');
}
selectKickServices(serviceStates);
setModalNumber(0);
setShowButtons(true);
setModalVisible(false);
dispatch({type: resetLaneReducer});
};
// 렌더링
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': 3, 'flexDirection': 'column'}}>
<View style={{'flex': 1, 'flexDirection': 'row'}}>
<Text style={{fontSize: 16, fontWeight: 'bold', color: '#373737'}}>지쿠터(현재 미지원)</Text>
<CheckBox checked={serviceStates[0]} color="#4844ff"
onPress={() => onPressCheckBox(0)}/>
</View>
<View style={{'flex': 3, 'flexDirection': 'row'}}>
{!showDetail
? <Text style={{fontSize: 16, color: '#373737'}}>#저렴한 가격 #최다 보유</Text>
: <Text style={{
fontSize: 15, color: '#373737'
}}>{`기본 1분 300 / 1분당 150\n최대 20km/h\n00-05시 새벽 할증 요금제`}</Text>}
</View>
</View>
<View style={{'flex': 3, 'flexDirection': 'column'}}>
<View style={{'flex': 1, 'flexDirection': 'row'}}>
<Text style={{fontSize: 16, fontWeight: 'bold', color: '#373737'}}>플라워 로드</Text>
<CheckBox checked={serviceStates[1]} color="#4844ff"
onPress={() => onPressCheckBox(1)}/>
</View>
<View style={{'flex': 3, 'flexDirection': 'row'}}>
{!showDetail
? <Text style={{fontSize: 16, color: '#373737'}}>#빠른 속도</Text>
: <Text style={{
fontSize: 15, color: '#373737'
}}>{`기본 5분 1000/1분당 100\n최대 25km/h\n21시 이후 최대속도 18km 제한`}</Text>}
</View>
</View>
<View style={{'flex': 3, 'flexDirection': 'column'}}>
<View style={{'flex': 1, 'flexDirection': 'row'}}>
<Text style={{fontSize: 16, fontWeight: 'bold', color: '#373737'}}>씽씽(현재 미지원)</Text>
<CheckBox checked={serviceStates[2]} color="#4844ff"
onPress={() => onPressCheckBox(2)}/>
</View>
<View style={{'flex': 3, 'flexDirection': 'row'}}>
{!showDetail
? <Text style={{fontSize: 16, color: '#373737'}}>#최신 기기</Text>
: <Text style={{
fontSize: 15, color: '#373737'
}}>{`평일/심야/주말 요금 상이\n최대 25km/h\n9월 말까지 50% 할인 행사중`}</Text>}
</View>
</View>
<SquareButtonComponent
onPress={onShowDetail}
text={!showDetail ? '상세 정보 보기' : '간단 정보 보기'}
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={onDecideServices}
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>
);
};
export default Modal1Component;