-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathInputExample.re
142 lines (135 loc) · 3.48 KB
/
InputExample.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
open Revery;
open Revery.UI;
open Revery.UI.Components;
let containerStyle =
Style.[
position(`Absolute),
top(0),
bottom(0),
left(0),
right(0),
alignItems(`Center),
justifyContent(`Center),
flexDirection(`Column),
];
let controlsStyle =
Style.[
margin(10),
flexDirection(`Row),
justifyContent(`Center),
alignItems(`Center),
];
let textStyle =
Style.[
color(Colors.white),
width(100),
margin(14),
textWrap(TextWrapping.NoWrap),
];
module Example = {
type inputFields = {
first: string,
second: string,
third: string,
isPassword: bool,
};
let%component make = () => {
let%hook ({first, isPassword, _}, setValue) =
Hooks.state({first: "", second: "", third: "", isPassword: false});
<View style=containerStyle>
<View
style=Style.[
flexDirection(`Row),
alignItems(`Center),
justifyContent(`Center),
]>
<Input
placeholder="Insert text here"
onChange={(value, _) =>
setValue(state => {...state, first: value})
}
value=first
/>
<Button
height=50
width=100
fontSize=15.
title="Reset"
onClick={() => setValue(state => {...state, first: ""})}
/>
<Button
height=50
width=100
fontSize=15.
title="Set value"
onClick={() => setValue(state => {...state, first: "New value"})}
/>
<Button
height=50
width=100
fontSize=15.
title="Emoji"
onClick={() => Native.Input.openEmojiPanel()}
/>
</View>
<Padding padding=20>
<View
style=Style.[
flexDirection(`Row),
alignItems(`Center),
justifyContent(`Center),
]>
<Input
placeholder="Insert text here"
onChange={(value, _) =>
setValue(state => {...state, first: value})
}
value=first
isPassword
/>
<View style=controlsStyle>
<Text fontSize=16. style=textStyle text="Obscure Input" />
<Checkbox
checkedColor=Colors.green
onChange={() =>
setValue(state => {...state, isPassword: !state.isPassword})
}
style=Style.[border(~width=2, ~color=Colors.green)]
checked=isPassword
/>
</View>
</View>
</Padding>
<Padding padding=20>
<BoxShadow
boxShadow={Style.BoxShadow.make(
~xOffset=-5.,
~yOffset=2.,
~color=Colors.black,
~blurRadius=20.,
~spreadRadius=0.,
(),
)}>
<Input
placeholder="custom input"
placeholderColor=Colors.plum
cursorColor=Colors.white
autofocus=true
onFocus={() => print_endline("Input example focused")}
onBlur={() => print_endline("Input example blurred")}
onChange={(value, _) =>
setValue(state => {...state, second: value})
}
onKeyDown={_ => print_endline("key event")}
style=Style.[
backgroundColor(Colors.paleVioletRed),
color(Colors.white),
height(50),
]
/>
</BoxShadow>
</Padding>
</View>;
};
};
let render = () => <Example />;