-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathCheckboxExample.tsx
More file actions
76 lines (66 loc) · 2.22 KB
/
CheckboxExample.tsx
File metadata and controls
76 lines (66 loc) · 2.22 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
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
import * as React from 'react';
import { StyleSheet, View } from 'react-native';
import { Checkbox, Colors, Text, TouchableRipple } from 'react-native-paper';
import ScreenWrapper from '../ScreenWrapper';
const CheckboxExample = () => {
const [checkedNormal, setCheckedNormal] = React.useState<boolean>(true);
const [checkedCustom, setCheckedCustom] = React.useState<boolean>(true);
const [indeterminate, setIndeterminate] = React.useState<boolean>(true);
return (
<ScreenWrapper style={styles.container}>
<TouchableRipple onPress={() => setCheckedNormal(!checkedNormal)}>
<View style={styles.row}>
<Text>Normal</Text>
<View pointerEvents="none">
<Checkbox status={checkedNormal ? 'checked' : 'unchecked'} />
</View>
</View>
</TouchableRipple>
<TouchableRipple onPress={() => setCheckedCustom(!checkedCustom)}>
<View style={styles.row}>
<Text>Custom</Text>
<View pointerEvents="none">
<Checkbox
color={Colors.error70}
status={checkedCustom ? 'checked' : 'unchecked'}
/>
</View>
</View>
</TouchableRipple>
<TouchableRipple onPress={() => setIndeterminate(!indeterminate)}>
<View style={styles.row}>
<Text>Indeterminate</Text>
<View pointerEvents="none">
<Checkbox status={indeterminate ? 'indeterminate' : 'unchecked'} />
</View>
</View>
</TouchableRipple>
<View style={styles.row}>
<Text>Checked (Disabled)</Text>
<Checkbox status="checked" disabled />
</View>
<View style={styles.row}>
<Text>Unchecked (Disabled)</Text>
<Checkbox status="unchecked" disabled />
</View>
<View style={styles.row}>
<Text>Indeterminate (Disabled)</Text>
<Checkbox status="indeterminate" disabled />
</View>
</ScreenWrapper>
);
};
CheckboxExample.title = 'Checkbox';
const styles = StyleSheet.create({
container: {
paddingVertical: 8,
},
row: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingVertical: 8,
paddingHorizontal: 16,
},
});
export default CheckboxExample;