forked from revery-ui/revery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckboxExample.re
67 lines (61 loc) · 1.66 KB
/
CheckboxExample.re
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
open Revery;
open Revery.UI;
open Revery.UI.Components;
module Check = {
type checkboxState = {
first: bool,
second: bool,
};
let getCheckboxText = checked => checked ? "Checked!" : "Not Checked!";
let component = React.component("Check");
let createElement = (~children as _, ()) =>
component(hooks => {
let initialCheckboxState = {first: false, second: true};
let ({first, second}, setCheckboxState, hooks) =
Hooks.state(initialCheckboxState, hooks);
(
hooks,
<View
style=Style.[
width(500),
height(500),
justifyContent(`Center),
alignItems(`Center),
]>
<Checkbox
checked=first
onChange={() => setCheckboxState({first: !first, second})}
style=Style.[marginBottom(10)]
/>
<Text
text={getCheckboxText(first)}
style=Style.[
marginBottom(10),
fontFamily("Roboto-Regular.ttf"),
fontSize(20),
]
/>
<Checkbox
checkedColor=Colors.green
onChange={() => setCheckboxState({second: !second, first})}
style=Style.[border(~width=2, ~color=Colors.green)]
checked=second
/>
<Text
text={
"Default state: "
++ getCheckboxText(initialCheckboxState.second)
}
style=Style.[
marginTop(10),
fontFamily("Roboto-Regular.ttf"),
fontSize(20),
]
/>
</View>,
);
});
};
let render = () => {
<Check />;
};