-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDropdown.tsx
More file actions
72 lines (66 loc) · 1.82 KB
/
Dropdown.tsx
File metadata and controls
72 lines (66 loc) · 1.82 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
import React, { useState } from 'react';
import { View, Text, TouchableOpacity, StyleSheet, Image } from 'react-native';
const Dropdown = ({ options, onSelectOption }) => {
const [isOptionsVisible, setOptionsVisible] = useState(false);
const handleOptionSelect = (option) => {
onSelectOption(option); // 선택한 옵션을 부모 컴포넌트로 전달
setOptionsVisible(false); // 선택지 닫기
};
return (
<View>
{/* 드롭다운 버튼 */}
<TouchableOpacity style={styles.orderButton} onPress={() => setOptionsVisible(!isOptionsVisible)}>
<Text style={styles.orderText}>최근 생성 순</Text>
{/* <Image style={styles.orderImg} source={require('./assets/arrow-drop-down.png')} /> */}
</TouchableOpacity>
{/* 선택지 영역 */}
{/* {isOptionsVisible && (
<View style={styles.optionsContainer}>
{options.map((option) => (
<TouchableOpacity
key={option}
style={styles.option}
onPress={() => handleOptionSelect(option)}
>
<Text>{option}</Text>
</TouchableOpacity>
))}
</View>
)} */}
</View>
);
};
const styles = StyleSheet.create({
orderButton: {
flexDirection: 'row',
gap: 6,
},
orderText: {
color: 'rgba(0, 0, 0, 0.5)',
fontFamily: 'Pretendard',
fontWeight: '400',
fontSize: 12,
fontStyle: 'normal',
textAlignVertical: 'center',
},
orderImg: {
width: 24,
height: 24,
},
modalContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
},
modalContent: {
backgroundColor: 'white',
padding: 20,
borderRadius: 8,
},
option: {
paddingVertical: 8,
paddingHorizontal: 12,
},
});
export default Dropdown;