-
Notifications
You must be signed in to change notification settings - Fork 0
/
RadioButton.js
57 lines (48 loc) · 1.36 KB
/
RadioButton.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
import React, {Component} from 'react';
// import RadioForm, {RadioButton, RadioButtonInput, RadioButtonLabel} from 'react-native-simple-radio-button'
import RadioButton from 'radio-button-react-native';
import {TextInput, View, Text} from 'react-native';
const RadioStyle = {
margin: 5,
width: 350,
}
const RadioTextStyle = {
marginLeft: 15,
marginTop: 2
}
const TextStyle = {
margin: 5,
marginBottom:0
}
const ViewStyle = {
backgroundColor : '#eee',
borderBottomColor : '#ccc',
borderBottomWidth : 1
}
class RadioBox extends Component {
constructor(props) {
super(props)
}
render() {
let attr = this.props.element;
// console.log(this.props.state[attr.key]);
return (<View style={ViewStyle} key={attr.key}>
<Text style={TextStyle}>{attr.label}</Text>
<View>
{attr.list.map(item =>
<View style={RadioStyle} key={item.id}>
<RadioButton currentValue={this.props.state[attr.key]} value={item.value}
onPress={(value) => this.props.changeHandler(value,attr.key) }
outerCircleWidth={3}
innerCircleSize={16}
outerCircleColor='black'
innerCircleColor='black'>
<Text style={RadioTextStyle}>{item.name}</Text>
</RadioButton>
</View>
)}
</View>
</View>)
}
}
export default RadioBox;