Newer
Older
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
import { StyleSheet, Text, View } from "react-native";
import { Picker } from '@react-native-picker/picker';
import React from "react";
const AppPicker: React.FC<{
label: string;
selectedValue: string | undefined;
onValueChange: (value: string | undefined) => void;
items: string[];
}> = ({ label, selectedValue, onValueChange, items }) => (
<>
<Text style={styles.label}>{label}</Text>
<View style={styles.pickerContainer}>
<Picker
selectedValue={selectedValue}
onValueChange={onValueChange}
style={styles.picker}
>
<Picker.Item label={`-- Sélectionner ${label} --`} value={undefined} />
{items.map((item: string) => (
<Picker.Item label={item} value={item} key={item} />
))}
</Picker>
</View>
</>
);
const styles = StyleSheet.create({
label: {
fontWeight: 'bold',
marginTop: 10,
color: '#333',
width: '100%',
},
pickerContainer: {
width: '100%',
borderColor: '#ccc',
borderWidth: 1,
borderRadius: 8,
marginTop: 5,
marginBottom: 10,
backgroundColor: '#f9f9f9',
justifyContent: 'center',
},
picker: {
width: '100%',
height: 50,
},
});
export default AppPicker;