-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
134 lines (126 loc) · 3.8 KB
/
Copy pathApp.tsx
File metadata and controls
134 lines (126 loc) · 3.8 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
import React, { useState } from "react";
import { View, StyleSheet, Text } from "react-native";
import DropDownPicker from "react-native-dropdown-picker";
export default function App() {
//0th drop down
const [open, setOpen] = useState(false);
const [value, setValue] = useState<string[]>([]); // Multi-select = array
const [items, setItems] = useState([
{ label: "Fruits", value: "fruits-label", selectable: false },
{ label: "Apple", value: "apple" },
{ label: "Banana", value: "banana" },
{ label: "Vegetables", value: "vegetables-label", selectable: false },
{ label: "Carrot", value: "carrot" },
{ label: "Broccoli", value: "broccoli" },
]);
//1st drop down
const [open1, setOpen1] = useState(false);
const [value1, setValue1] = useState(null);
const [items1, setItems1] = useState([
{ label: "Apple ", value: "apple" },
{ label: "Banana ", value: "banana" },
{ label: "Orange ", value: "orange" },
]);
//2nd drop down
const [open2, setOpen2] = useState(false);
const [value2, setValue2] = useState(null);
const [items2, setItems2] = useState([
{ label: "Apple ", value: "apple" },
{ label: "Banana ", value: "banana" },
{ label: "Orange ", value: "orange" },
]);
//3rd drop down
const [open3, setOpen3] = useState(false);
const [value3, setValue3] = useState(null);
const [items3, setItems3] = useState([
{ label: "Apple ", value: "apple" },
{ label: "Banana ", value: "banana" },
{ label: "Orange ", value: "orange" },
]);
return (
<>
<View style={styles.container}>
<DropDownPicker
open={open}
value={value}
items={items}
setOpen={setOpen}
setValue={setValue}
setItems={setItems}
placeholder="Select multiple items"
multiple={true} // ✅ Enable multi-select
mode="BADGE" // ✅ Optional: shows selected items as badges
listMode="SCROLLVIEW"
style={styles.dropdown}
dropDownContainerStyle={{ maxHeight: 200 }}
onSelectItem={(item) => {
console.log("Selected item:", item);
}}
/>
</View>
<View style={styles.container}>
<DropDownPicker
open={open1}
value={value1}
items={items1}
setOpen={setOpen1}
setValue={setValue1}
setItems={setItems1}
placeholder="Select a fruit"
listMode="SCROLLVIEW"
style={styles.dropdown}
onChangeValue={(value) => {
console.log("Selected value:", value);
}}
dropDownContainerStyle={styles.dropdown}
dropDownDirection="BOTTOM"
/>
</View>
<View style={styles.container}>
<DropDownPicker
open={open2}
value={value2}
items={items2}
setOpen={setOpen2}
setValue={setValue2}
setItems={setItems2}
placeholder="Select a fruit"
listMode="FLATLIST"
style={styles.dropdown}
/>
</View>
<View style={styles.container}>
<DropDownPicker
open={open3}
value={value3}
items={items3}
setOpen={setOpen3}
setValue={setValue3}
setItems={setItems3}
placeholder="Select a fruit"
listMode="MODAL"
style={styles.dropdown}
modalProps={{
animationType: "slide",
presentationStyle: "overFullScreen",
}}
modalContentContainerStyle={{
backgroundColor: "white",
borderRadius: 10,
padding: 20,
}}
/>
</View>
</>
);
}
const styles = StyleSheet.create({
container: {
marginTop: "37%",
paddingHorizontal: 20,
zIndex: 1000,
},
dropdown: {
borderColor: "green",
},
});