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/color.h
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
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
|
+
// The list every system colour is generated from: the ids below, the switch in
|
|
10
|
+
// `bare_ui_kit_color_system()`, and the constants in `binding.m`.
|
|
11
|
+
#define BARE_UI_KIT_COLORS(V) \
|
|
12
|
+
V(BLACK, blackColor) \
|
|
13
|
+
V(WHITE, whiteColor) \
|
|
14
|
+
V(CLEAR, clearColor) \
|
|
15
|
+
V(LABEL, labelColor) \
|
|
16
|
+
V(SECONDARY_LABEL, secondaryLabelColor) \
|
|
17
|
+
V(TERTIARY_LABEL, tertiaryLabelColor) \
|
|
18
|
+
V(QUATERNARY_LABEL, quaternaryLabelColor) \
|
|
19
|
+
V(PLACEHOLDER_TEXT, placeholderTextColor) \
|
|
20
|
+
V(SEPARATOR, separatorColor) \
|
|
21
|
+
V(OPAQUE_SEPARATOR, opaqueSeparatorColor) \
|
|
22
|
+
V(LINK, linkColor) \
|
|
23
|
+
V(SYSTEM_BACKGROUND, systemBackgroundColor) \
|
|
24
|
+
V(SECONDARY_SYSTEM_BACKGROUND, secondarySystemBackgroundColor) \
|
|
25
|
+
V(TERTIARY_SYSTEM_BACKGROUND, tertiarySystemBackgroundColor) \
|
|
26
|
+
V(SYSTEM_GROUPED_BACKGROUND, systemGroupedBackgroundColor) \
|
|
27
|
+
V(SYSTEM_FILL, systemFillColor) \
|
|
28
|
+
V(TINT, tintColor) \
|
|
29
|
+
V(SYSTEM_RED, systemRedColor) \
|
|
30
|
+
V(SYSTEM_ORANGE, systemOrangeColor) \
|
|
31
|
+
V(SYSTEM_YELLOW, systemYellowColor) \
|
|
32
|
+
V(SYSTEM_GREEN, systemGreenColor) \
|
|
33
|
+
V(SYSTEM_MINT, systemMintColor) \
|
|
34
|
+
V(SYSTEM_TEAL, systemTealColor) \
|
|
35
|
+
V(SYSTEM_CYAN, systemCyanColor) \
|
|
36
|
+
V(SYSTEM_BLUE, systemBlueColor) \
|
|
37
|
+
V(SYSTEM_INDIGO, systemIndigoColor) \
|
|
38
|
+
V(SYSTEM_PURPLE, systemPurpleColor) \
|
|
39
|
+
V(SYSTEM_PINK, systemPinkColor) \
|
|
40
|
+
V(SYSTEM_BROWN, systemBrownColor) \
|
|
41
|
+
V(SYSTEM_GRAY, systemGrayColor)
|
|
42
|
+
|
|
43
|
+
enum {
|
|
44
|
+
#define V(name, selector) bare_ui_kit_color_##name,
|
|
45
|
+
BARE_UI_KIT_COLORS(V)
|
|
46
|
+
#undef V
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
static js_value_t *
|
|
50
|
+
bare_ui_kit_color_system(js_env_t *env, js_callback_info_t *info) {
|
|
51
|
+
int err;
|
|
52
|
+
|
|
53
|
+
size_t argc = 1;
|
|
54
|
+
js_value_t *argv[1];
|
|
55
|
+
|
|
56
|
+
bare_ui_kit_state_t *state;
|
|
57
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
58
|
+
assert(err == 0);
|
|
59
|
+
|
|
60
|
+
assert(argc == 1);
|
|
61
|
+
|
|
62
|
+
int32_t id;
|
|
63
|
+
if (!bare_ui_kit__read_int32(env, argv[0], "id", &id)) return NULL;
|
|
64
|
+
|
|
65
|
+
js_value_t *result;
|
|
66
|
+
|
|
67
|
+
@autoreleasepool {
|
|
68
|
+
UIColor *color = nil;
|
|
69
|
+
|
|
70
|
+
switch (id) {
|
|
71
|
+
#define V(name, selector) \
|
|
72
|
+
case bare_ui_kit_color_##name: \
|
|
73
|
+
color = [UIColor selector]; \
|
|
74
|
+
break;
|
|
75
|
+
BARE_UI_KIT_COLORS(V)
|
|
76
|
+
#undef V
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
result = bare_foundation_bridge(env, state->registry, color);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static js_value_t *
|
|
86
|
+
bare_ui_kit_color_rgb(js_env_t *env, js_callback_info_t *info) {
|
|
87
|
+
int err;
|
|
88
|
+
|
|
89
|
+
size_t argc = 4;
|
|
90
|
+
js_value_t *argv[4];
|
|
91
|
+
|
|
92
|
+
bare_ui_kit_state_t *state;
|
|
93
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
94
|
+
assert(err == 0);
|
|
95
|
+
|
|
96
|
+
assert(argc == 4);
|
|
97
|
+
|
|
98
|
+
double red;
|
|
99
|
+
if (!bare_ui_kit__read_double(env, argv[0], "red", &red)) return NULL;
|
|
100
|
+
|
|
101
|
+
double green;
|
|
102
|
+
if (!bare_ui_kit__read_double(env, argv[1], "green", &green)) return NULL;
|
|
103
|
+
|
|
104
|
+
double blue;
|
|
105
|
+
if (!bare_ui_kit__read_double(env, argv[2], "blue", &blue)) return NULL;
|
|
106
|
+
|
|
107
|
+
double alpha;
|
|
108
|
+
if (!bare_ui_kit__read_double(env, argv[3], "alpha", &alpha)) return NULL;
|
|
109
|
+
|
|
110
|
+
js_value_t *result;
|
|
111
|
+
|
|
112
|
+
@autoreleasepool {
|
|
113
|
+
result = bare_foundation_bridge(env, state->registry, [UIColor colorWithRed:red green:green blue:blue alpha:alpha]);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static js_value_t *
|
|
120
|
+
bare_ui_kit_color_hsb(js_env_t *env, js_callback_info_t *info) {
|
|
121
|
+
int err;
|
|
122
|
+
|
|
123
|
+
size_t argc = 4;
|
|
124
|
+
js_value_t *argv[4];
|
|
125
|
+
|
|
126
|
+
bare_ui_kit_state_t *state;
|
|
127
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
128
|
+
assert(err == 0);
|
|
129
|
+
|
|
130
|
+
assert(argc == 4);
|
|
131
|
+
|
|
132
|
+
double hue;
|
|
133
|
+
if (!bare_ui_kit__read_double(env, argv[0], "hue", &hue)) return NULL;
|
|
134
|
+
|
|
135
|
+
double saturation;
|
|
136
|
+
if (!bare_ui_kit__read_double(env, argv[1], "saturation", &saturation)) return NULL;
|
|
137
|
+
|
|
138
|
+
double brightness;
|
|
139
|
+
if (!bare_ui_kit__read_double(env, argv[2], "brightness", &brightness)) return NULL;
|
|
140
|
+
|
|
141
|
+
double alpha;
|
|
142
|
+
if (!bare_ui_kit__read_double(env, argv[3], "alpha", &alpha)) return NULL;
|
|
143
|
+
|
|
144
|
+
js_value_t *result;
|
|
145
|
+
|
|
146
|
+
@autoreleasepool {
|
|
147
|
+
result = bare_foundation_bridge(env, state->registry, [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:alpha]);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static js_value_t *
|
|
154
|
+
bare_ui_kit_color_white(js_env_t *env, js_callback_info_t *info) {
|
|
155
|
+
int err;
|
|
156
|
+
|
|
157
|
+
size_t argc = 2;
|
|
158
|
+
js_value_t *argv[2];
|
|
159
|
+
|
|
160
|
+
bare_ui_kit_state_t *state;
|
|
161
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
162
|
+
assert(err == 0);
|
|
163
|
+
|
|
164
|
+
assert(argc == 2);
|
|
165
|
+
|
|
166
|
+
double white;
|
|
167
|
+
if (!bare_ui_kit__read_double(env, argv[0], "white", &white)) return NULL;
|
|
168
|
+
|
|
169
|
+
double alpha;
|
|
170
|
+
if (!bare_ui_kit__read_double(env, argv[1], "alpha", &alpha)) return NULL;
|
|
171
|
+
|
|
172
|
+
js_value_t *result;
|
|
173
|
+
|
|
174
|
+
@autoreleasepool {
|
|
175
|
+
result = bare_foundation_bridge(env, state->registry, [UIColor colorWithWhite:white alpha:alpha]);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
static js_value_t *
|
|
182
|
+
bare_ui_kit_color_with_alpha_component(js_env_t *env, js_callback_info_t *info) {
|
|
183
|
+
int err;
|
|
184
|
+
|
|
185
|
+
size_t argc = 2;
|
|
186
|
+
js_value_t *argv[2];
|
|
187
|
+
|
|
188
|
+
bare_ui_kit_state_t *state;
|
|
189
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
190
|
+
assert(err == 0);
|
|
191
|
+
|
|
192
|
+
assert(argc == 2);
|
|
193
|
+
|
|
194
|
+
void *handle;
|
|
195
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
196
|
+
|
|
197
|
+
double alpha;
|
|
198
|
+
if (!bare_ui_kit__read_double(env, argv[1], "alpha", &alpha)) return NULL;
|
|
199
|
+
|
|
200
|
+
js_value_t *result;
|
|
201
|
+
|
|
202
|
+
@autoreleasepool {
|
|
203
|
+
UIColor *color = (__bridge UIColor *) handle;
|
|
204
|
+
|
|
205
|
+
result = bare_foundation_bridge(env, state->registry, [color colorWithAlphaComponent:alpha]);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// A colour that has no RGBA value, such as a pattern, reports zeroes.
|
|
212
|
+
static js_value_t *
|
|
213
|
+
bare_ui_kit_color_components_into(js_env_t *env, js_callback_info_t *info) {
|
|
214
|
+
int err;
|
|
215
|
+
|
|
216
|
+
size_t argc = 3;
|
|
217
|
+
js_value_t *argv[3];
|
|
218
|
+
|
|
219
|
+
bare_ui_kit_state_t *state;
|
|
220
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
221
|
+
assert(err == 0);
|
|
222
|
+
|
|
223
|
+
assert(argc == 3);
|
|
224
|
+
|
|
225
|
+
void *handle;
|
|
226
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
227
|
+
|
|
228
|
+
uint32_t offset;
|
|
229
|
+
if (!bare_ui_kit__read_uint32(env, argv[2], "offset", &offset)) return NULL;
|
|
230
|
+
|
|
231
|
+
double *out;
|
|
232
|
+
|
|
233
|
+
if (!bare_ui_kit__buffer(env, argv[1], offset, 4, &out)) {
|
|
234
|
+
err = js_throw_type_error(env, NULL, "Expected an array buffer with room for 4 doubles");
|
|
235
|
+
assert(err == 0);
|
|
236
|
+
|
|
237
|
+
return NULL;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@autoreleasepool {
|
|
241
|
+
UIColor *color = (__bridge UIColor *) handle;
|
|
242
|
+
|
|
243
|
+
CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
|
244
|
+
|
|
245
|
+
[color getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
246
|
+
|
|
247
|
+
out[0] = red;
|
|
248
|
+
out[1] = green;
|
|
249
|
+
out[2] = blue;
|
|
250
|
+
out[3] = alpha;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return NULL;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
static void
|
|
257
|
+
bare_ui_kit_color_components_into_typed(js_value_t *receiver, int32_t bare_tag, js_value_t *bare_buffer, uint32_t bare_offset, js_typed_callback_info_t *info) {
|
|
258
|
+
int err;
|
|
259
|
+
|
|
260
|
+
bare_ui_kit_state_t *state;
|
|
261
|
+
|
|
262
|
+
js_env_t *env;
|
|
263
|
+
err = js_get_typed_callback_info(info, &env, (void **) &state);
|
|
264
|
+
assert(err == 0);
|
|
265
|
+
|
|
266
|
+
id bare_object = bare_foundation_object(state->registry, bare_tag);
|
|
267
|
+
|
|
268
|
+
if (bare_object == nil) return;
|
|
269
|
+
|
|
270
|
+
double *out;
|
|
271
|
+
|
|
272
|
+
if (!bare_ui_kit__buffer(env, bare_buffer, bare_offset, 4, &out)) return;
|
|
273
|
+
|
|
274
|
+
@autoreleasepool {
|
|
275
|
+
UIColor *color = (UIColor *) bare_object;
|
|
276
|
+
|
|
277
|
+
CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
|
278
|
+
|
|
279
|
+
[color getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
280
|
+
|
|
281
|
+
out[0] = red;
|
|
282
|
+
out[1] = green;
|
|
283
|
+
out[2] = blue;
|
|
284
|
+
out[3] = alpha;
|
|
285
|
+
}
|
|
286
|
+
}
|
package/lib/color.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const binding = require('../binding')
|
|
2
|
+
const registry = require('bare-foundation-registry')
|
|
3
|
+
const scratch = require('./scratch')
|
|
4
|
+
const wrap = require('./wrap')
|
|
5
|
+
|
|
6
|
+
module.exports = exports = class UIKitColor {
|
|
7
|
+
constructor(opts = {}) {
|
|
8
|
+
const { tag = null } = opts
|
|
9
|
+
|
|
10
|
+
this._tag = tag
|
|
11
|
+
|
|
12
|
+
this._token = binding.claim(this._tag, this)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get [registry.tag]() {
|
|
16
|
+
return this._tag
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get [registry.handle]() {
|
|
20
|
+
return binding.handle(this._tag)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static rgb(red, green, blue, alpha = 1) {
|
|
24
|
+
return new UIKitColor({ tag: binding.colorRGB(red, green, blue, alpha) })
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static hsb(hue, saturation, brightness, alpha = 1) {
|
|
28
|
+
return new UIKitColor({ tag: binding.colorHSB(hue, saturation, brightness, alpha) })
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static white(white, alpha = 1) {
|
|
32
|
+
return new UIKitColor({ tag: binding.colorWhite(white, alpha) })
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static get blackColor() {
|
|
36
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_BLACK))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static get whiteColor() {
|
|
40
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_WHITE))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static get clearColor() {
|
|
44
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_CLEAR))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static get labelColor() {
|
|
48
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_LABEL))
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static get secondaryLabelColor() {
|
|
52
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SECONDARY_LABEL))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static get tertiaryLabelColor() {
|
|
56
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_TERTIARY_LABEL))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static get quaternaryLabelColor() {
|
|
60
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_QUATERNARY_LABEL))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static get placeholderTextColor() {
|
|
64
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_PLACEHOLDER_TEXT))
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static get separatorColor() {
|
|
68
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SEPARATOR))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static get opaqueSeparatorColor() {
|
|
72
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_OPAQUE_SEPARATOR))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static get linkColor() {
|
|
76
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_LINK))
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static get systemBackgroundColor() {
|
|
80
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_BACKGROUND))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static get secondarySystemBackgroundColor() {
|
|
84
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SECONDARY_SYSTEM_BACKGROUND))
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static get tertiarySystemBackgroundColor() {
|
|
88
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_TERTIARY_SYSTEM_BACKGROUND))
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static get systemGroupedBackgroundColor() {
|
|
92
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_GROUPED_BACKGROUND))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static get systemFillColor() {
|
|
96
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_FILL))
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static get tintColor() {
|
|
100
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_TINT))
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static get systemRedColor() {
|
|
104
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_RED))
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static get systemOrangeColor() {
|
|
108
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_ORANGE))
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
static get systemYellowColor() {
|
|
112
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_YELLOW))
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static get systemGreenColor() {
|
|
116
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_GREEN))
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static get systemMintColor() {
|
|
120
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_MINT))
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static get systemTealColor() {
|
|
124
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_TEAL))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static get systemCyanColor() {
|
|
128
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_CYAN))
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
static get systemBlueColor() {
|
|
132
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_BLUE))
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static get systemIndigoColor() {
|
|
136
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_INDIGO))
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static get systemPurpleColor() {
|
|
140
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_PURPLE))
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static get systemPinkColor() {
|
|
144
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_PINK))
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
static get systemBrownColor() {
|
|
148
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_BROWN))
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static get systemGrayColor() {
|
|
152
|
+
return wrap(UIKitColor, binding.colorSystem(binding.COLOR_SYSTEM_GRAY))
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
get components() {
|
|
156
|
+
binding.colorComponentsInto(this._tag, scratch.buffer, 0)
|
|
157
|
+
|
|
158
|
+
return { red: scratch[0], green: scratch[1], blue: scratch[2], alpha: scratch[3] }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
withAlphaComponent(alpha) {
|
|
162
|
+
return wrap(UIKitColor, binding.colorWithAlphaComponent(this._tag, alpha))
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
[Symbol.for('bare.inspect')]() {
|
|
166
|
+
return {
|
|
167
|
+
__proto__: { constructor: UIKitColor }
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
package/lib/events.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const binding = require('../binding')
|
|
2
|
+
|
|
3
|
+
// The mask follows the listeners, so native code only calls into JavaScript
|
|
4
|
+
// when something listens. The map is inherited, so a subclass keeps the events
|
|
5
|
+
// of its parent.
|
|
6
|
+
module.exports = exports = function observe(target) {
|
|
7
|
+
const events = target.constructor._events
|
|
8
|
+
|
|
9
|
+
if (events === undefined) return
|
|
10
|
+
|
|
11
|
+
let mask = target.constructor._always || 0
|
|
12
|
+
|
|
13
|
+
if (mask !== 0) binding.eventMask(target._tag, mask)
|
|
14
|
+
|
|
15
|
+
target.on('newListener', (name) => {
|
|
16
|
+
const bit = events[name]
|
|
17
|
+
|
|
18
|
+
if (bit === undefined || (mask & bit) !== 0) return
|
|
19
|
+
|
|
20
|
+
mask |= bit
|
|
21
|
+
|
|
22
|
+
binding.eventMask(target._tag, mask)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
target.on('removeListener', (name) => {
|
|
26
|
+
const bit = events[name]
|
|
27
|
+
|
|
28
|
+
if (bit === undefined || (mask & bit) === 0) return
|
|
29
|
+
if (target.listenerCount(name) > 0) return
|
|
30
|
+
|
|
31
|
+
mask &= ~bit
|
|
32
|
+
|
|
33
|
+
binding.eventMask(target._tag, mask)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { tag, handle, Handle, Wrapper } from 'bare-foundation-registry'
|
|
2
|
+
|
|
3
|
+
/** A description of a font, as a `UIFontDescriptor`. */
|
|
4
|
+
interface UIKitFontDescriptor {
|
|
5
|
+
/** The traits of the font, as `SYMBOLIC_TRAITS` flags combined with `|`. */
|
|
6
|
+
readonly symbolicTraits: number
|
|
7
|
+
|
|
8
|
+
/** The same font with `traits`, or `null` if it has no such variant. */
|
|
9
|
+
withSymbolicTraits(traits: number): UIKitFontDescriptor | null
|
|
10
|
+
|
|
11
|
+
withFamily(family: string): UIKitFontDescriptor | null
|
|
12
|
+
|
|
13
|
+
readonly [tag]: number
|
|
14
|
+
|
|
15
|
+
readonly [handle]: Handle
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare class UIKitFontDescriptor {
|
|
19
|
+
protected constructor()
|
|
20
|
+
|
|
21
|
+
static readonly SYMBOLIC_TRAITS: {
|
|
22
|
+
readonly ITALIC: number
|
|
23
|
+
readonly BOLD: number
|
|
24
|
+
readonly EXPANDED: number
|
|
25
|
+
readonly CONDENSED: number
|
|
26
|
+
readonly MONO_SPACE: number
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export = UIKitFontDescriptor
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
static js_value_t *
|
|
10
|
+
bare_ui_kit_font_descriptor_symbolic_traits(js_env_t *env, js_callback_info_t *info) {
|
|
11
|
+
int err;
|
|
12
|
+
|
|
13
|
+
size_t argc = 1;
|
|
14
|
+
js_value_t *argv[1];
|
|
15
|
+
|
|
16
|
+
bare_ui_kit_state_t *state;
|
|
17
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
18
|
+
assert(err == 0);
|
|
19
|
+
|
|
20
|
+
assert(argc == 1);
|
|
21
|
+
|
|
22
|
+
void *handle;
|
|
23
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
24
|
+
|
|
25
|
+
js_value_t *result;
|
|
26
|
+
|
|
27
|
+
@autoreleasepool {
|
|
28
|
+
UIFontDescriptor *descriptor = (__bridge UIFontDescriptor *) handle;
|
|
29
|
+
|
|
30
|
+
err = js_create_uint32(env, descriptor.symbolicTraits, &result);
|
|
31
|
+
assert(err == 0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static js_value_t *
|
|
38
|
+
bare_ui_kit_font_descriptor_with_symbolic_traits(js_env_t *env, js_callback_info_t *info) {
|
|
39
|
+
int err;
|
|
40
|
+
|
|
41
|
+
size_t argc = 2;
|
|
42
|
+
js_value_t *argv[2];
|
|
43
|
+
|
|
44
|
+
bare_ui_kit_state_t *state;
|
|
45
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
46
|
+
assert(err == 0);
|
|
47
|
+
|
|
48
|
+
assert(argc == 2);
|
|
49
|
+
|
|
50
|
+
void *handle;
|
|
51
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
52
|
+
|
|
53
|
+
uint32_t traits;
|
|
54
|
+
if (!bare_ui_kit__read_uint32(env, argv[1], "traits", &traits)) return NULL;
|
|
55
|
+
|
|
56
|
+
js_value_t *result;
|
|
57
|
+
|
|
58
|
+
@autoreleasepool {
|
|
59
|
+
UIFontDescriptor *descriptor = (__bridge UIFontDescriptor *) handle;
|
|
60
|
+
|
|
61
|
+
result = bare_foundation_bridge(
|
|
62
|
+
env, state->registry, [descriptor fontDescriptorWithSymbolicTraits:(UIFontDescriptorSymbolicTraits) traits]
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static js_value_t *
|
|
70
|
+
bare_ui_kit_font_descriptor_with_family(js_env_t *env, js_callback_info_t *info) {
|
|
71
|
+
int err;
|
|
72
|
+
|
|
73
|
+
size_t argc = 2;
|
|
74
|
+
js_value_t *argv[2];
|
|
75
|
+
|
|
76
|
+
bare_ui_kit_state_t *state;
|
|
77
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
78
|
+
assert(err == 0);
|
|
79
|
+
|
|
80
|
+
assert(argc == 2);
|
|
81
|
+
|
|
82
|
+
void *handle;
|
|
83
|
+
if (bare_foundation_read_tag(env, state->registry, argv[0], "handle", &handle) < 0) return NULL;
|
|
84
|
+
|
|
85
|
+
js_value_t *result;
|
|
86
|
+
|
|
87
|
+
@autoreleasepool {
|
|
88
|
+
UIFontDescriptor *descriptor = (__bridge UIFontDescriptor *) handle;
|
|
89
|
+
|
|
90
|
+
NSString *family = bare_ui_kit__to_string(env, argv[1]);
|
|
91
|
+
|
|
92
|
+
result = bare_foundation_bridge(env, state->registry, [descriptor fontDescriptorWithFamily:family]);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const binding = require('../binding')
|
|
2
|
+
const registry = require('bare-foundation-registry')
|
|
3
|
+
const wrap = require('./wrap')
|
|
4
|
+
|
|
5
|
+
module.exports = exports = class UIKitFontDescriptor {
|
|
6
|
+
constructor(opts = {}) {
|
|
7
|
+
const { tag = null } = opts
|
|
8
|
+
|
|
9
|
+
this._tag = tag
|
|
10
|
+
|
|
11
|
+
this._token = binding.claim(this._tag, this)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get [registry.tag]() {
|
|
15
|
+
return this._tag
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get [registry.handle]() {
|
|
19
|
+
return binding.handle(this._tag)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get symbolicTraits() {
|
|
23
|
+
return binding.fontDescriptorSymbolicTraits(this._tag)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
withSymbolicTraits(traits) {
|
|
27
|
+
return wrap(UIKitFontDescriptor, binding.fontDescriptorWithSymbolicTraits(this._tag, traits))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
withFamily(family) {
|
|
31
|
+
return wrap(UIKitFontDescriptor, binding.fontDescriptorWithFamily(this._tag, family))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[Symbol.for('bare.inspect')]() {
|
|
35
|
+
return {
|
|
36
|
+
__proto__: { constructor: UIKitFontDescriptor }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.SYMBOLIC_TRAITS = {
|
|
42
|
+
ITALIC: binding.FONT_DESCRIPTOR_TRAIT_ITALIC,
|
|
43
|
+
BOLD: binding.FONT_DESCRIPTOR_TRAIT_BOLD,
|
|
44
|
+
EXPANDED: binding.FONT_DESCRIPTOR_TRAIT_EXPANDED,
|
|
45
|
+
CONDENSED: binding.FONT_DESCRIPTOR_TRAIT_CONDENSED,
|
|
46
|
+
MONO_SPACE: binding.FONT_DESCRIPTOR_TRAIT_MONO_SPACE
|
|
47
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { tag, handle, Handle, Wrapper } from 'bare-foundation-registry'
|
|
2
|
+
import UIKitFont = require('./font')
|
|
3
|
+
|
|
4
|
+
/** Scales fonts and lengths for the text size the user chose, as a `UIFontMetrics`. */
|
|
5
|
+
interface UIKitFontMetrics {
|
|
6
|
+
scaledValueForValue(value: number): number
|
|
7
|
+
|
|
8
|
+
scaledFontForFont(font: UIKitFont): UIKitFont
|
|
9
|
+
|
|
10
|
+
readonly [tag]: number
|
|
11
|
+
|
|
12
|
+
readonly [handle]: Handle
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare class UIKitFontMetrics {
|
|
16
|
+
protected constructor()
|
|
17
|
+
|
|
18
|
+
static readonly defaultMetrics: UIKitFontMetrics
|
|
19
|
+
|
|
20
|
+
/** The metrics for a `FONT_TEXT_STYLE`. */
|
|
21
|
+
static metricsForTextStyle(textStyle: string): UIKitFontMetrics
|
|
22
|
+
|
|
23
|
+
static readonly FONT_TEXT_STYLE: {
|
|
24
|
+
readonly LARGE_TITLE: string
|
|
25
|
+
readonly TITLE1: string
|
|
26
|
+
readonly TITLE2: string
|
|
27
|
+
readonly TITLE3: string
|
|
28
|
+
readonly HEADLINE: string
|
|
29
|
+
readonly SUBHEADLINE: string
|
|
30
|
+
readonly BODY: string
|
|
31
|
+
readonly CALLOUT: string
|
|
32
|
+
readonly FOOTNOTE: string
|
|
33
|
+
readonly CAPTION1: string
|
|
34
|
+
readonly CAPTION2: string
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export = UIKitFontMetrics
|