forked from react-native-oh-library/RNOHDCS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckboxDemo.tsx
More file actions
75 lines (67 loc) · 2.21 KB
/
CheckboxDemo.tsx
File metadata and controls
75 lines (67 loc) · 2.21 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
import React, { useState } from 'react';
import { StyleSheet, Text, View, Image, TextInput } from 'react-native';
import CheckBox from '@react-native-community/checkbox';
const CheckboxDemo = () => {
const [toggleCheckBox, setToggleCheckBox] = useState(true)
const [value, setValue] = useState(true)
const [msg, setMsg] = useState("init")
const [msg2, setMsg2] = useState("init2")
return (
<View style={styles.checkStyle}>
<CheckBox
disabled={false}
value={toggleCheckBox}
style={{ width: 70, height: 70 }}
tintColor={'red'}
onCheckColor={'green'}
onChange={(event) => {
console.log("" + event.nativeEvent.value)
setMsg2("onChange" + event.nativeEvent.target)
setValue(event.nativeEvent.value)
}}
markSize={70}
strokeColor={'yellow'}
strokeWidth={5}
onValueChange={(newValue) => {
setToggleCheckBox(newValue)
setMsg("onValueChange----")
}}
/>
<CheckBox/>
<CheckBox style={{ width: 70, height: 70 }}/>
<CheckBox
style={{ width: 70, height: 70 }}
markSize={70}
strokeWidth={5}
/>
<CheckBox
style={{ width: 70, height: 70 }}
markSize={140}
strokeWidth={5}
/>
<Text style={styles.text}>{toggleCheckBox ? "1" : "0"}</Text>
<Text style={styles.text}>{value ? "1" : "0"}</Text>
<Text style={styles.text}>{msg}</Text>
<Text style={styles.text}>{msg2}</Text>
</View>
)
}
const styles = StyleSheet.create({
maskedView: {
width: '100%',
height: '40%'
},
checkStyle: {
backgroundColor: 'transparent',
alignItems: 'flex-start',
width: '100%',
height: '100%',
justifyContent: 'flex-start',
},
text: {
width: '100%',
height: 20,
fontSize: 14,
},
});
export default CheckboxDemo