-
Notifications
You must be signed in to change notification settings - Fork 0
/
SelectBox.js
40 lines (34 loc) · 955 Bytes
/
SelectBox.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
import React, {Component} from 'react';
import {Picker,PickerIOS, View, Text} from 'react-native';
const SelectBoxInputStyle = {
margin: 0,
height: 40,
width: 350,
padding: 0,
borderColor: 'grey',
borderWidth: 1
}
const TextStyle = {
margin: 5,
marginBottom:0
}
const ViewStyle = {
backgroundColor : '#eee',
borderBottomColor : '#ccc',
borderBottomWidth : 1
}
class SelectBox extends Component {
constructor(props) {
super(props)
}
render() {
let attr = this.props.element;
return (<View style={ViewStyle} key={attr.key}>
<Text style={TextStyle}>{attr.label}</Text>
<Picker mode="dialog" style={SelectBoxInputStyle} selectedValue={this.props.state[attr.key]} onValueChange={(text) => this.props.changeHandler(text,attr.key)}>
{attr.options.list.map(item => <Picker.Item key={item.id} label={item.name} value ={item.value} />)}
</Picker>
</View>)
}
}
export default SelectBox;