bare-ui-kit 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +7 -1
- package/README.md +42 -1
- package/binding.m +558 -2
- package/index.d.ts +41 -0
- package/index.js +16 -0
- package/lib/activity-indicator-view.d.ts +29 -0
- package/lib/activity-indicator-view.h +181 -0
- package/lib/activity-indicator-view.js +56 -0
- package/lib/alert-action.d.ts +33 -0
- package/lib/alert-action.js +48 -0
- package/lib/alert-controller.d.ts +20 -0
- package/lib/alert-controller.h +199 -0
- package/lib/alert-controller.js +33 -0
- package/lib/attributed-string.d.ts +45 -0
- package/lib/attributed-string.h +176 -0
- package/lib/attributed-string.js +51 -0
- package/lib/attributes.js +34 -0
- package/lib/bezier-path.d.ts +26 -0
- package/lib/bezier-path.h +145 -0
- package/lib/bezier-path.js +51 -0
- package/lib/bridging.h +600 -2
- package/lib/color.d.ts +86 -0
- package/lib/color.h +286 -0
- package/lib/color.js +170 -0
- package/lib/events.js +35 -0
- package/lib/font-descriptor.d.ts +30 -0
- package/lib/font-descriptor.h +96 -0
- package/lib/font-descriptor.js +47 -0
- package/lib/font-metrics.d.ts +38 -0
- package/lib/font-metrics.h +109 -0
- package/lib/font-metrics.js +58 -0
- package/lib/font.d.ts +59 -0
- package/lib/font.h +424 -0
- package/lib/font.js +100 -0
- package/lib/handle.d.ts +5 -0
- package/lib/handle.js +6 -0
- package/lib/image-view.d.ts +15 -0
- package/lib/image-view.h +75 -0
- package/lib/image-view.js +27 -0
- package/lib/image.d.ts +37 -0
- package/lib/image.h +205 -0
- package/lib/image.js +60 -0
- package/lib/label.d.ts +51 -0
- package/lib/label.h +331 -0
- package/lib/label.js +94 -0
- package/lib/paragraph-style.d.ts +20 -0
- package/lib/paragraph-style.h +94 -0
- package/lib/paragraph-style.js +42 -0
- package/lib/pasteboard.d.ts +31 -0
- package/lib/pasteboard.h +123 -0
- package/lib/pasteboard.js +63 -0
- package/lib/retain.js +12 -0
- package/lib/runtime.m +92 -15
- package/lib/scene.d.ts +30 -0
- package/lib/scene.h +87 -0
- package/lib/scene.js +48 -0
- package/lib/scratch.js +4 -0
- package/lib/screen.d.ts +26 -0
- package/lib/screen.h +194 -0
- package/lib/screen.js +52 -0
- package/lib/scroll-view.d.ts +39 -0
- package/lib/scroll-view.h +246 -0
- package/lib/scroll-view.js +64 -0
- package/lib/switch.d.ts +22 -0
- package/lib/switch.h +166 -0
- package/lib/switch.js +42 -0
- package/lib/text-field.d.ts +103 -0
- package/lib/text-field.h +562 -0
- package/lib/text-field.js +183 -0
- package/lib/text-view.d.ts +59 -0
- package/lib/text-view.h +497 -0
- package/lib/text-view.js +138 -0
- package/lib/view-controller.d.ts +37 -0
- package/lib/view-controller.h +108 -20
- package/lib/view-controller.js +50 -5
- package/lib/view.d.ts +158 -0
- package/lib/view.h +1385 -20
- package/lib/view.js +276 -7
- package/lib/window.d.ts +44 -0
- package/lib/window.h +167 -27
- package/lib/window.js +62 -9
- package/lib/wrap.js +7 -0
- package/package.json +12 -3
- package/prebuilds/ios-arm64/bare +0 -0
- package/prebuilds/ios-arm64/bare-ui-kit.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-ui-kit.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-ui-kit.bare +0 -0
package/lib/text-view.h
ADDED
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
#import <assert.h>
|
|
2
|
+
#import <bare.h>
|
|
3
|
+
#import <js.h>
|
|
4
|
+
|
|
5
|
+
#import <UIKit/UIKit.h>
|
|
6
|
+
|
|
7
|
+
#import "bridging.h"
|
|
8
|
+
|
|
9
|
+
enum {
|
|
10
|
+
bare_ui_kit_text_view_event_did_begin_editing = 1 << 0,
|
|
11
|
+
bare_ui_kit_text_view_event_did_end_editing = 1 << 1,
|
|
12
|
+
bare_ui_kit_text_view_event_did_change = 1 << 2,
|
|
13
|
+
bare_ui_kit_text_view_event_should_change_text = 1 << 3,
|
|
14
|
+
bare_ui_kit_text_view_event_did_change_selection = 1 << 4,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
@interface BareTextView : UITextView <UITextViewDelegate, BareEventTarget> {
|
|
18
|
+
@public
|
|
19
|
+
js_env_t *env;
|
|
20
|
+
js_ref_t *ctx;
|
|
21
|
+
|
|
22
|
+
int32_t mask;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@end
|
|
26
|
+
|
|
27
|
+
@implementation BareTextView
|
|
28
|
+
|
|
29
|
+
- (void)dealloc {
|
|
30
|
+
int err;
|
|
31
|
+
|
|
32
|
+
err = js_delete_reference(env, ctx);
|
|
33
|
+
assert(err == 0);
|
|
34
|
+
|
|
35
|
+
[super dealloc];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
- (int32_t)eventMask {
|
|
39
|
+
return mask;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (void)setEventMask:(int32_t)value {
|
|
43
|
+
mask = value;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
- (void)textViewDidBeginEditing:(UITextView *)view {
|
|
47
|
+
if ((mask & bare_ui_kit_text_view_event_did_begin_editing) == 0) return;
|
|
48
|
+
|
|
49
|
+
bare_ui_kit__emit(env, ctx, "_ondidbeginediting");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
- (void)textViewDidEndEditing:(UITextView *)view {
|
|
53
|
+
if ((mask & bare_ui_kit_text_view_event_did_end_editing) == 0) return;
|
|
54
|
+
|
|
55
|
+
bare_ui_kit__emit(env, ctx, "_ondidendediting");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void)textViewDidChange:(UITextView *)view {
|
|
59
|
+
if ((mask & bare_ui_kit_text_view_event_did_change) == 0) return;
|
|
60
|
+
|
|
61
|
+
bare_ui_kit__emit(env, ctx, "_ondidchange");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
- (void)textViewDidChangeSelection:(UITextView *)view {
|
|
65
|
+
if ((mask & bare_ui_kit_text_view_event_did_change_selection) == 0) return;
|
|
66
|
+
|
|
67
|
+
bare_ui_kit__emit(env, ctx, "_ondidchangeselection");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
- (BOOL)textView:(UITextView *)view shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)string {
|
|
71
|
+
if ((mask & bare_ui_kit_text_view_event_should_change_text) != 0) {
|
|
72
|
+
bare_ui_kit__emit_replacement(env, ctx, "_onshouldchangetext", (int32_t) range.location, (int32_t) range.length, string);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return YES;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@end
|
|
79
|
+
|
|
80
|
+
static js_value_t *
|
|
81
|
+
bare_ui_kit_text_view_init(js_env_t *env, js_callback_info_t *info) {
|
|
82
|
+
int err;
|
|
83
|
+
|
|
84
|
+
size_t argc = 5;
|
|
85
|
+
js_value_t *argv[5];
|
|
86
|
+
|
|
87
|
+
bare_ui_kit_state_t *state;
|
|
88
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
89
|
+
assert(err == 0);
|
|
90
|
+
|
|
91
|
+
assert(argc == 5);
|
|
92
|
+
|
|
93
|
+
double x;
|
|
94
|
+
if (!bare_ui_kit__read_double(env, argv[0], "x", &x)) return NULL;
|
|
95
|
+
|
|
96
|
+
double y;
|
|
97
|
+
if (!bare_ui_kit__read_double(env, argv[1], "y", &y)) return NULL;
|
|
98
|
+
|
|
99
|
+
double width;
|
|
100
|
+
if (!bare_ui_kit__read_double(env, argv[2], "width", &width)) return NULL;
|
|
101
|
+
|
|
102
|
+
double height;
|
|
103
|
+
if (!bare_ui_kit__read_double(env, argv[3], "height", &height)) return NULL;
|
|
104
|
+
|
|
105
|
+
js_value_t *result;
|
|
106
|
+
|
|
107
|
+
@autoreleasepool {
|
|
108
|
+
BareTextView *handle = [[[BareTextView alloc]
|
|
109
|
+
initWithFrame:CGRectMake(x, y, width, height)] autorelease];
|
|
110
|
+
|
|
111
|
+
result = bare_foundation_bridge(env, state->registry, handle);
|
|
112
|
+
|
|
113
|
+
handle->env = env;
|
|
114
|
+
|
|
115
|
+
err = js_create_reference(env, argv[4], 0, &handle->ctx);
|
|
116
|
+
assert(err == 0);
|
|
117
|
+
|
|
118
|
+
handle.delegate = handle;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static js_value_t *
|
|
125
|
+
bare_ui_kit_text_view_selected_range(js_env_t *env, js_callback_info_t *info) {
|
|
126
|
+
int err;
|
|
127
|
+
|
|
128
|
+
size_t argc = 3;
|
|
129
|
+
js_value_t *argv[3];
|
|
130
|
+
|
|
131
|
+
bare_ui_kit_state_t *state;
|
|
132
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
133
|
+
assert(err == 0);
|
|
134
|
+
|
|
135
|
+
assert(argc == 1 || argc == 3);
|
|
136
|
+
|
|
137
|
+
void *handle;
|
|
138
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
139
|
+
|
|
140
|
+
js_value_t *result = NULL;
|
|
141
|
+
|
|
142
|
+
@autoreleasepool {
|
|
143
|
+
UITextView *text_view = (__bridge UITextView *) handle;
|
|
144
|
+
|
|
145
|
+
if (argc == 1) {
|
|
146
|
+
result = bare_ui_kit__from_range(env, text_view.selectedRange);
|
|
147
|
+
} else {
|
|
148
|
+
int32_t location;
|
|
149
|
+
if (!bare_ui_kit__read_int32(env, argv[1], "location", &location)) return NULL;
|
|
150
|
+
|
|
151
|
+
int32_t length;
|
|
152
|
+
if (!bare_ui_kit__read_int32(env, argv[2], "length", &length)) return NULL;
|
|
153
|
+
|
|
154
|
+
text_view.selectedRange = NSMakeRange(location, length);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static js_value_t *
|
|
162
|
+
bare_ui_kit_text_view_text(js_env_t *env, js_callback_info_t *info) {
|
|
163
|
+
int err;
|
|
164
|
+
|
|
165
|
+
size_t argc = 2;
|
|
166
|
+
js_value_t *argv[2];
|
|
167
|
+
|
|
168
|
+
bare_ui_kit_state_t *state;
|
|
169
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
170
|
+
assert(err == 0);
|
|
171
|
+
|
|
172
|
+
assert(argc == 1 || argc == 2);
|
|
173
|
+
|
|
174
|
+
void *handle;
|
|
175
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
176
|
+
|
|
177
|
+
js_value_t *result = NULL;
|
|
178
|
+
|
|
179
|
+
@autoreleasepool {
|
|
180
|
+
UITextView *text_view = (__bridge UITextView *) handle;
|
|
181
|
+
|
|
182
|
+
if (argc == 1) {
|
|
183
|
+
result = bare_ui_kit__from_string(env, text_view.text);
|
|
184
|
+
} else {
|
|
185
|
+
text_view.text = bare_ui_kit__to_string(env, argv[1]);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
static js_value_t *
|
|
193
|
+
bare_ui_kit_text_view_font(js_env_t *env, js_callback_info_t *info) {
|
|
194
|
+
int err;
|
|
195
|
+
|
|
196
|
+
size_t argc = 2;
|
|
197
|
+
js_value_t *argv[2];
|
|
198
|
+
|
|
199
|
+
bare_ui_kit_state_t *state;
|
|
200
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
201
|
+
assert(err == 0);
|
|
202
|
+
|
|
203
|
+
assert(argc == 1 || argc == 2);
|
|
204
|
+
|
|
205
|
+
void *handle;
|
|
206
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
207
|
+
|
|
208
|
+
js_value_t *result = NULL;
|
|
209
|
+
|
|
210
|
+
@autoreleasepool {
|
|
211
|
+
UITextView *text_view = (__bridge UITextView *) handle;
|
|
212
|
+
|
|
213
|
+
if (argc == 1) {
|
|
214
|
+
result = bare_foundation_bridge(env, state->registry, text_view.font);
|
|
215
|
+
} else {
|
|
216
|
+
text_view.font = bare_foundation_to_object(env, state->registry, argv[1]);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
static js_value_t *
|
|
224
|
+
bare_ui_kit_text_view_text_color(js_env_t *env, js_callback_info_t *info) {
|
|
225
|
+
int err;
|
|
226
|
+
|
|
227
|
+
size_t argc = 2;
|
|
228
|
+
js_value_t *argv[2];
|
|
229
|
+
|
|
230
|
+
bare_ui_kit_state_t *state;
|
|
231
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
232
|
+
assert(err == 0);
|
|
233
|
+
|
|
234
|
+
assert(argc == 1 || argc == 2);
|
|
235
|
+
|
|
236
|
+
void *handle;
|
|
237
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
238
|
+
|
|
239
|
+
js_value_t *result = NULL;
|
|
240
|
+
|
|
241
|
+
@autoreleasepool {
|
|
242
|
+
UITextView *text_view = (__bridge UITextView *) handle;
|
|
243
|
+
|
|
244
|
+
if (argc == 1) {
|
|
245
|
+
result = bare_foundation_bridge(env, state->registry, text_view.textColor);
|
|
246
|
+
} else {
|
|
247
|
+
text_view.textColor = bare_foundation_to_object(env, state->registry, argv[1]);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return result;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
static js_value_t *
|
|
255
|
+
bare_ui_kit_text_view_text_alignment(js_env_t *env, js_callback_info_t *info) {
|
|
256
|
+
int err;
|
|
257
|
+
|
|
258
|
+
size_t argc = 2;
|
|
259
|
+
js_value_t *argv[2];
|
|
260
|
+
|
|
261
|
+
bare_ui_kit_state_t *state;
|
|
262
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
263
|
+
assert(err == 0);
|
|
264
|
+
|
|
265
|
+
assert(argc == 1 || argc == 2);
|
|
266
|
+
|
|
267
|
+
void *handle;
|
|
268
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
269
|
+
|
|
270
|
+
js_value_t *result = NULL;
|
|
271
|
+
|
|
272
|
+
@autoreleasepool {
|
|
273
|
+
UITextView *text_view = (__bridge UITextView *) handle;
|
|
274
|
+
|
|
275
|
+
if (argc == 1) {
|
|
276
|
+
err = js_create_int32(env, (int32_t) text_view.textAlignment, &result);
|
|
277
|
+
assert(err == 0);
|
|
278
|
+
} else {
|
|
279
|
+
int32_t value;
|
|
280
|
+
if (!bare_ui_kit__read_int32(env, argv[1], "text_alignment", &value)) return NULL;
|
|
281
|
+
|
|
282
|
+
text_view.textAlignment = value;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
static js_value_t *
|
|
290
|
+
bare_ui_kit_text_view_editable(js_env_t *env, js_callback_info_t *info) {
|
|
291
|
+
int err;
|
|
292
|
+
|
|
293
|
+
size_t argc = 2;
|
|
294
|
+
js_value_t *argv[2];
|
|
295
|
+
|
|
296
|
+
bare_ui_kit_state_t *state;
|
|
297
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
298
|
+
assert(err == 0);
|
|
299
|
+
|
|
300
|
+
assert(argc == 1 || argc == 2);
|
|
301
|
+
|
|
302
|
+
void *handle;
|
|
303
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
304
|
+
|
|
305
|
+
js_value_t *result = NULL;
|
|
306
|
+
|
|
307
|
+
@autoreleasepool {
|
|
308
|
+
UITextView *text_view = (__bridge UITextView *) handle;
|
|
309
|
+
|
|
310
|
+
if (argc == 1) {
|
|
311
|
+
err = js_get_boolean(env, text_view.editable, &result);
|
|
312
|
+
assert(err == 0);
|
|
313
|
+
} else {
|
|
314
|
+
bool value;
|
|
315
|
+
if (!bare_ui_kit__read_bool(env, argv[1], "editable", &value)) return NULL;
|
|
316
|
+
|
|
317
|
+
text_view.editable = value;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return result;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
static js_value_t *
|
|
325
|
+
bare_ui_kit_text_view_keyboard_type(js_env_t *env, js_callback_info_t *info) {
|
|
326
|
+
int err;
|
|
327
|
+
|
|
328
|
+
size_t argc = 2;
|
|
329
|
+
js_value_t *argv[2];
|
|
330
|
+
|
|
331
|
+
bare_ui_kit_state_t *state;
|
|
332
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
333
|
+
assert(err == 0);
|
|
334
|
+
|
|
335
|
+
assert(argc == 1 || argc == 2);
|
|
336
|
+
|
|
337
|
+
void *handle;
|
|
338
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
339
|
+
|
|
340
|
+
js_value_t *result = NULL;
|
|
341
|
+
|
|
342
|
+
@autoreleasepool {
|
|
343
|
+
UITextView *text_view = (__bridge UITextView *) handle;
|
|
344
|
+
|
|
345
|
+
if (argc == 1) {
|
|
346
|
+
err = js_create_int32(env, (int32_t) text_view.keyboardType, &result);
|
|
347
|
+
assert(err == 0);
|
|
348
|
+
} else {
|
|
349
|
+
int32_t value;
|
|
350
|
+
if (!bare_ui_kit__read_int32(env, argv[1], "keyboard_type", &value)) return NULL;
|
|
351
|
+
|
|
352
|
+
text_view.keyboardType = value;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return result;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
static js_value_t *
|
|
360
|
+
bare_ui_kit_text_view_return_key_type(js_env_t *env, js_callback_info_t *info) {
|
|
361
|
+
int err;
|
|
362
|
+
|
|
363
|
+
size_t argc = 2;
|
|
364
|
+
js_value_t *argv[2];
|
|
365
|
+
|
|
366
|
+
bare_ui_kit_state_t *state;
|
|
367
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
368
|
+
assert(err == 0);
|
|
369
|
+
|
|
370
|
+
assert(argc == 1 || argc == 2);
|
|
371
|
+
|
|
372
|
+
void *handle;
|
|
373
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
374
|
+
|
|
375
|
+
js_value_t *result = NULL;
|
|
376
|
+
|
|
377
|
+
@autoreleasepool {
|
|
378
|
+
UITextView *text_view = (__bridge UITextView *) handle;
|
|
379
|
+
|
|
380
|
+
if (argc == 1) {
|
|
381
|
+
err = js_create_int32(env, (int32_t) text_view.returnKeyType, &result);
|
|
382
|
+
assert(err == 0);
|
|
383
|
+
} else {
|
|
384
|
+
int32_t value;
|
|
385
|
+
if (!bare_ui_kit__read_int32(env, argv[1], "return_key_type", &value)) return NULL;
|
|
386
|
+
|
|
387
|
+
text_view.returnKeyType = value;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return result;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
static js_value_t *
|
|
395
|
+
bare_ui_kit_text_view_autocapitalization_type(js_env_t *env, js_callback_info_t *info) {
|
|
396
|
+
int err;
|
|
397
|
+
|
|
398
|
+
size_t argc = 2;
|
|
399
|
+
js_value_t *argv[2];
|
|
400
|
+
|
|
401
|
+
bare_ui_kit_state_t *state;
|
|
402
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
403
|
+
assert(err == 0);
|
|
404
|
+
|
|
405
|
+
assert(argc == 1 || argc == 2);
|
|
406
|
+
|
|
407
|
+
void *handle;
|
|
408
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
409
|
+
|
|
410
|
+
js_value_t *result = NULL;
|
|
411
|
+
|
|
412
|
+
@autoreleasepool {
|
|
413
|
+
UITextView *text_view = (__bridge UITextView *) handle;
|
|
414
|
+
|
|
415
|
+
if (argc == 1) {
|
|
416
|
+
err = js_create_int32(env, (int32_t) text_view.autocapitalizationType, &result);
|
|
417
|
+
assert(err == 0);
|
|
418
|
+
} else {
|
|
419
|
+
int32_t value;
|
|
420
|
+
if (!bare_ui_kit__read_int32(env, argv[1], "autocapitalization_type", &value)) return NULL;
|
|
421
|
+
|
|
422
|
+
text_view.autocapitalizationType = value;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return result;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
static js_value_t *
|
|
430
|
+
bare_ui_kit_text_view_autocorrection_type(js_env_t *env, js_callback_info_t *info) {
|
|
431
|
+
int err;
|
|
432
|
+
|
|
433
|
+
size_t argc = 2;
|
|
434
|
+
js_value_t *argv[2];
|
|
435
|
+
|
|
436
|
+
bare_ui_kit_state_t *state;
|
|
437
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
438
|
+
assert(err == 0);
|
|
439
|
+
|
|
440
|
+
assert(argc == 1 || argc == 2);
|
|
441
|
+
|
|
442
|
+
void *handle;
|
|
443
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
444
|
+
|
|
445
|
+
js_value_t *result = NULL;
|
|
446
|
+
|
|
447
|
+
@autoreleasepool {
|
|
448
|
+
UITextView *text_view = (__bridge UITextView *) handle;
|
|
449
|
+
|
|
450
|
+
if (argc == 1) {
|
|
451
|
+
err = js_create_int32(env, (int32_t) text_view.autocorrectionType, &result);
|
|
452
|
+
assert(err == 0);
|
|
453
|
+
} else {
|
|
454
|
+
int32_t value;
|
|
455
|
+
if (!bare_ui_kit__read_int32(env, argv[1], "autocorrection_type", &value)) return NULL;
|
|
456
|
+
|
|
457
|
+
text_view.autocorrectionType = value;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return result;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
static js_value_t *
|
|
465
|
+
bare_ui_kit_text_view_scroll_enabled(js_env_t *env, js_callback_info_t *info) {
|
|
466
|
+
int err;
|
|
467
|
+
|
|
468
|
+
size_t argc = 2;
|
|
469
|
+
js_value_t *argv[2];
|
|
470
|
+
|
|
471
|
+
bare_ui_kit_state_t *state;
|
|
472
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
473
|
+
assert(err == 0);
|
|
474
|
+
|
|
475
|
+
assert(argc == 1 || argc == 2);
|
|
476
|
+
|
|
477
|
+
void *handle;
|
|
478
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
479
|
+
|
|
480
|
+
js_value_t *result = NULL;
|
|
481
|
+
|
|
482
|
+
@autoreleasepool {
|
|
483
|
+
UITextView *text_view = (__bridge UITextView *) handle;
|
|
484
|
+
|
|
485
|
+
if (argc == 1) {
|
|
486
|
+
err = js_get_boolean(env, text_view.scrollEnabled, &result);
|
|
487
|
+
assert(err == 0);
|
|
488
|
+
} else {
|
|
489
|
+
bool value;
|
|
490
|
+
if (!bare_ui_kit__read_bool(env, argv[1], "scroll_enabled", &value)) return NULL;
|
|
491
|
+
|
|
492
|
+
text_view.scrollEnabled = value;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return result;
|
|
497
|
+
}
|
package/lib/text-view.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const binding = require('../binding')
|
|
2
|
+
const { adopt } = require('./handle')
|
|
3
|
+
const wrap = require('./wrap')
|
|
4
|
+
const UIKitColor = require('./color')
|
|
5
|
+
const UIKitFont = require('./font')
|
|
6
|
+
const UIKitScrollView = require('./scroll-view')
|
|
7
|
+
|
|
8
|
+
module.exports = exports = class UIKitTextView extends UIKitScrollView {
|
|
9
|
+
_init(opts) {
|
|
10
|
+
const { x = 0, y = 0, width = 0, height = 0 } = opts
|
|
11
|
+
|
|
12
|
+
return binding.textViewInit(x, y, width, height, this)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get text() {
|
|
16
|
+
return binding.textViewText(this._tag)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
set text(text) {
|
|
20
|
+
binding.textViewText(this._tag, text)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get font() {
|
|
24
|
+
return wrap(UIKitFont, binding.textViewFont(this._tag))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
set font(font) {
|
|
28
|
+
binding.textViewFont(this._tag, adopt(font))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get textColor() {
|
|
32
|
+
return wrap(UIKitColor, binding.textViewTextColor(this._tag))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
set textColor(textColor) {
|
|
36
|
+
binding.textViewTextColor(this._tag, adopt(textColor))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get textAlignment() {
|
|
40
|
+
return binding.textViewTextAlignment(this._tag)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
set textAlignment(textAlignment) {
|
|
44
|
+
binding.textViewTextAlignment(this._tag, textAlignment)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get editable() {
|
|
48
|
+
return binding.textViewEditable(this._tag)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
set editable(editable) {
|
|
52
|
+
binding.textViewEditable(this._tag, editable)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get keyboardType() {
|
|
56
|
+
return binding.textViewKeyboardType(this._tag)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
set keyboardType(keyboardType) {
|
|
60
|
+
binding.textViewKeyboardType(this._tag, keyboardType)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get returnKeyType() {
|
|
64
|
+
return binding.textViewReturnKeyType(this._tag)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
set returnKeyType(returnKeyType) {
|
|
68
|
+
binding.textViewReturnKeyType(this._tag, returnKeyType)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get autocapitalizationType() {
|
|
72
|
+
return binding.textViewAutocapitalizationType(this._tag)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
set autocapitalizationType(autocapitalizationType) {
|
|
76
|
+
binding.textViewAutocapitalizationType(this._tag, autocapitalizationType)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get autocorrectionType() {
|
|
80
|
+
return binding.textViewAutocorrectionType(this._tag)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
set autocorrectionType(autocorrectionType) {
|
|
84
|
+
binding.textViewAutocorrectionType(this._tag, autocorrectionType)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get scrollEnabled() {
|
|
88
|
+
return binding.textViewScrollEnabled(this._tag)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
set scrollEnabled(scrollEnabled) {
|
|
92
|
+
binding.textViewScrollEnabled(this._tag, scrollEnabled)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
get selectedRange() {
|
|
96
|
+
return binding.textViewSelectedRange(this._tag)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
set selectedRange(selectedRange) {
|
|
100
|
+
const { location = 0, length = 0 } = selectedRange
|
|
101
|
+
|
|
102
|
+
binding.textViewSelectedRange(this._tag, location, length)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
[Symbol.for('bare.inspect')]() {
|
|
106
|
+
return {
|
|
107
|
+
__proto__: { constructor: UIKitTextView }
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
_ondidbeginediting() {
|
|
112
|
+
this.emit('didBeginEditing')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
_ondidendediting() {
|
|
116
|
+
this.emit('didEndEditing')
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_ondidchange() {
|
|
120
|
+
this.emit('didChange')
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
_ondidchangeselection() {
|
|
124
|
+
this.emit('didChangeSelection')
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
_onshouldchangetext(location, length, string) {
|
|
128
|
+
this.emit('shouldChangeText', { location, length, string })
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
exports._events = {
|
|
133
|
+
didBeginEditing: binding.TEXT_VIEW_EVENT_DID_BEGIN_EDITING,
|
|
134
|
+
didEndEditing: binding.TEXT_VIEW_EVENT_DID_END_EDITING,
|
|
135
|
+
didChange: binding.TEXT_VIEW_EVENT_DID_CHANGE,
|
|
136
|
+
shouldChangeText: binding.TEXT_VIEW_EVENT_SHOULD_CHANGE_TEXT,
|
|
137
|
+
didChangeSelection: binding.TEXT_VIEW_EVENT_DID_CHANGE_SELECTION
|
|
138
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import EventEmitter from 'bare-events'
|
|
2
|
+
import { tag, handle, Handle, Wrapper } from 'bare-foundation-registry'
|
|
3
|
+
import UIKitView = require('./view')
|
|
4
|
+
|
|
5
|
+
/** Manages a view, as a `UIViewController`. */
|
|
6
|
+
interface UIKitViewController<
|
|
7
|
+
M extends Record<keyof M, unknown[]> = UIKitViewController.Events
|
|
8
|
+
> extends EventEmitter<M> {
|
|
9
|
+
get view(): UIKitView | null
|
|
10
|
+
set view(view: Wrapper | null)
|
|
11
|
+
|
|
12
|
+
/** Show `controller` over this one. */
|
|
13
|
+
present(controller: Wrapper, animated?: boolean): this
|
|
14
|
+
|
|
15
|
+
/** Close the controller this one presented, or this one if it was presented. */
|
|
16
|
+
dismiss(animated?: boolean): this
|
|
17
|
+
|
|
18
|
+
readonly [tag]: number
|
|
19
|
+
|
|
20
|
+
readonly [handle]: Handle
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare class UIKitViewController<
|
|
24
|
+
M extends Record<keyof M, unknown[]> = UIKitViewController.Events
|
|
25
|
+
> {
|
|
26
|
+
constructor()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare namespace UIKitViewController {
|
|
30
|
+
export interface Events {
|
|
31
|
+
/** The view was laid out, for example because the window changed size. */
|
|
32
|
+
didLayoutSubviews: []
|
|
33
|
+
safeAreaInsetsDidChange: []
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export = UIKitViewController
|