-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRadioButton.tsx
More file actions
45 lines (41 loc) · 1.02 KB
/
RadioButton.tsx
File metadata and controls
45 lines (41 loc) · 1.02 KB
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
import React from 'react';
import {StyleSheet, View, Text, TouchableOpacity} from 'react-native';
import {RadioButtonProps} from './App';
const RadioButton = (props: RadioButtonProps) => {
const {item, selected, onSelected} = props;
return (
<TouchableOpacity
style={styles.radioButton}
onPress={() => onSelected(item)}>
<Text>{item.name}</Text>
<View style={styles.button}>
{selected?.id === item.id && <View style={styles.selectedButton} />}
</View>
</TouchableOpacity>
);
};
const styles = StyleSheet.create({
radioButton: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: '#e5e5e5',
padding: 12,
},
button: {
height: 24,
width: 24,
borderRadius: 24,
borderWidth: 2,
borderColor: '#999',
alignItems: 'center',
justifyContent: 'center',
},
selectedButton: {
width: 14,
height: 14,
borderRadius: 14,
backgroundColor: '#1976d2',
},
});
export default RadioButton;