@onekeyfe/react-native-native-list 3.0.115 → 3.0.117
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/NativeListAdapter.kt +30 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRowView.kt +309 -32
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +41 -1
- package/ios/NativeListCell.swift +191 -18
- package/ios/RNCNativeListView.swift +4 -0
- package/lib/module/validation.js +24 -1
- package/lib/module/web/NativeListWebEngine.js +11 -0
- package/lib/typescript/src/models.d.ts +30 -1
- package/package.json +3 -3
- package/src/models.ts +25 -0
- package/src/validation.ts +54 -0
- package/src/web/NativeListWebEngine.ts +18 -0
package/src/models.ts
CHANGED
|
@@ -57,7 +57,12 @@ export type MarketRowStyle = Readonly<{
|
|
|
57
57
|
/** Space between title and subtitle; 0 by default, bounded to 0..16. */
|
|
58
58
|
lineGap?: number;
|
|
59
59
|
titleBadgeGap?: number;
|
|
60
|
+
/** OneKey patch: keep badges next to the intrinsic title width. */
|
|
61
|
+
titleBadgeLayout?: 'inline';
|
|
60
62
|
trailingGap?: number;
|
|
63
|
+
/** OneKey patch: preserve separate Market content and subtitle insets. */
|
|
64
|
+
contentTrailingGap?: number;
|
|
65
|
+
subtitleTrailingPadding?: number;
|
|
61
66
|
image?: MarketImageStyle;
|
|
62
67
|
title?: MarketTextStyle;
|
|
63
68
|
subtitle?: MarketTextStyle;
|
|
@@ -79,6 +84,14 @@ export type MarketBadgeModel = Readonly<{
|
|
|
79
84
|
backgroundColor?: string;
|
|
80
85
|
actionKey?: string;
|
|
81
86
|
accessibilityLabel?: string;
|
|
87
|
+
/** OneKey patch: optional Market badge metrics; legacy native defaults remain unchanged. */
|
|
88
|
+
style?: Readonly<{
|
|
89
|
+
fontSize?: number;
|
|
90
|
+
fontWeight?: MarketTextStyle['fontWeight'];
|
|
91
|
+
lineHeight?: number;
|
|
92
|
+
height?: number;
|
|
93
|
+
horizontalPadding?: number;
|
|
94
|
+
}>;
|
|
82
95
|
}>;
|
|
83
96
|
|
|
84
97
|
export type MarketChangeModel = Readonly<{
|
|
@@ -333,9 +346,17 @@ export type MarketRow = RowBase &
|
|
|
333
346
|
Readonly<{
|
|
334
347
|
type: 'market';
|
|
335
348
|
variant: 'token' | 'stock' | 'perp';
|
|
349
|
+
leadingAction?: Extract<TrailingAccessory, { kind: 'icon' }>;
|
|
336
350
|
leading: LeadingVisual;
|
|
337
351
|
title: string;
|
|
338
352
|
subtitle?: string;
|
|
353
|
+
/** OneKey patch: localized name shrinks independently of the volume. */
|
|
354
|
+
subtitlePrefix?: Readonly<{
|
|
355
|
+
text: string;
|
|
356
|
+
gap?: number;
|
|
357
|
+
maxWidth?: number;
|
|
358
|
+
style?: MarketTextStyle;
|
|
359
|
+
}>;
|
|
339
360
|
subtitleSegments?: readonly ValueTextSegment[];
|
|
340
361
|
price: string;
|
|
341
362
|
priceSegments?: readonly ValueTextSegment[];
|
|
@@ -434,6 +455,7 @@ export type SystemRow = RowBase &
|
|
|
434
455
|
presentation?: 'market';
|
|
435
456
|
message: string;
|
|
436
457
|
actionKey: string;
|
|
458
|
+
actionText?: string;
|
|
437
459
|
}>
|
|
438
460
|
| Readonly<{
|
|
439
461
|
type: 'system';
|
|
@@ -646,6 +668,7 @@ export type RowPatch =
|
|
|
646
668
|
Pick<
|
|
647
669
|
MarketRow,
|
|
648
670
|
| CommonPatchFields
|
|
671
|
+
| 'leadingAction'
|
|
649
672
|
| 'leading'
|
|
650
673
|
| 'title'
|
|
651
674
|
| 'subtitle'
|
|
@@ -764,6 +787,8 @@ export type NativeListActionAnchor = Readonly<{
|
|
|
764
787
|
token: string;
|
|
765
788
|
/** Window-relative logical units: CSS px on Web, points on iOS, dp on Android. */
|
|
766
789
|
windowRect: NativeListWindowRect;
|
|
790
|
+
/** Actual long-press point, in the same logical units as windowRect. */
|
|
791
|
+
windowPoint?: Readonly<{ x: number; y: number }>;
|
|
767
792
|
source: NativeListActionSource;
|
|
768
793
|
slot?: number;
|
|
769
794
|
generation: number;
|
package/src/validation.ts
CHANGED
|
@@ -162,9 +162,18 @@ function assertMarketStyle(
|
|
|
162
162
|
'leadingGap',
|
|
163
163
|
'titleBadgeGap',
|
|
164
164
|
'trailingGap',
|
|
165
|
+
'contentTrailingGap',
|
|
166
|
+
'subtitleTrailingPadding',
|
|
165
167
|
] as const) {
|
|
166
168
|
assertBoundedStyleNumber(style[field], `${path}.${field}`, 0, 64);
|
|
167
169
|
}
|
|
170
|
+
// OneKey patch: validate the opt-in Market badge layout.
|
|
171
|
+
if (
|
|
172
|
+
style.titleBadgeLayout !== undefined &&
|
|
173
|
+
style.titleBadgeLayout !== 'inline'
|
|
174
|
+
) {
|
|
175
|
+
fail(`${path}.titleBadgeLayout`, 'must be inline when provided');
|
|
176
|
+
}
|
|
168
177
|
assertBoundedStyleNumber(style.lineGap, `${path}.lineGap`, 0, 16);
|
|
169
178
|
assertBoundedStyleNumber(style.changeWidth, `${path}.changeWidth`, 1, 160);
|
|
170
179
|
assertBoundedStyleNumber(style.changeHeight, `${path}.changeHeight`, 1, 160);
|
|
@@ -211,8 +220,38 @@ function assertMarketRow(row: MarketRow, path: string): void {
|
|
|
211
220
|
}
|
|
212
221
|
assertText(row.title, `${path}.title`);
|
|
213
222
|
assertText(row.subtitle, `${path}.subtitle`);
|
|
223
|
+
// OneKey patch: validate the independently laid out Market name.
|
|
224
|
+
if (row.subtitlePrefix) {
|
|
225
|
+
assertText(row.subtitlePrefix.text, `${path}.subtitlePrefix.text`);
|
|
226
|
+
assertBoundedStyleNumber(
|
|
227
|
+
row.subtitlePrefix.gap,
|
|
228
|
+
`${path}.subtitlePrefix.gap`,
|
|
229
|
+
0,
|
|
230
|
+
64
|
|
231
|
+
);
|
|
232
|
+
assertBoundedStyleNumber(
|
|
233
|
+
row.subtitlePrefix.maxWidth,
|
|
234
|
+
`${path}.subtitlePrefix.maxWidth`,
|
|
235
|
+
1,
|
|
236
|
+
320
|
|
237
|
+
);
|
|
238
|
+
assertMarketTextStyle(
|
|
239
|
+
row.subtitlePrefix.style,
|
|
240
|
+
`${path}.subtitlePrefix.style`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
214
243
|
assertText(row.price, `${path}.price`);
|
|
215
244
|
assertText(row.change.text, `${path}.change.text`);
|
|
245
|
+
assertTrailingAccessories(
|
|
246
|
+
row.leadingAction ? [row.leadingAction] : undefined,
|
|
247
|
+
`${path}.leadingAction`
|
|
248
|
+
);
|
|
249
|
+
if (row.leadingAction) {
|
|
250
|
+
assertText(row.leadingAction.name, `${path}.leadingAction.name`);
|
|
251
|
+
if (row.leadingAction.actionKey !== undefined) {
|
|
252
|
+
assertKey(row.leadingAction.actionKey, `${path}.leadingAction.actionKey`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
216
255
|
assertLeadingVisual(row.leading, `${path}.leading`);
|
|
217
256
|
const assertSegments = (
|
|
218
257
|
segments: MarketRow['priceSegments'],
|
|
@@ -246,6 +285,20 @@ function assertMarketRow(row: MarketRow, path: string): void {
|
|
|
246
285
|
}
|
|
247
286
|
badgeKeys.add(badge.key);
|
|
248
287
|
assertText(badge.text, `${badgePath}.text`);
|
|
288
|
+
// OneKey patch: share typography bounds with Market text styles.
|
|
289
|
+
assertMarketTextStyle(badge.style, `${badgePath}.style`);
|
|
290
|
+
assertBoundedStyleNumber(
|
|
291
|
+
badge.style?.height,
|
|
292
|
+
`${badgePath}.style.height`,
|
|
293
|
+
1,
|
|
294
|
+
64
|
|
295
|
+
);
|
|
296
|
+
assertBoundedStyleNumber(
|
|
297
|
+
badge.style?.horizontalPadding,
|
|
298
|
+
`${badgePath}.style.horizontalPadding`,
|
|
299
|
+
0,
|
|
300
|
+
32
|
|
301
|
+
);
|
|
249
302
|
if (badge.iconName !== undefined && badge.iconName !== 'verified') {
|
|
250
303
|
fail(`${badgePath}.iconName`, 'must be verified when provided');
|
|
251
304
|
}
|
|
@@ -797,6 +850,7 @@ function assertRow(
|
|
|
797
850
|
}
|
|
798
851
|
if (row.variant === 'retry') {
|
|
799
852
|
assertKey(row.actionKey, `${path}.actionKey`);
|
|
853
|
+
assertText(row.actionText, `${path}.actionText`);
|
|
800
854
|
}
|
|
801
855
|
break;
|
|
802
856
|
}
|
|
@@ -3123,6 +3123,24 @@ function createMarketRow(context: RenderContext, row: MarketRow): HTMLElement {
|
|
|
3123
3123
|
String(layoutStyle.horizontalPadding) +
|
|
3124
3124
|
'px';
|
|
3125
3125
|
body.style.gap = '0px';
|
|
3126
|
+
if (row.leadingAction) {
|
|
3127
|
+
const action = createIconAction(
|
|
3128
|
+
context,
|
|
3129
|
+
row.leadingAction.name,
|
|
3130
|
+
row.leadingAction.actionKey,
|
|
3131
|
+
row.leadingAction.disabled,
|
|
3132
|
+
row.leadingAction.tintColor
|
|
3133
|
+
);
|
|
3134
|
+
action.style.flex = '0 0 36px';
|
|
3135
|
+
action.style.width = '36px';
|
|
3136
|
+
action.style.height = '36px';
|
|
3137
|
+
action.style.marginRight = '5px';
|
|
3138
|
+
setData(action, 'testid', row.leadingAction.testID);
|
|
3139
|
+
if (row.leadingAction.accessibilityLabel)
|
|
3140
|
+
action.setAttribute('aria-label', row.leadingAction.accessibilityLabel);
|
|
3141
|
+
markActionAnchorSource(action, 'leadingAction');
|
|
3142
|
+
body.appendChild(action);
|
|
3143
|
+
}
|
|
3126
3144
|
const visual = createVisual(context, row.leading);
|
|
3127
3145
|
if (visual) {
|
|
3128
3146
|
const width = layoutStyle.imageWidth;
|