forked from callstack/react-native-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRadioButtonGroupExample.tsx
81 lines (76 loc) · 2.03 KB
/
RadioButtonGroupExample.tsx
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import {
Colors,
RadioButton,
Paragraph,
List,
useTheme,
} from 'react-native-paper';
const RadioButtonGroupExample = () => {
const [value, setValue] = React.useState<string>('first');
const [value2, setValue2] = React.useState<string>('first');
const {
colors: { background, primary },
} = useTheme();
return (
<View
style={[
styles.container,
{
backgroundColor: background,
},
]}
>
<List.Section title="With RadioButton">
<RadioButton.Group
value={value}
onValueChange={(value: string) => setValue(value)}
>
<View style={styles.row}>
<Paragraph>First</Paragraph>
<RadioButton value="first" />
</View>
<View style={styles.row}>
<Paragraph>Second</Paragraph>
<RadioButton.Android value="second" />
</View>
<View style={styles.row}>
<Paragraph>Third</Paragraph>
<RadioButton.IOS value="third" />
</View>
</RadioButton.Group>
</List.Section>
<List.Section title="With RadioButton.Item">
<RadioButton.Group
value={value2}
onValueChange={(value: string) => setValue2(value)}
>
<RadioButton.Item label="First item" value="first" />
<RadioButton.Item label="Second item" value="second" />
<RadioButton.Item
label="Third item"
value="third"
labelStyle={{ color: primary }}
/>
</RadioButton.Group>
</List.Section>
</View>
);
};
RadioButtonGroupExample.title = 'Radio Button Group';
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.white,
padding: 8,
},
row: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingVertical: 8,
paddingHorizontal: 16,
},
});
export default RadioButtonGroupExample;