Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 19 additions & 31 deletions src/components/Radio.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
View, StyleSheet, Text, Image, TouchableOpacity
} from 'react-native';
import { radioButton } from '../constant';
import PropTypes from "prop-types";
import React from "react";
import { Image, StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { radioButton } from "../constant";

export default function Radio(props) {
const {
name, value, meta, onChangeInputValue, isMandatory
} = props;
const { name, value, meta, onChangeInputValue, isMandatory } = props;

const onPress = value => () => onChangeInputValue(value);
const onPress = (value) => () => onChangeInputValue(value);

return (
<View key={name} style={styles.container}>
<Text style={styles.heading}>{`${meta.text} ${isMandatory ? '*' : ''}`}</Text>
<Text style={styles.heading}>{`${meta.text} ${isMandatory ? "*" : ""}`}</Text>
{meta.data.map((item, index) => (
<View key={index} style={styles.radioContainer}>
<TouchableOpacity
onPressIn={onPress(item.value || item.label)}
hitSlop={styles.slop}
style={styles.buttonContainer}
key={index}
>
<TouchableOpacity onPressIn={onPress(item.value || item.label)} hitSlop={styles.slop} style={styles.buttonContainer} key={index}>
<Image
accessibilityLabel={`choose-option-${item.label}`}
style={styles.radioButtonImage}
source={
value === (item.value || item.label)
? radioButton.selected
: radioButton.unselected
}
source={value === (item.value || item.label) ? radioButton.selected : radioButton.unselected}
/>
<Text style={styles.text}>{item.label}</Text>
</TouchableOpacity>
Expand All @@ -39,43 +26,44 @@ export default function Radio(props) {
</View>
);
}

test sse;
dasd;
const styles = StyleSheet.create({
container: {
borderRadius: 2
borderRadius: 2,
},
buttonContainer: {
flexDirection: 'row'
flexDirection: "row",
},
radioButtonImage: {
height: 20,
width: 20,
resizeMode: 'contain'
resizeMode: "contain",
},
text: {
paddingLeft: 10,
},
heading: {
margin: 10
margin: 10,
},
slop: {
top: 10,
bottom: 10,
left: 10,
right: 10
right: 10,
},
radioContainer: {
paddingVertical: 10,
width: '100%',
width: "100%",
height: 40,
paddingLeft: 10,
}
},
});

Radio.propTypes = {
name: PropTypes.string.isRequired,
meta: PropTypes.object.isRequired,
value: PropTypes.string,
onChangeInputValue: PropTypes.func,
isMandatory: PropTypes.bool
isMandatory: PropTypes.bool,
};