-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDropdownMenu.js
More file actions
67 lines (62 loc) · 1.52 KB
/
DropdownMenu.js
File metadata and controls
67 lines (62 loc) · 1.52 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
import React from "react";
import { View, StyleSheet } from "react-native";
import RNPickerSelect from "react-native-picker-select";
export default DropdownMenu = ({ tagsList, selectedTag, setSelectedTag }) => {
const TAGS = tagsList.map((tag) => {
return { label: tag.name, value: tag.name };
});
const getTagId = (value) => {
const tagId = tagsList.filter((tag) => {
return tag.name === value;
});
return tagId[0]?.id;
};
return (
<View style={styles.container}>
<RNPickerSelect
items={TAGS}
onValueChange={(value) =>
setSelectedTag({ id: getTagId(value), name: value })
}
placeholder={{ label: "Select a category", value: null }}
value={selectedTag}
style={pickerSelectStyles}
/>
</View>
);
};
const styles = StyleSheet.create({
container: {
borderColor: "lightgray",
borderWidth: 1,
borderRadius: 5,
backgroundColor: "#f0f5fd",
marginBottom: 10,
},
});
const pickerSelectStyles = StyleSheet.create({
inputIOS: {
height: 50,
fontSize: 16,
paddingVertical: 12,
paddingHorizontal: 10,
borderWidth: 1,
borderColor: "lightgray",
borderRadius: 4,
color: "black",
backgroundColor: "#f0f5fd",
paddingRight: 30,
},
inputAndroid: {
height: 50,
fontSize: 16,
paddingHorizontal: 10,
paddingVertical: 8,
borderWidth: 1,
borderColor: "lightgray",
borderRadius: 4,
color: "black",
backgroundColor: "#f0f5fd",
paddingRight: 30,
},
});