forked from callstack/react-native-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSegmentedButtonCustomColorCheck.tsx
93 lines (86 loc) · 2.32 KB
/
SegmentedButtonCustomColorCheck.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
82
83
84
85
86
87
88
89
90
91
92
93
import * as React from 'react';
import { StyleSheet } from 'react-native';
import { List, SegmentedButtons } from 'react-native-paper';
type TransportMode = 'walk' | 'train' | 'drive';
const themeMock = {
colors: {
onSurface: '#3700B3',
secondaryContainer: '#3700B3',
onSecondaryContainer: '#FFFFFF',
},
};
const SegmentButtonCustomColorCheck = () => {
const [themeValue, setThemeValue] = React.useState<TransportMode>('walk');
const [colorValue, setColorValue] = React.useState<TransportMode>('walk');
return (
<List.Section title={`Segmented Button - Custom Colors`}>
<List.Subheader>Via Theme</List.Subheader>
<SegmentedButtons<TransportMode>
value={themeValue}
onValueChange={setThemeValue}
theme={themeMock}
buttons={[
{
value: 'walk',
icon: 'walk',
label: 'Walking',
disabled: true,
style: styles.button,
},
{
value: 'train',
icon: 'train',
label: 'Transit',
style: styles.button,
},
{
value: 'drive',
icon: 'car',
label: 'Driving',
style: styles.button,
},
]}
style={styles.group}
/>
<List.Subheader>Via Props</List.Subheader>
<SegmentedButtons<TransportMode>
value={colorValue}
onValueChange={setColorValue}
theme={themeMock}
buttons={[
{
value: 'walk',
icon: 'walk',
label: 'Walking',
checkedColor: '#F9AA33',
style: styles.button,
},
{
value: 'train',
icon: 'train',
showSelectedCheck: true,
checkedColor: '#F9AA33',
uncheckedColor: '#000000',
label: 'Transit',
style: styles.button,
},
{
value: 'drive',
icon: 'car',
checkedColor: '#F9AA33',
label: 'Driving',
style: styles.button,
},
]}
style={styles.group}
/>
</List.Section>
);
};
const styles = StyleSheet.create({
button: {
flex: 1,
},
group: { paddingHorizontal: 20, justifyContent: 'center' },
});
export default SegmentButtonCustomColorCheck;