@onekeyfe/react-native-native-list 6.7.0-1 → 6.7.0-12
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/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +1 -1
- package/docs/SPEC.md +449 -14
- package/ios/HybridNativeList.swift +11 -3
- package/ios/RNCNativeListView.swift +10 -6
- package/ios/tests/NativeListLifecycleTests.swift +28 -0
- package/lib/module/NativeList.js +42 -21
- package/lib/module/NativeList.web.js +163 -32
- package/lib/module/ScrollEdgeEffect.js +8 -0
- package/lib/module/index.js +1 -0
- package/lib/module/validation.js +358 -47
- package/lib/module/web/NativeListWebEngine.js +373 -67
- package/lib/module/web/templates/ActivityRowRenderer.js +484 -5
- package/lib/module/web/templates/MarketRowRenderer.js +8 -3
- package/lib/module/web/templates/MarketTableRowRenderer.js +577 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
- package/lib/module/web/templates/RowRendererRegistry.js +5 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +34 -1
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +10 -6
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -2
- package/lib/nitrogen/generated/android/c++/JNativeListScrollEdgeEffect.hpp +61 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +3 -3
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +1 -1
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollEdgeEffect.kt +24 -0
- package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +3 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +8 -4
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +4 -4
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -1
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +3 -3
- package/lib/nitrogen/generated/ios/swift/NativeListScrollEdgeEffect.swift +44 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -2
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +5 -2
- package/lib/nitrogen/generated/shared/c++/NativeListScrollEdgeEffect.hpp +80 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +4 -3
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +1 -1
- package/lib/typescript/src/NativeList.d.ts +2 -2
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -1
- package/lib/typescript/src/NativeList.types.d.ts +14 -3
- package/lib/typescript/src/NativeList.web.d.ts +2 -2
- package/lib/typescript/src/ScrollEdgeEffect.d.ts +5 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/models.d.ts +71 -1
- package/lib/typescript/src/validation.d.ts +3 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +26 -1
- package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
- package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +10 -6
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -2
- package/nitrogen/generated/android/c++/JNativeListScrollEdgeEffect.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +3 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollEdgeEffect.kt +24 -0
- package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +8 -4
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +4 -4
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +3 -3
- package/nitrogen/generated/ios/swift/NativeListScrollEdgeEffect.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -2
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +5 -2
- package/nitrogen/generated/shared/c++/NativeListScrollEdgeEffect.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -2
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +4 -3
- package/nitrogen/generated/shared/json/NativeListConfig.json +1 -1
- package/package.json +3 -3
- package/react-native-native-list.podspec +4 -1
- package/src/NativeList.nitro.ts +3 -1
- package/src/NativeList.tsx +102 -60
- package/src/NativeList.types.ts +15 -3
- package/src/NativeList.web.tsx +264 -65
- package/src/ScrollEdgeEffect.ts +4 -0
- package/src/index.ts +2 -0
- package/src/models.ts +93 -0
- package/src/validation.ts +785 -72
- package/src/web/NativeListWebEngine.ts +625 -100
- package/src/web/templates/ActivityRowRenderer.ts +723 -7
- package/src/web/templates/MarketRowRenderer.ts +19 -3
- package/src/web/templates/MarketTableRowRenderer.ts +755 -0
- package/src/web/templates/MediaTileRowRenderer.ts +313 -5
- package/src/web/templates/RowRendererRegistry.ts +10 -5
- package/src/web/templates/SectionHeaderRowRenderer.ts +42 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const views = new WeakMap();
|
|
4
|
-
function
|
|
4
|
+
function bindLegacy(body, row, primitives) {
|
|
5
5
|
const v = views.get(body);
|
|
6
6
|
v.primitives = primitives;
|
|
7
7
|
const style = row.style;
|
|
@@ -73,7 +73,7 @@ function bind(body, row, primitives) {
|
|
|
73
73
|
body.appendChild(v.close);
|
|
74
74
|
} else v.close.remove();
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function createLegacy(document, row, primitives) {
|
|
77
77
|
const node = (tag, className, slot) => {
|
|
78
78
|
const n = document.createElement(tag);
|
|
79
79
|
n.className = className;
|
|
@@ -106,10 +106,10 @@ function create(document, row, primitives) {
|
|
|
106
106
|
imageKey: '',
|
|
107
107
|
networkKey: ''
|
|
108
108
|
});
|
|
109
|
-
|
|
109
|
+
bindLegacy(body, row, primitives);
|
|
110
110
|
return body;
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function recycleLegacy(body) {
|
|
113
113
|
const v = views.get(body);
|
|
114
114
|
if (!v) return;
|
|
115
115
|
[v.image, v.network].forEach(n => {
|
|
@@ -121,12 +121,267 @@ function recycle(body) {
|
|
|
121
121
|
v.image = v.network = undefined;
|
|
122
122
|
v.imageKey = v.networkKey = '';
|
|
123
123
|
}
|
|
124
|
+
const galleries = new WeakMap();
|
|
125
|
+
const isGalleryMedia = row => row.variant === 'gallery' && (!row.image || !!row.media && !row.imageState);
|
|
126
|
+
function clearGalleryMedia(v) {
|
|
127
|
+
v.epoch += 1;
|
|
128
|
+
v.frame.style.borderRadius = '10px';
|
|
129
|
+
if (!v.media) return;
|
|
130
|
+
v.media.onerror = null;
|
|
131
|
+
v.media.onload = null;
|
|
132
|
+
v.media.onloadeddata = null;
|
|
133
|
+
if (v.media.tagName === 'VIDEO') {
|
|
134
|
+
const video = v.media;
|
|
135
|
+
video.pause();
|
|
136
|
+
video.removeAttribute('src');
|
|
137
|
+
video.load();
|
|
138
|
+
} else v.media.removeAttribute('src');
|
|
139
|
+
v.media.remove();
|
|
140
|
+
v.media = undefined;
|
|
141
|
+
}
|
|
142
|
+
function initGallery(body, primitives) {
|
|
143
|
+
const document = body.ownerDocument;
|
|
144
|
+
const element = className => {
|
|
145
|
+
const node = document.createElement('div');
|
|
146
|
+
node.className = className;
|
|
147
|
+
return node;
|
|
148
|
+
};
|
|
149
|
+
const frame = element('ok-native-list-media-image');
|
|
150
|
+
const fallback = element('ok-native-list-media-fallback');
|
|
151
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
152
|
+
svg.setAttribute('viewBox', '0 0 24 24');
|
|
153
|
+
svg.setAttribute('width', '24');
|
|
154
|
+
svg.setAttribute('height', '24');
|
|
155
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
156
|
+
svg.setAttribute('fill', 'currentColor');
|
|
157
|
+
for (const d of ['M14.25 7a2 2 0 1 1 0 4 2 2 0 0 1 0-4', 'M21 21H3V3h18zM5 16.414V19h12.586L14 15.414l-2 2-4-4zm0-2.828 3-3 4 4 2-2 5 5V5H5z']) {
|
|
158
|
+
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
159
|
+
path.setAttribute('d', d);
|
|
160
|
+
path.setAttribute('fill-rule', 'evenodd');
|
|
161
|
+
svg.append(path);
|
|
162
|
+
}
|
|
163
|
+
fallback.append(svg);
|
|
164
|
+
Object.assign(fallback.style, {
|
|
165
|
+
position: 'absolute',
|
|
166
|
+
inset: '0',
|
|
167
|
+
display: 'flex',
|
|
168
|
+
alignItems: 'center',
|
|
169
|
+
justifyContent: 'center',
|
|
170
|
+
color: 'var(--nl-disabled)',
|
|
171
|
+
borderRadius: '10px',
|
|
172
|
+
background: 'var(--nl-strong)'
|
|
173
|
+
});
|
|
174
|
+
const metadata = element('ok-native-list-media-meta');
|
|
175
|
+
const subtitleLine = element('ok-native-list-media-subtitle-row');
|
|
176
|
+
const subtitle = element('ok-native-list-media-subtitle');
|
|
177
|
+
const title = element('ok-native-list-media-title');
|
|
178
|
+
const badge = element('ok-native-list-badge');
|
|
179
|
+
subtitle.dataset.nlSlot = 'subtitle';
|
|
180
|
+
title.dataset.nlSlot = 'title';
|
|
181
|
+
badge.dataset.nlSlot = 'badge';
|
|
182
|
+
subtitleLine.append(subtitle);
|
|
183
|
+
metadata.append(subtitleLine, title);
|
|
184
|
+
frame.append(fallback);
|
|
185
|
+
body.replaceChildren(frame, metadata);
|
|
186
|
+
const enter = () => {
|
|
187
|
+
frame.style.opacity = '0.8';
|
|
188
|
+
};
|
|
189
|
+
const leave = () => {
|
|
190
|
+
frame.style.opacity = '';
|
|
191
|
+
};
|
|
192
|
+
body.addEventListener('mouseenter', enter);
|
|
193
|
+
body.addEventListener('mouseleave', leave);
|
|
194
|
+
const v = {
|
|
195
|
+
frame,
|
|
196
|
+
fallback,
|
|
197
|
+
metadata,
|
|
198
|
+
subtitleLine,
|
|
199
|
+
subtitle,
|
|
200
|
+
title,
|
|
201
|
+
badge,
|
|
202
|
+
networkKey: '',
|
|
203
|
+
mediaKey: '',
|
|
204
|
+
epoch: 0,
|
|
205
|
+
primitives,
|
|
206
|
+
enter,
|
|
207
|
+
leave
|
|
208
|
+
};
|
|
209
|
+
galleries.set(body, v);
|
|
210
|
+
return v;
|
|
211
|
+
}
|
|
212
|
+
function bindGallery(body, row, primitives) {
|
|
213
|
+
const v = galleries.get(body) ?? initGallery(body, primitives);
|
|
214
|
+
v.primitives = primitives;
|
|
215
|
+
const style = row.style;
|
|
216
|
+
body.className = 'ok-native-list-row ok-native-list-media';
|
|
217
|
+
body.style.cssText = '';
|
|
218
|
+
body.removeAttribute('data-nl-container-background');
|
|
219
|
+
body.removeAttribute('data-nl-container-border');
|
|
220
|
+
Object.assign(body.style, {
|
|
221
|
+
display: 'block',
|
|
222
|
+
position: 'relative',
|
|
223
|
+
boxSizing: 'border-box',
|
|
224
|
+
padding: `${style?.verticalPadding ?? 10}px ${style?.horizontalPadding ?? 10}px`,
|
|
225
|
+
borderRadius: '16px',
|
|
226
|
+
background: 'transparent',
|
|
227
|
+
height: 'auto'
|
|
228
|
+
});
|
|
229
|
+
Object.assign(v.frame.style, {
|
|
230
|
+
position: 'relative',
|
|
231
|
+
width: '100%',
|
|
232
|
+
height: 'auto',
|
|
233
|
+
aspectRatio: '1',
|
|
234
|
+
borderRadius: v.media?.tagName === 'VIDEO' ? '0' : '10px',
|
|
235
|
+
overflow: 'hidden',
|
|
236
|
+
background: 'var(--nl-bg)'
|
|
237
|
+
});
|
|
238
|
+
v.metadata.style.paddingTop = `${style?.leadingGap ?? 8}px`;
|
|
239
|
+
v.subtitleLine.style.gap = '0px';
|
|
240
|
+
v.subtitle.style.cssText = 'font-size:12px;line-height:16px;font-weight:400;box-sizing:border-box;padding-right:8px';
|
|
241
|
+
v.title.style.cssText = 'font-size:16px;line-height:24px;font-weight:500';
|
|
242
|
+
v.subtitle.textContent = row.subtitle || '-';
|
|
243
|
+
v.title.textContent = row.title || '-';
|
|
244
|
+
if (style?.subtitle) primitives.textStyle(v.subtitle, style.subtitle);
|
|
245
|
+
if (style?.title) primitives.textStyle(v.title, style.title);
|
|
246
|
+
const mediaKey = JSON.stringify([row.key, row.media, row.imageState]);
|
|
247
|
+
if (v.mediaKey !== mediaKey) {
|
|
248
|
+
clearGalleryMedia(v);
|
|
249
|
+
v.mediaKey = mediaKey;
|
|
250
|
+
v.fallback.style.visibility = 'visible';
|
|
251
|
+
const epoch = v.epoch;
|
|
252
|
+
const source = row.imageState ? undefined : row.media?.source;
|
|
253
|
+
const probe = attempt => {
|
|
254
|
+
if (v.epoch !== epoch) return;
|
|
255
|
+
const kind = row.media?.probeOrder[attempt];
|
|
256
|
+
if (!source?.uri || !kind) return;
|
|
257
|
+
const media = body.ownerDocument.createElement(kind === 'video' ? 'video' : 'img');
|
|
258
|
+
v.frame.style.borderRadius = kind === 'video' ? '0' : '10px';
|
|
259
|
+
Object.assign(media.style, {
|
|
260
|
+
display: 'block',
|
|
261
|
+
position: 'absolute',
|
|
262
|
+
inset: '0',
|
|
263
|
+
width: '100%',
|
|
264
|
+
height: '100%',
|
|
265
|
+
objectFit: source.contentFit === 'center' ? 'none' : source.contentFit ?? (kind === 'video' ? 'contain' : 'cover'),
|
|
266
|
+
borderRadius: kind === 'video' ? '0' : '10px',
|
|
267
|
+
pointerEvents: 'none'
|
|
268
|
+
});
|
|
269
|
+
media.setAttribute('aria-hidden', 'true');
|
|
270
|
+
if (media.tagName === 'VIDEO') {
|
|
271
|
+
const video = media;
|
|
272
|
+
video.muted = true;
|
|
273
|
+
video.autoplay = false;
|
|
274
|
+
video.controls = false;
|
|
275
|
+
video.playsInline = true;
|
|
276
|
+
video.preload = 'metadata';
|
|
277
|
+
video.tabIndex = -1;
|
|
278
|
+
} else {
|
|
279
|
+
media.alt = '';
|
|
280
|
+
media.decoding = 'async';
|
|
281
|
+
}
|
|
282
|
+
media.onerror = () => {
|
|
283
|
+
if (v.epoch !== epoch || v.media !== media) return;
|
|
284
|
+
media.onerror = null;
|
|
285
|
+
media.onload = null;
|
|
286
|
+
media.onloadeddata = null;
|
|
287
|
+
if (media.tagName === 'VIDEO') media.pause();
|
|
288
|
+
media.removeAttribute('src');
|
|
289
|
+
if (media.tagName === 'VIDEO') media.load();
|
|
290
|
+
media.remove();
|
|
291
|
+
v.media = undefined;
|
|
292
|
+
v.frame.style.borderRadius = '10px';
|
|
293
|
+
v.fallback.style.visibility = 'visible';
|
|
294
|
+
probe(attempt + 1);
|
|
295
|
+
};
|
|
296
|
+
const ready = () => {
|
|
297
|
+
if (v.epoch === epoch && v.media === media) v.fallback.style.visibility = 'hidden';
|
|
298
|
+
};
|
|
299
|
+
if (media.tagName === 'VIDEO') media.onloadeddata = ready;else media.onload = ready;
|
|
300
|
+
v.media = media;
|
|
301
|
+
v.frame.insertBefore(media, v.badge.parentNode === v.frame ? v.badge : null);
|
|
302
|
+
media.src = source.uri;
|
|
303
|
+
};
|
|
304
|
+
probe(0);
|
|
305
|
+
}
|
|
306
|
+
v.badge.textContent = row.badge?.text ?? '';
|
|
307
|
+
if (row.badge) {
|
|
308
|
+
Object.assign(v.badge.style, {
|
|
309
|
+
position: 'absolute',
|
|
310
|
+
right: '0',
|
|
311
|
+
bottom: '0',
|
|
312
|
+
boxSizing: 'content-box',
|
|
313
|
+
height: '20px',
|
|
314
|
+
padding: '0 8px',
|
|
315
|
+
border: '2px solid var(--nl-bg)',
|
|
316
|
+
borderRadius: '10px',
|
|
317
|
+
background: 'var(--nl-inverse)',
|
|
318
|
+
color: 'var(--nl-inverse-text)',
|
|
319
|
+
fontSize: '14px',
|
|
320
|
+
fontWeight: '500',
|
|
321
|
+
fontFamily: 'var(--nl-font-medium)',
|
|
322
|
+
lineHeight: '20px'
|
|
323
|
+
});
|
|
324
|
+
if (style?.badge) primitives.textStyle(v.badge, style.badge);
|
|
325
|
+
v.frame.append(v.badge);
|
|
326
|
+
} else v.badge.remove();
|
|
327
|
+
const networkKey = JSON.stringify(row.networkImage);
|
|
328
|
+
if (v.networkKey !== networkKey) {
|
|
329
|
+
if (v.network) {
|
|
330
|
+
primitives.dispose(v.network);
|
|
331
|
+
v.network.remove();
|
|
332
|
+
}
|
|
333
|
+
v.network = row.networkImage ? primitives.thumbnail(row.networkImage) : undefined;
|
|
334
|
+
if (v.network) {
|
|
335
|
+
v.network.className = 'ok-native-list-media-network';
|
|
336
|
+
v.subtitleLine.append(v.network);
|
|
337
|
+
}
|
|
338
|
+
v.networkKey = networkKey;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function recycle(body) {
|
|
342
|
+
const gallery = galleries.get(body);
|
|
343
|
+
if (gallery) {
|
|
344
|
+
clearGalleryMedia(gallery);
|
|
345
|
+
if (gallery.network) gallery.primitives.dispose(gallery.network);
|
|
346
|
+
body.removeEventListener('mouseenter', gallery.enter);
|
|
347
|
+
body.removeEventListener('mouseleave', gallery.leave);
|
|
348
|
+
galleries.delete(body);
|
|
349
|
+
}
|
|
350
|
+
recycleLegacy(body);
|
|
351
|
+
views.delete(body);
|
|
352
|
+
}
|
|
353
|
+
function bind(body, row, primitives) {
|
|
354
|
+
const gallery = isGalleryMedia(row);
|
|
355
|
+
if (gallery) {
|
|
356
|
+
if (views.has(body)) {
|
|
357
|
+
recycleLegacy(body);
|
|
358
|
+
views.delete(body);
|
|
359
|
+
}
|
|
360
|
+
bindGallery(body, row, primitives);
|
|
361
|
+
} else {
|
|
362
|
+
if (galleries.has(body)) recycle(body);
|
|
363
|
+
if (!views.has(body)) {
|
|
364
|
+
const initial = createLegacy(body.ownerDocument, row, primitives);
|
|
365
|
+
body.replaceChildren(...Array.from(initial.childNodes));
|
|
366
|
+
body.className = initial.className;
|
|
367
|
+
views.set(body, views.get(initial));
|
|
368
|
+
views.delete(initial);
|
|
369
|
+
}
|
|
370
|
+
bindLegacy(body, row, primitives);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function create(document, row, primitives) {
|
|
374
|
+
const body = document.createElement('div');
|
|
375
|
+
body.dataset.nlRenderer = 'mediaTile';
|
|
376
|
+
bind(body, row, primitives);
|
|
377
|
+
return body;
|
|
378
|
+
}
|
|
124
379
|
export const mediaTileRowRenderer = {
|
|
125
380
|
key: 'mediaTile',
|
|
126
381
|
create,
|
|
127
382
|
bind,
|
|
128
383
|
recycle,
|
|
129
|
-
measure: (
|
|
384
|
+
measure: (row, width) => isGalleryMedia(row) ? width + 48 : 244,
|
|
130
385
|
measureRendered: (_body, _row) => undefined
|
|
131
386
|
};
|
|
132
387
|
//# sourceMappingURL=MediaTileRowRenderer.js.map
|
|
@@ -4,6 +4,7 @@ import { walletGroupRowRenderer } from "./WalletGroupRowRenderer.js";
|
|
|
4
4
|
import { identityRowRenderer } from "./IdentityRowRenderer.js";
|
|
5
5
|
import { sectionHeaderRowRenderer } from "./SectionHeaderRowRenderer.js";
|
|
6
6
|
import { marketRowRenderer } from "./MarketRowRenderer.js";
|
|
7
|
+
import { marketTableRowRenderer } from "./MarketTableRowRenderer.js";
|
|
7
8
|
import { metricCardRowRenderer } from "./MetricCardRowRenderer.js";
|
|
8
9
|
import { dataRowRenderer } from "./DataRowRenderer.js";
|
|
9
10
|
import { activityRowRenderer } from "./ActivityRowRenderer.js";
|
|
@@ -27,7 +28,7 @@ const factories = {
|
|
|
27
28
|
walletGroup: row => registration(walletGroupRowRenderer, row),
|
|
28
29
|
identity: row => registration(identityRowRenderer, row),
|
|
29
30
|
sectionHeader: row => registration(sectionHeaderRowRenderer, row),
|
|
30
|
-
market: row => registration(marketRowRenderer, row),
|
|
31
|
+
market: row => row.webTable ? registration(marketTableRowRenderer, row) : registration(marketRowRenderer, row),
|
|
31
32
|
metricCard: row => registration(metricCardRowRenderer, row),
|
|
32
33
|
dataRow: row => registration(dataRowRenderer, row),
|
|
33
34
|
activity: row => registration(activityRowRenderer, row),
|
|
@@ -42,6 +43,7 @@ const renderers = {
|
|
|
42
43
|
identity: identityRowRenderer,
|
|
43
44
|
sectionHeader: sectionHeaderRowRenderer,
|
|
44
45
|
market: marketRowRenderer,
|
|
46
|
+
marketTable: marketTableRowRenderer,
|
|
45
47
|
metricCard: metricCardRowRenderer,
|
|
46
48
|
dataRow: dataRowRenderer,
|
|
47
49
|
activity: activityRowRenderer,
|
|
@@ -59,11 +61,11 @@ export function rowRenderer(row) {
|
|
|
59
61
|
return factories[row.type](row);
|
|
60
62
|
}
|
|
61
63
|
export function rowRendererKey(row) {
|
|
62
|
-
return row.type;
|
|
64
|
+
return row.type === 'market' && row.webTable ? 'marketTable' : row.type;
|
|
63
65
|
}
|
|
64
66
|
export function recycleRowBody(body) {
|
|
65
67
|
const key = body.dataset.nlRenderer ?? '';
|
|
66
|
-
if (!
|
|
68
|
+
if (!Object.prototype.hasOwnProperty.call(renderers, key)) return false;
|
|
67
69
|
renderers[key].recycle(body);
|
|
68
70
|
return true;
|
|
69
71
|
}
|
|
@@ -73,7 +73,40 @@ function createSectionHeader(document, primitives, row) {
|
|
|
73
73
|
title.replaceChildren(text, dotted);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
if (row.variant === 'history' && row.titleLoading) {
|
|
77
|
+
const pendingLine = createElement(document, 'div');
|
|
78
|
+
pendingLine.style.cssText = 'display:flex;align-items:center;gap:8px;min-width:0;width:100%;height:20px';
|
|
79
|
+
const spinner = createElement(document, 'span');
|
|
80
|
+
spinner.setAttribute('role', 'progressbar');
|
|
81
|
+
spinner.setAttribute('aria-valuemin', '0');
|
|
82
|
+
spinner.setAttribute('aria-valuemax', '1');
|
|
83
|
+
spinner.style.cssText = 'display:block;width:20px;height:20px;flex:0 0 20px';
|
|
84
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
85
|
+
svg.setAttribute('viewBox', '0 0 32 32');
|
|
86
|
+
svg.setAttribute('class', 'ok-native-list-spinner');
|
|
87
|
+
svg.style.cssText = 'display:block;width:20px;height:20px;border:0;animation-duration:.75s';
|
|
88
|
+
for (const track of [true, false]) {
|
|
89
|
+
const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
90
|
+
for (const [name, value] of Object.entries({
|
|
91
|
+
cx: '16',
|
|
92
|
+
cy: '16',
|
|
93
|
+
r: '14',
|
|
94
|
+
fill: 'none',
|
|
95
|
+
'stroke-width': '4'
|
|
96
|
+
})) circle.setAttribute(name, value);
|
|
97
|
+
circle.style.stroke = row.style?.title?.color ?? 'var(--nl-secondary)';
|
|
98
|
+
if (track) circle.style.opacity = '.2';else {
|
|
99
|
+
circle.style.strokeDasharray = '80';
|
|
100
|
+
circle.style.strokeDashoffset = '60';
|
|
101
|
+
}
|
|
102
|
+
svg.appendChild(circle);
|
|
103
|
+
}
|
|
104
|
+
spinner.appendChild(svg);
|
|
105
|
+
title.style.textTransform = 'uppercase';
|
|
106
|
+
pendingLine.append(spinner, column);
|
|
107
|
+
body.style.height = 'calc(100% + 4px)';
|
|
108
|
+
body.appendChild(pendingLine);
|
|
109
|
+
} else body.appendChild(column);
|
|
77
110
|
if (row.value) {
|
|
78
111
|
const value = tagSlot(createElement(document, row.valueActionKey ? 'button' : 'span', row.valueActionKey ? 'ok-native-list-action-button ok-native-list-section-value' : 'ok-native-list-value ok-native-list-section-value', row.value), 'value');
|
|
79
112
|
applyValueSegments(value, row.valueSegments);
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
#include "JHybridNativeListSpec.hpp"
|
|
9
9
|
|
|
10
|
+
// Forward declaration of `NativeListScrollEdgeEffect` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::nativelist { enum class NativeListScrollEdgeEffect; }
|
|
10
12
|
// Forward declaration of `NativeListKeyboardDismissMode` to properly resolve imports.
|
|
11
13
|
namespace margelo::nitro::nativelist { enum class NativeListKeyboardDismissMode; }
|
|
12
14
|
// Forward declaration of `NativeListKeyboardShouldPersistTaps` to properly resolve imports.
|
|
@@ -15,6 +17,8 @@ namespace margelo::nitro::nativelist { enum class NativeListKeyboardShouldPersis
|
|
|
15
17
|
namespace margelo::nitro::nativelist { enum class NativeListScrollAlignment; }
|
|
16
18
|
|
|
17
19
|
#include <string>
|
|
20
|
+
#include "NativeListScrollEdgeEffect.hpp"
|
|
21
|
+
#include "JNativeListScrollEdgeEffect.hpp"
|
|
18
22
|
#include <functional>
|
|
19
23
|
#include <optional>
|
|
20
24
|
#include "JFunc_void_bool.hpp"
|
|
@@ -84,14 +88,14 @@ namespace margelo::nitro::nativelist {
|
|
|
84
88
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* containerSlotHeightsJson */)>("setContainerSlotHeightsJson");
|
|
85
89
|
method(_javaPart, jni::make_jstring(containerSlotHeightsJson));
|
|
86
90
|
}
|
|
87
|
-
|
|
88
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<
|
|
91
|
+
NativeListScrollEdgeEffect JHybridNativeListSpec::getTopScrollEdgeEffect() {
|
|
92
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JNativeListScrollEdgeEffect>()>("getTopScrollEdgeEffect");
|
|
89
93
|
auto __result = method(_javaPart);
|
|
90
|
-
return
|
|
94
|
+
return __result->toCpp();
|
|
91
95
|
}
|
|
92
|
-
void JHybridNativeListSpec::
|
|
93
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<void(
|
|
94
|
-
method(_javaPart,
|
|
96
|
+
void JHybridNativeListSpec::setTopScrollEdgeEffect(NativeListScrollEdgeEffect topScrollEdgeEffect) {
|
|
97
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JNativeListScrollEdgeEffect> /* topScrollEdgeEffect */)>("setTopScrollEdgeEffect");
|
|
98
|
+
method(_javaPart, JNativeListScrollEdgeEffect::fromCpp(topScrollEdgeEffect));
|
|
95
99
|
}
|
|
96
100
|
double JHybridNativeListSpec::getTopOverlayHeight() {
|
|
97
101
|
static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getTopOverlayHeight");
|
|
@@ -56,8 +56,8 @@ namespace margelo::nitro::nativelist {
|
|
|
56
56
|
void setFontFamiliesJson(const std::string& fontFamiliesJson) override;
|
|
57
57
|
std::string getContainerSlotHeightsJson() override;
|
|
58
58
|
void setContainerSlotHeightsJson(const std::string& containerSlotHeightsJson) override;
|
|
59
|
-
|
|
60
|
-
void
|
|
59
|
+
NativeListScrollEdgeEffect getTopScrollEdgeEffect() override;
|
|
60
|
+
void setTopScrollEdgeEffect(NativeListScrollEdgeEffect topScrollEdgeEffect) override;
|
|
61
61
|
double getTopOverlayHeight() override;
|
|
62
62
|
void setTopOverlayHeight(double topOverlayHeight) override;
|
|
63
63
|
std::string getScrollPositionThresholdsJson() override;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JNativeListScrollEdgeEffect.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "NativeListScrollEdgeEffect.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nativelist {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "NativeListScrollEdgeEffect" and the Kotlin enum "NativeListScrollEdgeEffect".
|
|
19
|
+
*/
|
|
20
|
+
struct JNativeListScrollEdgeEffect final: public jni::JavaClass<JNativeListScrollEdgeEffect> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/NativeListScrollEdgeEffect;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum NativeListScrollEdgeEffect.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
NativeListScrollEdgeEffect toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<NativeListScrollEdgeEffect>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JNativeListScrollEdgeEffect> fromCpp(NativeListScrollEdgeEffect value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case NativeListScrollEdgeEffect::NONE:
|
|
46
|
+
static const auto fieldNONE = clazz->getStaticField<JNativeListScrollEdgeEffect>("NONE");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldNONE);
|
|
48
|
+
case NativeListScrollEdgeEffect::HARD:
|
|
49
|
+
static const auto fieldHARD = clazz->getStaticField<JNativeListScrollEdgeEffect>("HARD");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldHARD);
|
|
51
|
+
case NativeListScrollEdgeEffect::SOFT:
|
|
52
|
+
static const auto fieldSOFT = clazz->getStaticField<JNativeListScrollEdgeEffect>("SOFT");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldSOFT);
|
|
54
|
+
default:
|
|
55
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
56
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::nativelist
|
|
@@ -69,9 +69,9 @@ void JHybridNativeListStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
|
|
|
69
69
|
hybridView->setContainerSlotHeightsJson(newProps->containerSlotHeightsJson.get());
|
|
70
70
|
}
|
|
71
71
|
if (oldProps == nullptr
|
|
72
|
-
? newProps->
|
|
73
|
-
: !newProps->
|
|
74
|
-
hybridView->
|
|
72
|
+
? newProps->topScrollEdgeEffect.isProvided()
|
|
73
|
+
: !newProps->topScrollEdgeEffect.hasSameValue(oldProps->topScrollEdgeEffect)) {
|
|
74
|
+
hybridView->setTopScrollEdgeEffect(newProps->topScrollEdgeEffect.get());
|
|
75
75
|
}
|
|
76
76
|
if (oldProps == nullptr
|
|
77
77
|
? newProps->topOverlayHeight.isProvided()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NativeListScrollEdgeEffect.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nativelist
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "NativeListScrollEdgeEffect".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class NativeListScrollEdgeEffect(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
NONE(0),
|
|
20
|
+
HARD(1),
|
|
21
|
+
SOFT(2);
|
|
22
|
+
|
|
23
|
+
companion object
|
|
24
|
+
}
|
|
@@ -16,12 +16,15 @@ namespace margelo::nitro::nativelist { enum class NativeListKeyboardDismissMode;
|
|
|
16
16
|
namespace margelo::nitro::nativelist { enum class NativeListKeyboardShouldPersistTaps; }
|
|
17
17
|
// Forward declaration of `NativeListScrollAlignment` to properly resolve imports.
|
|
18
18
|
namespace margelo::nitro::nativelist { enum class NativeListScrollAlignment; }
|
|
19
|
+
// Forward declaration of `NativeListScrollEdgeEffect` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::nativelist { enum class NativeListScrollEdgeEffect; }
|
|
19
21
|
|
|
20
22
|
// Include C++ defined types
|
|
21
23
|
#include "HybridNativeListSpec.hpp"
|
|
22
24
|
#include "NativeListKeyboardDismissMode.hpp"
|
|
23
25
|
#include "NativeListKeyboardShouldPersistTaps.hpp"
|
|
24
26
|
#include "NativeListScrollAlignment.hpp"
|
|
27
|
+
#include "NativeListScrollEdgeEffect.hpp"
|
|
25
28
|
#include <NitroModules/Result.hpp>
|
|
26
29
|
#include <exception>
|
|
27
30
|
#include <functional>
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
// Forward declaration of `HybridNativeListSpec_cxx` to properly resolve imports.
|
|
13
13
|
namespace NativeListModule { class HybridNativeListSpec_cxx; }
|
|
14
14
|
|
|
15
|
+
// Forward declaration of `NativeListScrollEdgeEffect` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nativelist { enum class NativeListScrollEdgeEffect; }
|
|
15
17
|
// Forward declaration of `NativeListKeyboardDismissMode` to properly resolve imports.
|
|
16
18
|
namespace margelo::nitro::nativelist { enum class NativeListKeyboardDismissMode; }
|
|
17
19
|
// Forward declaration of `NativeListKeyboardShouldPersistTaps` to properly resolve imports.
|
|
@@ -20,6 +22,7 @@ namespace margelo::nitro::nativelist { enum class NativeListKeyboardShouldPersis
|
|
|
20
22
|
namespace margelo::nitro::nativelist { enum class NativeListScrollAlignment; }
|
|
21
23
|
|
|
22
24
|
#include <string>
|
|
25
|
+
#include "NativeListScrollEdgeEffect.hpp"
|
|
23
26
|
#include <functional>
|
|
24
27
|
#include <optional>
|
|
25
28
|
#include "NativeListKeyboardDismissMode.hpp"
|
|
@@ -93,11 +96,12 @@ namespace margelo::nitro::nativelist {
|
|
|
93
96
|
inline void setContainerSlotHeightsJson(const std::string& containerSlotHeightsJson) noexcept override {
|
|
94
97
|
_swiftPart.setContainerSlotHeightsJson(containerSlotHeightsJson);
|
|
95
98
|
}
|
|
96
|
-
inline
|
|
97
|
-
|
|
99
|
+
inline NativeListScrollEdgeEffect getTopScrollEdgeEffect() noexcept override {
|
|
100
|
+
auto __result = _swiftPart.getTopScrollEdgeEffect();
|
|
101
|
+
return static_cast<NativeListScrollEdgeEffect>(__result);
|
|
98
102
|
}
|
|
99
|
-
inline void
|
|
100
|
-
_swiftPart.
|
|
103
|
+
inline void setTopScrollEdgeEffect(NativeListScrollEdgeEffect topScrollEdgeEffect) noexcept override {
|
|
104
|
+
_swiftPart.setTopScrollEdgeEffect(static_cast<int>(topScrollEdgeEffect));
|
|
101
105
|
}
|
|
102
106
|
inline double getTopOverlayHeight() noexcept override {
|
|
103
107
|
return _swiftPart.getTopOverlayHeight();
|
|
@@ -130,11 +130,11 @@ using namespace margelo::nitro::nativelist::views;
|
|
|
130
130
|
: !newViewProps.containerSlotHeightsJson.hasSameValue(oldViewProps->containerSlotHeightsJson)) {
|
|
131
131
|
swiftPart.setContainerSlotHeightsJson(newViewProps.containerSlotHeightsJson.get());
|
|
132
132
|
}
|
|
133
|
-
//
|
|
133
|
+
// topScrollEdgeEffect: enum
|
|
134
134
|
if (oldViewProps == nullptr
|
|
135
|
-
? newViewProps.
|
|
136
|
-
: !newViewProps.
|
|
137
|
-
swiftPart.
|
|
135
|
+
? newViewProps.topScrollEdgeEffect.isProvided()
|
|
136
|
+
: !newViewProps.topScrollEdgeEffect.hasSameValue(oldViewProps->topScrollEdgeEffect)) {
|
|
137
|
+
swiftPart.setTopScrollEdgeEffect(static_cast<int>(newViewProps.topScrollEdgeEffect.get()));
|
|
138
138
|
}
|
|
139
139
|
// topOverlayHeight: number
|
|
140
140
|
if (oldViewProps == nullptr
|
|
@@ -13,7 +13,7 @@ public protocol HybridNativeListSpec_protocol: HybridObject, HybridView {
|
|
|
13
13
|
var snapshotJson: String { get set }
|
|
14
14
|
var fontFamiliesJson: String { get set }
|
|
15
15
|
var containerSlotHeightsJson: String { get set }
|
|
16
|
-
var
|
|
16
|
+
var topScrollEdgeEffect: NativeListScrollEdgeEffect { get set }
|
|
17
17
|
var topOverlayHeight: Double { get set }
|
|
18
18
|
var scrollPositionThresholdsJson: String { get set }
|
|
19
19
|
var onScrollPositionThresholdChange: ((_ isBeyondThreshold: Bool) -> Void)? { get set }
|
|
@@ -154,14 +154,14 @@ open class HybridNativeListSpec_cxx {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
public final var
|
|
157
|
+
public final var topScrollEdgeEffect: Int32 {
|
|
158
158
|
@inline(__always)
|
|
159
159
|
get {
|
|
160
|
-
return self.__implementation.
|
|
160
|
+
return self.__implementation.topScrollEdgeEffect.rawValue
|
|
161
161
|
}
|
|
162
162
|
@inline(__always)
|
|
163
163
|
set {
|
|
164
|
-
self.__implementation.
|
|
164
|
+
self.__implementation.topScrollEdgeEffect = margelo.nitro.nativelist.NativeListScrollEdgeEffect(rawValue: newValue)!
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|