forked from AkshayWarrier/Volunteer-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DropdownComponent.js
91 lines (88 loc) · 2.64 KB
/
DropdownComponent.js
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
import { useState } from 'react';
import { StyleSheet, View} from 'react-native';
import { Dropdown } from 'react-native-element-dropdown';
export const DropdownComponent = ({data, placeholder,withSearch,disabled,onSelect}) => {
const [value, setValue] = useState(null);
const [isFocus, setIsFocus] = useState(false);
return (
<View>
<Dropdown
data={data}
style={!disabled ? styles.dropdown : styles.disabledDropdown}
placeholderStyle={!disabled ? styles.dropdownPlaceholder : styles.disabledPlaceholder}
selectedTextStyle={styles.dropdownSelectedText}
containerStyle={styles.dropdownContainer}
itemTextStyle={styles.dropdownItemText}
itemStyle={styles.dropdownItem}
inputSearchStyle={styles.dropdownInputSearch}
activeColor="#4ECDC459"
placeholder = {placeholder}
labelField="label"
valueField="value"
onChange={(value) => {
setValue(value);
onSelect(value);
}}
onFocus={() => setIsFocus(true)}
onBlur={() => setIsFocus(false)}
search={withSearch}
disable={disabled}
dropdownPosition='bottom'
// onChangeText={onChange}
/>
</View>
)
}
const styles = StyleSheet.create({
dropdown: {
width: 350,
height: 50,
borderRadius: 5,
paddingHorizontal: 10,
borderColor: "#1A535C",
color: "#1A535C",
borderWidth: 1,
fontFamily: 'Poppins',
},
dropdownSelectedText: {
color: "#1A535C",
fontFamily: 'Poppins',
},
dropdownPlaceholder: {
color: "#1A535C",
fontFamily: 'Poppins',
},
dropdownContainer: {
width: 350,
borderRadius: 5,
fontFamily: 'Poppins',
backgroundColor: "#F7FFF7",
},
dropdownItemText: {
color: "#1A535C",
fontFamily: 'Poppins',
},
dropdownItem: {
backgroundColor: "#F7FFF7",
fontFamily: 'Poppins',
},
dropdownInputSearch: {
backgroundColor: "#F7FFF7",
fontFamily: 'Poppins',
},
disabledDropdown: {
width: 350,
height: 50,
borderRadius: 5,
paddingHorizontal: 10,
borderColor: "#c5c9d1",
color: "#9da1a8",
borderWidth: 1,
fontFamily: 'Poppins',
backgroundColor: "#c5c9d1",
},
disabledPlaceholder: {
color: "#9da1a8",
fontFamily: 'Poppins',
},
});