Add dot when active
This commit is contained in:
@@ -12,10 +12,8 @@ export default class RadioButton extends Component {
|
|||||||
<View style={styles.radioButtonGroup}>
|
<View style={styles.radioButtonGroup}>
|
||||||
{
|
{
|
||||||
this.props.buttons.map(({ label, value }) => {
|
this.props.buttons.map(({ label, value }) => {
|
||||||
|
const isActive = value === this.props.active
|
||||||
const circleStyle = [styles.radioButton]
|
const circleStyle = [styles.radioButton]
|
||||||
if (value === this.props.active) {
|
|
||||||
circleStyle.push(styles.radioButtonActive)
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => this.props.onSelect(value)}
|
onPress={() => this.props.onSelect(value)}
|
||||||
@@ -23,7 +21,10 @@ export default class RadioButton extends Component {
|
|||||||
activeOpacity={1}
|
activeOpacity={1}
|
||||||
>
|
>
|
||||||
<View style={styles.radioButtonTextGroup}>
|
<View style={styles.radioButtonTextGroup}>
|
||||||
<View style={circleStyle} />
|
<View style={circleStyle}>
|
||||||
|
{isActive ?
|
||||||
|
<View style={styles.radioButtonActiveDot}/> : null}
|
||||||
|
</View>
|
||||||
<Text>{label}</Text>
|
<Text>{label}</Text>
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|||||||
+10
-6
@@ -209,17 +209,21 @@ export default StyleSheet.create({
|
|||||||
marginVertical: 10,
|
marginVertical: 10,
|
||||||
},
|
},
|
||||||
radioButton: {
|
radioButton: {
|
||||||
width: 30,
|
width: 20,
|
||||||
height: 30,
|
height: 20,
|
||||||
borderRadius: 100,
|
borderRadius: 100,
|
||||||
borderStyle: 'solid',
|
borderStyle: 'solid',
|
||||||
borderWidth: 2,
|
borderWidth: 2,
|
||||||
borderColor: secondaryColor,
|
borderColor: secondaryColor,
|
||||||
marginBottom: 5
|
marginBottom: 5,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center'
|
||||||
},
|
},
|
||||||
radioButtonActive: {
|
radioButtonActiveDot: {
|
||||||
backgroundColor: secondaryColor,
|
width: 10,
|
||||||
color: fontOnPrimaryColor
|
height: 10,
|
||||||
|
borderRadius: 100,
|
||||||
|
backgroundColor: secondaryColor
|
||||||
},
|
},
|
||||||
radioButtonGroup: {
|
radioButtonGroup: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
|||||||
Reference in New Issue
Block a user