@onekeyfe/react-native-native-list 6.7.0-alpha.466 → 6.8.0-2
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/README.md +312 -379
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +15 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +60 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +5 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +75 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +25 -19
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -0
- package/docs/ROW_TEMPLATES.md +8 -3
- package/docs/SPEC.md +258 -18
- package/docs/STYLE_SPEC.md +12 -0
- package/ios/NativeListActivityDetailsView.swift +13 -5
- package/ios/NativeListMediaPlaceholderView.swift +189 -0
- package/ios/NativeListMediaPreviewSlot.swift +122 -61
- package/ios/NativeListMediaTileRenderer.swift +13 -13
- package/ios/NativeListResolvedText.swift +15 -4
- package/ios/NativeListTextLabel.swift +106 -0
- package/ios/RNCNativeListView.swift +50 -7
- package/ios/tests/NativeListActivityPresentationTests.swift +270 -0
- package/ios/tests/NativeListLifecycleTests.swift +176 -16
- package/ios/tests/NativeListMediaVisibilityTests.swift +41 -7
- package/lib/module/NativeList.js +17 -4
- package/lib/module/NativeList.web.js +3 -1
- package/lib/module/validation.js +19 -2
- package/lib/module/web/NativeListWebEngine.js +13 -11
- package/lib/module/web/templates/ActivityRowRenderer.js +29 -23
- package/lib/module/web/templates/DataRowRenderer.js +16 -0
- package/lib/module/web/templates/IdentityRowRenderer.js +3 -1
- package/lib/module/web/templates/MediaTileRowRenderer.js +84 -15
- package/lib/typescript/src/models.d.ts +9 -1
- package/package.json +1 -1
- package/src/NativeList.tsx +25 -4
- package/src/NativeList.web.tsx +1 -1
- package/src/models.ts +9 -0
- package/src/validation.ts +34 -0
- package/src/web/NativeListWebEngine.ts +16 -11
- package/src/web/templates/ActivityRowRenderer.ts +42 -32
- package/src/web/templates/DataRowRenderer.ts +28 -0
- package/src/web/templates/IdentityRowRenderer.ts +3 -3
- package/src/web/templates/MediaTileRowRenderer.ts +90 -15
package/lib/module/validation.js
CHANGED
|
@@ -814,12 +814,18 @@ function assertVisual(row, path) {
|
|
|
814
814
|
assertLeadingVisual(visual, `${path}.visual[${index}]`);
|
|
815
815
|
});
|
|
816
816
|
}
|
|
817
|
+
|
|
818
|
+
/** The type half of the `descriptionActionStart` contract; the range needs the row. */
|
|
819
|
+
function isDescriptionActionStart(value) {
|
|
820
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
821
|
+
}
|
|
817
822
|
function assertActivity(row, path) {
|
|
818
823
|
if (row.hideLeading !== undefined && typeof row.hideLeading !== 'boolean') fail(`${path}.hideLeading`, 'must be boolean');
|
|
819
824
|
assertText(row.title, `${path}.title`);
|
|
820
825
|
assertText(row.description, `${path}.description`);
|
|
821
826
|
if (row.presentation !== undefined && !['stacked', 'table'].includes(row.presentation)) fail(`${path}.presentation`, 'must be stacked or table');
|
|
822
827
|
if (row.descriptionActionKey !== undefined) assertKey(row.descriptionActionKey, `${path}.descriptionActionKey`);
|
|
828
|
+
if (row.descriptionActionStart !== undefined && !isDescriptionActionStart(row.descriptionActionStart)) fail(`${path}.descriptionActionStart`, 'must be a non-negative integer');
|
|
823
829
|
if ((row.amounts?.length ?? 0) > 32) fail(`${path}.amounts`, 'supports at most 32 amount lines');
|
|
824
830
|
const amountKeys = new Set();
|
|
825
831
|
row.amounts?.forEach((amount, index) => {
|
|
@@ -962,6 +968,9 @@ function assertRow(row, index, path = `rows[${index}]`) {
|
|
|
962
968
|
break;
|
|
963
969
|
case 'activity':
|
|
964
970
|
assertActivity(row, path);
|
|
971
|
+
// Checked on the complete row only: a patch may carry the offset
|
|
972
|
+
// without the description it points into.
|
|
973
|
+
if ((row.descriptionActionStart ?? 0) > (row.description?.length ?? 0)) fail(`${path}.descriptionActionStart`, 'must not exceed the description length');
|
|
965
974
|
break;
|
|
966
975
|
case 'message':
|
|
967
976
|
if (row.presentation !== undefined && row.presentation !== 'inlineWarning') {
|
|
@@ -1229,7 +1238,7 @@ const ROW_FIELDS = {
|
|
|
1229
1238
|
identity: [...COMMON_ROW_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'presentation', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'titleLines', 'subtitleLines', 'badges', 'trailing', 'draggable'],
|
|
1230
1239
|
walletGroup: [...COMMON_ROW_FIELDS, 'parent', 'children', 'draggable'],
|
|
1231
1240
|
rail: [...COMMON_ROW_FIELDS, 'visual', 'title', 'status', 'badge', 'draggable'],
|
|
1232
|
-
activity: [...COMMON_ROW_FIELDS, 'leading', 'hideLeading', 'secondaryLeading', 'title', 'description', 'status', 'primaryAmount', 'secondaryAmount', 'amounts', 'badges', 'presentation', 'fee', 'descriptionActionKey', 'footerActions'],
|
|
1241
|
+
activity: [...COMMON_ROW_FIELDS, 'leading', 'hideLeading', 'secondaryLeading', 'title', 'description', 'status', 'primaryAmount', 'secondaryAmount', 'amounts', 'badges', 'presentation', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
|
|
1233
1242
|
message: [...COMMON_ROW_FIELDS, 'presentation', 'unread', 'leading', 'title', 'body', 'bodyLines', 'time', 'thumbnail'],
|
|
1234
1243
|
dataRow: [...COMMON_ROW_FIELDS, 'leading', 'columns', 'trailing', 'checkbox', 'index', 'badge', 'badges', 'favorite', 'favoriteActive'],
|
|
1235
1244
|
market: [...COMMON_ROW_FIELDS, 'variant', 'webTable', 'metrics', 'leadingAction', 'leading', 'title', 'subtitle', 'subtitlePrefix', 'subtitleSegments', 'price', 'priceSegments', 'change', 'badges', 'pressActionKey', 'pressInActionKey', 'longPressActionKey', 'diagnostics'],
|
|
@@ -1244,7 +1253,7 @@ const COMMON_PATCH_FIELDS = ['height', 'heightRounding', 'opacity', 'pressDisabl
|
|
|
1244
1253
|
const PATCH_FIELDS = {
|
|
1245
1254
|
identity: [...COMMON_PATCH_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'subtitleLines', 'badges', 'trailing'],
|
|
1246
1255
|
rail: [...COMMON_PATCH_FIELDS, 'title', 'visual', 'status', 'badge'],
|
|
1247
|
-
activity: [...COMMON_PATCH_FIELDS, 'presentation', 'leading', 'title', 'badges', 'status', 'hideLeading', 'secondaryLeading', 'description', 'primaryAmount', 'secondaryAmount', 'amounts', 'fee', 'descriptionActionKey', 'footerActions'],
|
|
1256
|
+
activity: [...COMMON_PATCH_FIELDS, 'presentation', 'leading', 'title', 'badges', 'status', 'hideLeading', 'secondaryLeading', 'description', 'primaryAmount', 'secondaryAmount', 'amounts', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
|
|
1248
1257
|
message: [...COMMON_PATCH_FIELDS, 'presentation', 'title', 'unread', 'body', 'bodyLines', 'time', 'thumbnail'],
|
|
1249
1258
|
dataRow: [...COMMON_PATCH_FIELDS, 'leading', 'badges', 'trailing', 'badge', 'columns', 'checkbox', 'index', 'favorite', 'favoriteActive'],
|
|
1250
1259
|
market: [...COMMON_PATCH_FIELDS, 'longPressActionKey', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'subtitle', 'badges', 'webTable', 'metrics', 'price', 'priceSegments', 'change', 'pressActionKey', 'pressInActionKey', 'diagnostics'],
|
|
@@ -1705,6 +1714,11 @@ function sanitizeRowForProduction(row) {
|
|
|
1705
1714
|
delete next[field];
|
|
1706
1715
|
continue;
|
|
1707
1716
|
}
|
|
1717
|
+
if (field === 'descriptionActionStart') {
|
|
1718
|
+
// Renderers clamp an offset past the text; anything else has no meaning.
|
|
1719
|
+
if (!isDescriptionActionStart(value)) delete next[field];
|
|
1720
|
+
continue;
|
|
1721
|
+
}
|
|
1708
1722
|
if (field === 'parent' && isRecord(value)) next[field] = sanitizeRowForProduction(value);else if (field === 'children' && Array.isArray(value)) next[field] = value.map(child => sanitizeRowForProduction(child));else {
|
|
1709
1723
|
const normalized = row.type === 'market' && field === 'metrics' ? sanitizeMarketMetrics(value) : sanitizeDecoration(value, field);
|
|
1710
1724
|
if (normalized === undefined) delete next[field];else next[field] = normalized;
|
|
@@ -2297,6 +2311,9 @@ function mergeAndValidateSingleRow(previous, patch, index) {
|
|
|
2297
2311
|
if (typeof changes.subtitle === 'string' && !('subtitleSegments' in changes) && previous.subtitleSegments !== undefined) changes.subtitleSegments = null;
|
|
2298
2312
|
if (Array.isArray(changes.subtitleSegments) && changes.subtitleSegments.length > 0 && !('subtitle' in changes) && previous.subtitle !== undefined) changes.subtitle = null;
|
|
2299
2313
|
}
|
|
2314
|
+
// The offset points into one specific description string, so a patch that
|
|
2315
|
+
// replaces the description without restating it falls back to the default.
|
|
2316
|
+
if (previous.type === 'activity' && 'description' in changes && changes.description !== previous.description && !('descriptionActionStart' in changes) && previous.descriptionActionStart !== undefined) changes.descriptionActionStart = null;
|
|
2300
2317
|
const merged = {
|
|
2301
2318
|
...previous
|
|
2302
2319
|
};
|
|
@@ -183,6 +183,14 @@ function effectiveRows(snapshot) {
|
|
|
183
183
|
if (snapshot.rows.length > 0) return snapshot.rows;
|
|
184
184
|
return snapshot.emptyState ? [snapshot.emptyState] : [];
|
|
185
185
|
}
|
|
186
|
+
function isDarkBackground(color) {
|
|
187
|
+
const rgb = color ? /^#([0-9a-f]{6})/i.exec(color)?.[1] : undefined;
|
|
188
|
+
if (!rgb) return false;
|
|
189
|
+
const red = Number.parseInt(rgb.slice(0, 2), 16);
|
|
190
|
+
const green = Number.parseInt(rgb.slice(2, 4), 16);
|
|
191
|
+
const blue = Number.parseInt(rgb.slice(4, 6), 16);
|
|
192
|
+
return red * 299 + green * 587 + blue * 114 < 128_000;
|
|
193
|
+
}
|
|
186
194
|
function resolvedTheme(snapshot) {
|
|
187
195
|
return {
|
|
188
196
|
...defaultTheme,
|
|
@@ -482,7 +490,7 @@ export const WEB_LIST_CSS = `
|
|
|
482
490
|
.ok-native-list-account-action-row{justify-content:flex-start;gap:12px;padding:0 12px}.ok-native-list-account-action-row .ok-native-list-action-title{color:var(--nl-secondary);font-size:16px;line-height:24px;font-weight:400;font-family:var(--nl-font-regular)}
|
|
483
491
|
.ok-native-list-system{justify-content:center;padding:8px 12px;background:var(--nl-bg);color:var(--nl-secondary);cursor:default}.ok-native-list-system[data-variant="retry"],.ok-native-list-system[data-variant="noMatch"],.ok-native-list-system[data-variant="end"]{justify-content:flex-start}.ok-native-list-system[data-variant="retry"]{cursor:pointer}
|
|
484
492
|
.ok-native-list-rail{padding:4px;gap:6px;border-radius:8px}.ok-native-list-rail .ok-native-list-visual{width:20px;height:20px;flex-basis:20px}.ok-native-list-rail .ok-native-list-visual>img,.ok-native-list-rail .ok-native-list-visual-main{width:20px;height:20px}.ok-native-list-rail-title{font-size:12px;font-weight:500;white-space:nowrap;font-family:var(--nl-font-medium)}
|
|
485
|
-
.ok-native-list-media{display:block;padding:0 5px;background:transparent;border-radius:16px}.ok-native-list-media-image{display:block;width:100%;aspect-ratio:1;border-radius:10px;background:var(--nl-strong);object-fit:cover}.ok-native-list-media-image[data-state="empty"]{background:transparent}.ok-native-list-media-image[data-state="error"]{display:flex;align-items:center;justify-content:center;color:var(--nl-icon-subdued);font-size:24px}.ok-native-list-media-meta{padding-top:7px}.ok-native-list-media-subtitle-row{display:flex;align-items:center;gap:6px}.ok-native-list-media-subtitle{flex:1;min-width:0;font-size:12px;color:var(--nl-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ok-native-list-media-network{width:14px;height:14px;border-radius:50%}.ok-native-list-media-title{font-size:16px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:var(--nl-font-medium)}.ok-native-list-media-close{position:absolute;right:9px;top:4px;border:0;background:color-mix(in srgb,var(--nl-inverse) 72%,transparent);color:var(--nl-inverse-text);width:24px;height:24px;border-radius:50%;cursor:pointer;font:18px/20px var(--nl-font-regular)}
|
|
493
|
+
.ok-native-list-media{display:block;padding:0 5px;background:transparent;border-radius:16px}.ok-native-list-media-image{display:block;width:100%;aspect-ratio:1;border-radius:10px;background:var(--nl-strong);object-fit:cover}.ok-native-list-media-image[data-state="empty"]{background:transparent}.ok-native-list-media-image[data-state="error"]{display:flex;align-items:center;justify-content:center;color:var(--nl-icon-subdued);font-size:24px}.ok-native-list-media-meta{padding-top:7px}.ok-native-list-media-subtitle-row{display:flex;align-items:center;gap:6px}.ok-native-list-media-subtitle{flex:1;min-width:0;font-size:12px;color:var(--nl-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ok-native-list-media-network{width:14px;height:14px;border-radius:50%}.ok-native-list-media-title{font-size:16px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:var(--nl-font-medium)}.ok-native-list-media-fallback{position:absolute;inset:0;overflow:hidden;border-radius:10px;background:var(--nl-strong);color:color-mix(in srgb,var(--nl-disabled) 70%,transparent)}.ok-native-list-media-fallback::after{content:"";position:absolute;inset:0;border-radius:inherit;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--nl-separator) 60%,transparent);pointer-events:none}.ok-native-list-media-sheen,.ok-native-list-media-hatch,.ok-native-list-media-glyph{position:absolute;inset:0;pointer-events:none}.ok-native-list-media-glyph{display:none;align-items:center;justify-content:center}.ok-native-list-media-glyph svg{width:28%;max-width:44px;height:auto}.ok-native-list-media-fallback[data-state="loading"] .ok-native-list-media-glyph[data-glyph="loading"],.ok-native-list-media-fallback[data-state="failed"] .ok-native-list-media-glyph[data-glyph="failed"]{display:flex}.ok-native-list-media-sheen{display:none;overflow:hidden}.ok-native-list-media-fallback[data-state="loading"] .ok-native-list-media-sheen{display:block}.ok-native-list-media-sheen::before{content:"";position:absolute;top:-50%;bottom:-50%;left:0;width:60%;background:linear-gradient(100deg,transparent 0%,var(--nl-media-shine,rgba(255,255,255,.75)) 50%,transparent 100%);transform:translateX(-135%) skewX(-12deg);animation:ok-native-list-media-sweep 1.6s cubic-bezier(.4,0,.2,1) infinite;animation-delay:var(--nl-media-sweep-delay,0s)}@keyframes ok-native-list-media-sweep{0%{transform:translateX(-135%) skewX(-12deg)}70%,100%{transform:translateX(220%) skewX(-12deg)}}.ok-native-list-media-hatch{display:none;background-image:repeating-linear-gradient(135deg,color-mix(in srgb,var(--nl-primary) 4.5%,transparent) 0 1px,transparent 1px 7px);-webkit-mask-image:radial-gradient(circle at 50% 50%,transparent 0 22%,#000 70%);mask-image:radial-gradient(circle at 50% 50%,transparent 0 22%,#000 70%)}.ok-native-list-media-fallback[data-state="failed"] .ok-native-list-media-hatch{display:block}@media(prefers-reduced-motion:reduce){.ok-native-list-media-sheen::before{animation:none;transform:translateX(60%) skewX(-12deg);opacity:.6}}.ok-native-list-media-close{position:absolute;right:9px;top:4px;border:0;background:color-mix(in srgb,var(--nl-inverse) 72%,transparent);color:var(--nl-inverse-text);width:24px;height:24px;border-radius:50%;cursor:pointer;font:18px/20px var(--nl-font-regular)}
|
|
486
494
|
.ok-native-list-metric{display:flex;flex-direction:column;align-items:flex-start;padding:12px;border-radius:12px;gap:5px;background:var(--nl-row)}.ok-native-list-metric-value{font-size:22px;line-height:28px;font-weight:700;font-family:var(--nl-font-bold)}.ok-native-list-composite{display:flex;flex-direction:column;align-items:stretch;padding:14px;border-radius:12px;gap:12px;background:var(--nl-subdued)}.ok-native-list-composite-heading{font-size:14px;letter-spacing:1px;color:var(--nl-secondary)}.ok-native-list-composite-row{display:flex;gap:12px}.ok-native-list-composite-cell{flex:1;min-width:0}.ok-native-list-composite-cell[data-shaded="true"]{padding:10px;border-radius:10px;background:color-mix(in srgb,var(--nl-primary) 5%,transparent)}.ok-native-list-composite-value{font-size:18px;font-weight:600;font-family:var(--nl-font-semibold)}.ok-native-list-divider{height:1px;background:var(--nl-separator)}.ok-native-list-progress{height:4px;border-radius:2px;overflow:hidden;background:var(--nl-negative)}.ok-native-list-progress>span{display:block;height:100%;border-radius:2px;background:var(--nl-positive)}
|
|
487
495
|
.ok-native-list-data{padding:6px 12px}.ok-native-list-index{flex:0 0 28px;color:var(--nl-secondary);font-size:13px}.ok-native-list-favorite{flex:0 0 24px;color:var(--nl-icon-subdued);font-size:22px}.ok-native-list-favorite[data-active="true"]{color:var(--nl-accent)}.ok-native-list-data-cell{display:flex;flex-direction:column;min-width:0}.ok-native-list-data-cell[data-align="center"]{align-items:center}.ok-native-list-data-cell[data-align="end"]{align-items:flex-end}.ok-native-list-data-primary{display:flex;align-items:center;gap:5px;max-width:100%;font-size:16px;font-weight:500;white-space:nowrap;font-family:var(--nl-font-medium)}.ok-native-list-unread{width:7px;height:7px;flex:0 0 7px;border-radius:50%;background:var(--nl-accent)}.ok-native-list-thumbnail{width:64px;height:64px;border-radius:10px;object-fit:cover}
|
|
488
496
|
.ok-native-list-item[data-native-list-row-press-enabled="true"]:active>.ok-native-list-history{background:var(--nl-selected)}
|
|
@@ -494,7 +502,7 @@ export const WEB_LIST_CSS = `
|
|
|
494
502
|
.ok-native-list-index-preview{position:absolute;z-index:8;right:40px;top:50%;display:flex;width:48px;height:48px;align-items:center;justify-content:center;transform:translateY(-50%) scale(.92);border-radius:14px;background:var(--nl-inverse);color:var(--nl-inverse-text);font-size:22px;font-weight:600;opacity:0;pointer-events:none;transition:opacity .15s ease,transform .15s ease;font-family:var(--nl-font-semibold)}.ok-native-list-index-preview[data-visible="true"]{opacity:1;transform:translateY(-50%) scale(1)}
|
|
495
503
|
.ok-native-list-row.ok-native-list-market-skeleton{padding:12px 20px;gap:0}.ok-native-list-skeleton-left{display:flex;align-items:center;gap:12px;flex:1}.ok-native-list-skeleton-text{display:flex;flex-direction:column;gap:4px}.ok-native-list-skeleton-right{display:flex;align-items:center;gap:8px}.ok-native-list-skeleton-mark{display:block;flex-shrink:0;border-radius:8px;animation:ok-native-list-skeleton 1.5s linear infinite alternate}@keyframes ok-native-list-skeleton{from{background-color:var(--nl-skeleton-base)}to{background-color:var(--nl-skeleton-highlight)}}.ok-native-list-market-spinner{display:block;width:20px;height:20px;flex-shrink:0;color:var(--nl-icon);animation:ok-native-list-spin .75s linear infinite}
|
|
496
504
|
@media (prefers-reduced-motion:reduce){.ok-native-list-index-preview,.ok-native-list-refresh{transition:none}.ok-native-list-spinner,.ok-native-list-market-spinner{animation:none}.ok-native-list-skeleton-mark{animation:none;background:var(--nl-skeleton-base)}}
|
|
497
|
-
.ok-native-list-footer{flex:0 0 auto;min-height:0}.ok-native-list-sticky{position:absolute;z-index:4;left:0;right:0;top:0;pointer-events:auto
|
|
505
|
+
.ok-native-list-footer{flex:0 0 auto;min-height:0}.ok-native-list-sticky{position:absolute;z-index:4;left:0;right:0;top:0;pointer-events:auto}.ok-native-list-viewport-frame:has(>.ok-native-list-index-rail:not([hidden]))>.ok-native-list-viewport,.ok-native-list-viewport-frame[data-section-index-visible="true"]>.ok-native-list-viewport{scrollbar-width:none}.ok-native-list-viewport-frame:has(>.ok-native-list-index-rail:not([hidden]))>.ok-native-list-viewport::-webkit-scrollbar,.ok-native-list-viewport-frame[data-section-index-visible="true"]>.ok-native-list-viewport::-webkit-scrollbar{display:none}.ok-native-list-index-rail{position:absolute;z-index:6;top:0;right:0;bottom:0;width:${SECTION_INDEX_RAIL_WIDTH}px;touch-action:none;cursor:pointer;font-family:var(--nl-font-regular);font-synthesis:none}.ok-native-list-index-rail[hidden]{display:none}.ok-native-list-index-button{appearance:none;position:absolute;left:15px;display:flex;width:14px;height:14px;align-items:center;justify-content:center;padding:0;transform:translateY(-50%);border:0;border-radius:7px;background:transparent;color:var(--nl-disabled);font-size:10px;font-weight:400;line-height:1;cursor:pointer;opacity:.5;transition:opacity .15s ease;font-family:var(--nl-font-regular)}.ok-native-list-index-rail:hover .ok-native-list-index-button,.ok-native-list-index-rail:focus-within .ok-native-list-index-button,.ok-native-list-index-button[data-active="true"]{opacity:1}.ok-native-list-index-button[data-active="true"]{background:var(--nl-positive);color:var(--nl-inverse-text);font-weight:500;font-family:var(--nl-font-medium)}.ok-native-list-index-button:focus-visible{outline:2px solid var(--nl-positive);outline-offset:1px}
|
|
498
506
|
.ok-native-list-refresh{position:absolute;z-index:7;left:50%;top:8px;display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;background:var(--nl-inverse);color:var(--nl-inverse-text);font-size:12px;opacity:0;transform:translate(-50%,-16px);transition:opacity .15s ease,transform .15s ease;pointer-events:none}.ok-native-list-refresh[data-visible="true"]{opacity:1;transform:translate(-50%,0)}
|
|
499
507
|
.ok-native-list-warning{height:auto;display:flex;flex-direction:column;align-items:stretch;gap:4px;padding:14px 12px;border-top:1px solid;border-bottom:1px solid;box-sizing:border-box;cursor:default}.ok-native-list-warning-title,.ok-native-list-warning-message{font-size:14px;line-height:20px;white-space:normal;overflow-wrap:anywhere}.ok-native-list-warning-title{font-weight:500;color:var(--nl-primary);font-family:var(--nl-font-medium)}.ok-native-list-warning-message{font-weight:400;color:var(--nl-secondary);font-family:var(--nl-font-regular)}
|
|
500
508
|
.ok-native-list-subtitle-segments{display:flex;align-items:center;min-width:0;max-width:100%;height:20px}.ok-native-list-subtitle-segments>.ok-native-list-secondary{flex:0 1 auto;min-width:0}.ok-native-list-subtitle-dot{flex:0 0 4px;width:4px;height:4px;margin:0 6px;border-radius:50%;background:var(--nl-disabled)}.ok-native-list-wallet-row>.ok-native-list-flex{flex:0 1 auto;width:100%;align-items:center}.ok-native-list-wallet-badges{display:flex;gap:4px;justify-content:center;margin-top:4px;height:20px;max-width:100%}.ok-native-list-wallet-badges>.ok-native-list-badge{background:var(--nl-strong);color:var(--nl-secondary);font-size:12px;line-height:16px;height:20px;box-sizing:border-box;padding:2px 4px}.ok-native-list-visual-overlay{position:absolute;display:flex;align-items:center;justify-content:center;box-sizing:border-box;border-radius:50%;overflow:hidden;line-height:1;font-size:10px}.ok-native-list-visual-overlay img,.ok-native-list-visual-overlay svg{width:100%;height:100%;object-fit:contain}/* OneKey patch: selector controls follow their original semantic colors and geometry. */
|
|
@@ -808,14 +816,7 @@ function createVisual(context, visual, selectorPresentation) {
|
|
|
808
816
|
if (selectorPresentation) paintSelectorImageBackground(image, frame);
|
|
809
817
|
if (source?.loadingStrategy === 'skeleton' && !(image.complete && image.naturalWidth > 0)) {
|
|
810
818
|
const skeleton = createElement(context.document, 'span', 'ok-native-list-image-skeleton');
|
|
811
|
-
|
|
812
|
-
const rgb = /^#([0-9a-f]{6})/i.exec(background)?.[1];
|
|
813
|
-
if (rgb) {
|
|
814
|
-
const red = Number.parseInt(rgb.slice(0, 2), 16);
|
|
815
|
-
const green = Number.parseInt(rgb.slice(2, 4), 16);
|
|
816
|
-
const blue = Number.parseInt(rgb.slice(4, 6), 16);
|
|
817
|
-
if (red * 299 + green * 587 + blue * 114 < 128_000) skeleton.dataset.dark = 'true';
|
|
818
|
-
}
|
|
819
|
+
if (isDarkBackground(resolvedTheme(context.snapshot).background)) skeleton.dataset.dark = 'true';
|
|
819
820
|
frame.appendChild(skeleton);
|
|
820
821
|
image.addEventListener('load', () => skeleton.remove(), {
|
|
821
822
|
once: true
|
|
@@ -1966,7 +1967,8 @@ export class NativeListWebEngine {
|
|
|
1966
1967
|
'--nl-critical': theme.criticalBackground,
|
|
1967
1968
|
'--nl-inverse': theme.inverseBackground,
|
|
1968
1969
|
'--nl-inverse-text': theme.inverseText,
|
|
1969
|
-
'--nl-info': theme.info
|
|
1970
|
+
'--nl-info': theme.info,
|
|
1971
|
+
'--nl-media-shine': isDarkBackground(theme.background) ? 'rgba(255,255,255,0.07)' : 'rgba(255,255,255,0.75)'
|
|
1970
1972
|
};
|
|
1971
1973
|
Object.entries(values).forEach(([name, value]) => {
|
|
1972
1974
|
if (!value) return;
|
|
@@ -89,6 +89,8 @@ function recycleLegacy(body) {
|
|
|
89
89
|
const histories = new WeakMap();
|
|
90
90
|
const isHistory = row => row.presentation !== undefined || row.amounts !== undefined;
|
|
91
91
|
const ellipsis = 'min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;';
|
|
92
|
+
/** Width a description prefix always leaves for the action text after it. */
|
|
93
|
+
const descriptionActionReserve = '3em';
|
|
92
94
|
function valueText(node, text, segments, size, line, weight) {
|
|
93
95
|
node.textContent = text ?? '';
|
|
94
96
|
applyTextWeight(node, weight);
|
|
@@ -106,11 +108,10 @@ function createHistory(body, primitives) {
|
|
|
106
108
|
const badges = node('badges');
|
|
107
109
|
const description = node('description');
|
|
108
110
|
description.dataset.nlSlot = 'description';
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
description.append(descriptionTime, descriptionDot, descriptionAddress);
|
|
111
|
+
const descriptionPrefix = createElement(document, 'span');
|
|
112
|
+
const descriptionAction = createElement(document, 'button');
|
|
113
|
+
descriptionAction.type = 'button';
|
|
114
|
+
description.append(descriptionPrefix, descriptionAction);
|
|
114
115
|
const amounts = node('amounts');
|
|
115
116
|
const fee = node('fee');
|
|
116
117
|
const feeLabel = node('fee-label');
|
|
@@ -134,9 +135,8 @@ function createHistory(body, primitives) {
|
|
|
134
135
|
title,
|
|
135
136
|
badges,
|
|
136
137
|
description,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
descriptionAddress,
|
|
138
|
+
descriptionPrefix,
|
|
139
|
+
descriptionAction,
|
|
140
140
|
amounts,
|
|
141
141
|
amountRows: new Map(),
|
|
142
142
|
fee,
|
|
@@ -373,23 +373,29 @@ function bindHistory(body, row, primitives) {
|
|
|
373
373
|
v.badges.style.display = row.badges?.length ? 'flex' : 'none';
|
|
374
374
|
v.description.style.cssText = ellipsis + 'display:flex;max-width:100%;color:var(--nl-secondary);font-family:inherit;font-size:14px;line-height:20px;font-weight:400;font-variant-numeric:tabular-nums;';
|
|
375
375
|
applyTextWeight(v.description, 400);
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
v.
|
|
376
|
+
// The caller states where the action text starts; the string is not parsed.
|
|
377
|
+
const description = row.description ?? '';
|
|
378
|
+
const actionStart = row.descriptionActionKey ? Math.min(Math.max(row.descriptionActionStart ?? 0, 0), description.length) : 0;
|
|
379
|
+
const actionText = description.slice(actionStart);
|
|
380
|
+
const boundAction = row.descriptionActionKey && actionText ? row.descriptionActionKey : '';
|
|
381
|
+
// `pre` keeps the space a prefix ends with; a line break stays a space.
|
|
382
|
+
v.descriptionPrefix.textContent = description.slice(0, actionStart).replace(/\r\n|[\r\n]/g, ' ');
|
|
383
|
+
// The prefix keeps its width and the action truncates first, as the tail of
|
|
384
|
+
// the one native label does. A prefix wider than the row is capped instead,
|
|
385
|
+
// or it would squeeze the action to nothing and leave no pointer target.
|
|
386
|
+
v.descriptionPrefix.style.cssText = `${ellipsis}flex-shrink:0;max-width:${actionText ? `calc(100% - ${descriptionActionReserve})` : '100%'};white-space:pre;display:${actionStart > 0 ? 'block' : 'none'}`;
|
|
387
|
+
v.descriptionAction.style.cssText = `${ellipsis}appearance:none;max-width:100%;border:0;padding:0;background:transparent;text-align:left;color:inherit;font:inherit;font-variant-numeric:inherit;display:${actionText ? 'block' : 'none'};`;
|
|
388
|
+
v.descriptionAction.textContent = actionText;
|
|
383
389
|
v.description.style.display = row.description ? 'flex' : 'none';
|
|
384
|
-
v.
|
|
385
|
-
if (
|
|
386
|
-
v.
|
|
387
|
-
markActionAnchorSource(v.
|
|
388
|
-
v.
|
|
390
|
+
v.descriptionAction.tabIndex = boundAction ? 0 : -1;
|
|
391
|
+
if (boundAction) {
|
|
392
|
+
v.descriptionAction.dataset.nativeListAction = boundAction;
|
|
393
|
+
markActionAnchorSource(v.descriptionAction, 'description');
|
|
394
|
+
v.descriptionAction.style.cursor = 'pointer';
|
|
389
395
|
} else {
|
|
390
|
-
delete v.
|
|
391
|
-
delete v.
|
|
392
|
-
v.
|
|
396
|
+
delete v.descriptionAction.dataset.nativeListAction;
|
|
397
|
+
delete v.descriptionAction.dataset.nativeListAnchorSource;
|
|
398
|
+
v.descriptionAction.style.cursor = 'inherit';
|
|
393
399
|
}
|
|
394
400
|
if (row.style?.description) primitives.textStyle(v.description, row.style.description);
|
|
395
401
|
v.description.style.display = row.description ? 'flex' : 'none';
|
|
@@ -12,6 +12,13 @@ function bind(body, row, primitives) {
|
|
|
12
12
|
body.removeAttribute('data-nl-container-background');
|
|
13
13
|
body.removeAttribute('data-nl-container-border');
|
|
14
14
|
const style = row.style;
|
|
15
|
+
const isTokenTable = row.index === undefined && !row.favorite && !row.checkbox && row.columns.length === 4 && row.columns[0]?.key === 'asset' && row.columns[1]?.key === 'balance' && row.columns[2]?.key === 'price' && row.columns[3]?.key === 'swapSpacer';
|
|
16
|
+
if (isTokenTable) {
|
|
17
|
+
// Match the legacy four equal columns, including the icon in the first.
|
|
18
|
+
body.style.display = 'grid';
|
|
19
|
+
body.style.gridTemplateColumns = 'repeat(4, minmax(0, 1fr))';
|
|
20
|
+
body.style.gap = '0';
|
|
21
|
+
}
|
|
15
22
|
if (style?.horizontalPadding !== undefined) body.style.paddingInline = `${style.horizontalPadding}px`;
|
|
16
23
|
if (style?.verticalPadding !== undefined) body.style.paddingBlock = `${style.verticalPadding}px`;
|
|
17
24
|
v.controls.replaceChildren();
|
|
@@ -39,6 +46,9 @@ function bind(body, row, primitives) {
|
|
|
39
46
|
v.visualKey = visualKey;
|
|
40
47
|
}
|
|
41
48
|
v.visualStyle?.apply(style?.image, style?.image?.width ?? 40, style?.image?.height ?? 40, (style?.leadingGap ?? 12) - 12);
|
|
49
|
+
if (v.visual) v.visual.style.gridArea = isTokenTable ? '1 / 1' : '';
|
|
50
|
+
v.trailing.style.gridArea = isTokenTable ? '1 / 4' : '';
|
|
51
|
+
v.trailing.style.justifySelf = isTokenTable ? 'end' : '';
|
|
42
52
|
v.columns.forEach((cell, index) => {
|
|
43
53
|
const column = row.columns[index];
|
|
44
54
|
cell.body.hidden = !column;
|
|
@@ -51,6 +61,12 @@ function bind(body, row, primitives) {
|
|
|
51
61
|
cell.body.hidden = false;
|
|
52
62
|
cell.body.style.flex = String(column.weight ?? 1);
|
|
53
63
|
cell.body.style.display = 'flex';
|
|
64
|
+
if (isTokenTable) {
|
|
65
|
+
cell.body.style.gridArea = `1 / ${index + 1}`;
|
|
66
|
+
if (index === 0 && v.visual) {
|
|
67
|
+
cell.body.style.marginInlineStart = `${(style?.image?.width ?? 40) + (style?.leadingGap ?? 12)}px`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
54
70
|
cell.body.dataset.align = column.alignment ?? 'start';
|
|
55
71
|
if (style?.lineGap !== undefined) cell.body.style.rowGap = `${style.lineGap}px`;
|
|
56
72
|
cell.primaryLine.style.cssText = '';
|
|
@@ -269,7 +269,9 @@ function applyIdentityStyle(body, row) {
|
|
|
269
269
|
}
|
|
270
270
|
if (box.trailingGap !== undefined) {
|
|
271
271
|
const gap = String(box.trailingGap) + 'px';
|
|
272
|
-
|
|
272
|
+
// The accessory row only. A value pair is one accessory whose two lines
|
|
273
|
+
// are a flex column, so a gap there would push the lines apart.
|
|
274
|
+
body.querySelectorAll('.ok-native-list-accessories').forEach(trailing => {
|
|
273
275
|
trailing.style.gap = gap;
|
|
274
276
|
});
|
|
275
277
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { createNamedIcon } from '@onekeyfe/react-native-image/icon/dom';
|
|
4
3
|
const views = new WeakMap();
|
|
5
4
|
function bindLegacy(body, row, primitives) {
|
|
6
5
|
const v = views.get(body);
|
|
@@ -123,6 +122,79 @@ function recycleLegacy(body) {
|
|
|
123
122
|
v.imageKey = v.networkKey = '';
|
|
124
123
|
}
|
|
125
124
|
const galleries = new WeakMap();
|
|
125
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
126
|
+
let glyphMaskId = 0;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Placeholder glyphs share one 24pt geometry with the iOS and Android renderers:
|
|
130
|
+
* a rounded frame with a sun and a ridge; the failed glyph adds a slash and cuts
|
|
131
|
+
* a gap into the frame around it.
|
|
132
|
+
*/
|
|
133
|
+
function createMediaGlyph(document, state) {
|
|
134
|
+
const svg = document.createElementNS(SVG_NS, 'svg');
|
|
135
|
+
svg.setAttribute('viewBox', '0 0 24 24');
|
|
136
|
+
svg.setAttribute('fill', 'none');
|
|
137
|
+
svg.setAttribute('stroke', 'currentColor');
|
|
138
|
+
svg.setAttribute('stroke-width', '1.5');
|
|
139
|
+
svg.setAttribute('stroke-linecap', 'round');
|
|
140
|
+
svg.setAttribute('stroke-linejoin', 'round');
|
|
141
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
142
|
+
const shape = (tag, attributes) => {
|
|
143
|
+
const node = document.createElementNS(SVG_NS, tag);
|
|
144
|
+
Object.entries(attributes).forEach(([key, value]) => node.setAttribute(key, value));
|
|
145
|
+
return node;
|
|
146
|
+
};
|
|
147
|
+
const picture = shape('g', {});
|
|
148
|
+
picture.append(shape('rect', {
|
|
149
|
+
x: '3',
|
|
150
|
+
y: '3',
|
|
151
|
+
width: '18',
|
|
152
|
+
height: '18',
|
|
153
|
+
rx: '4'
|
|
154
|
+
}), shape('circle', {
|
|
155
|
+
cx: '9',
|
|
156
|
+
cy: '9',
|
|
157
|
+
r: '1.6'
|
|
158
|
+
}), shape('path', {
|
|
159
|
+
d: 'M5 20.5L14.5 11L21 17.5'
|
|
160
|
+
}));
|
|
161
|
+
if (state === 'failed') {
|
|
162
|
+
glyphMaskId += 1;
|
|
163
|
+
const id = `ok-native-list-media-cut-${glyphMaskId}`;
|
|
164
|
+
const mask = shape('mask', {
|
|
165
|
+
id,
|
|
166
|
+
maskUnits: 'userSpaceOnUse'
|
|
167
|
+
});
|
|
168
|
+
mask.append(shape('rect', {
|
|
169
|
+
x: '0',
|
|
170
|
+
y: '0',
|
|
171
|
+
width: '24',
|
|
172
|
+
height: '24',
|
|
173
|
+
fill: '#fff',
|
|
174
|
+
stroke: 'none'
|
|
175
|
+
}), shape('path', {
|
|
176
|
+
d: 'M2.6 -0.6L24.6 21.4L21.4 24.6L-0.6 2.6Z',
|
|
177
|
+
fill: '#000',
|
|
178
|
+
stroke: 'none'
|
|
179
|
+
}));
|
|
180
|
+
picture.setAttribute('mask', `url(#${id})`);
|
|
181
|
+
svg.append(mask, picture, shape('path', {
|
|
182
|
+
d: 'M3 3L21 21'
|
|
183
|
+
}));
|
|
184
|
+
} else svg.append(picture);
|
|
185
|
+
const wrap = document.createElement('div');
|
|
186
|
+
wrap.className = 'ok-native-list-media-glyph';
|
|
187
|
+
wrap.dataset.glyph = state;
|
|
188
|
+
wrap.append(svg);
|
|
189
|
+
return wrap;
|
|
190
|
+
}
|
|
191
|
+
const SWEEP_PERIOD_MS = 1600;
|
|
192
|
+
function setPlaceholderState(v, state) {
|
|
193
|
+
v.fallback.dataset.state = state;
|
|
194
|
+
if (state === 'loading')
|
|
195
|
+
// Keep every loading tile on one sweep phase, including recycled rows.
|
|
196
|
+
v.fallback.style.setProperty('--nl-media-sweep-delay', `-${Math.round(performance.now() % SWEEP_PERIOD_MS)}ms`);
|
|
197
|
+
}
|
|
126
198
|
const isGalleryMedia = row => row.variant === 'gallery' && (!row.image || !!row.media && !row.imageState);
|
|
127
199
|
function clearGalleryMedia(v) {
|
|
128
200
|
v.epoch += 1;
|
|
@@ -149,18 +221,7 @@ function initGallery(body, primitives) {
|
|
|
149
221
|
};
|
|
150
222
|
const frame = element('ok-native-list-media-image');
|
|
151
223
|
const fallback = element('ok-native-list-media-fallback');
|
|
152
|
-
|
|
153
|
-
fallback.append(svg);
|
|
154
|
-
Object.assign(fallback.style, {
|
|
155
|
-
position: 'absolute',
|
|
156
|
-
inset: '0',
|
|
157
|
-
display: 'flex',
|
|
158
|
-
alignItems: 'center',
|
|
159
|
-
justifyContent: 'center',
|
|
160
|
-
color: 'var(--nl-disabled)',
|
|
161
|
-
borderRadius: '10px',
|
|
162
|
-
background: 'var(--nl-strong)'
|
|
163
|
-
});
|
|
224
|
+
fallback.append(element('ok-native-list-media-hatch'), element('ok-native-list-media-sheen'), createMediaGlyph(document, 'loading'), createMediaGlyph(document, 'failed'));
|
|
164
225
|
const metadata = element('ok-native-list-media-meta');
|
|
165
226
|
const subtitleLine = element('ok-native-list-media-subtitle-row');
|
|
166
227
|
const subtitle = element('ok-native-list-media-subtitle');
|
|
@@ -240,10 +301,14 @@ function bindGallery(body, row, primitives) {
|
|
|
240
301
|
v.fallback.style.visibility = 'visible';
|
|
241
302
|
const epoch = v.epoch;
|
|
242
303
|
const source = row.imageState ? undefined : row.media?.source;
|
|
304
|
+
setPlaceholderState(v, source?.uri && row.media?.probeOrder.length ? 'loading' : 'failed');
|
|
243
305
|
const probe = attempt => {
|
|
244
306
|
if (v.epoch !== epoch) return;
|
|
245
307
|
const kind = row.media?.probeOrder[attempt];
|
|
246
|
-
if (!source?.uri || !kind)
|
|
308
|
+
if (!source?.uri || !kind) {
|
|
309
|
+
setPlaceholderState(v, 'failed');
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
247
312
|
const media = body.ownerDocument.createElement(kind === 'video' ? 'video' : 'img');
|
|
248
313
|
v.frame.style.borderRadius = kind === 'video' ? '0' : '10px';
|
|
249
314
|
Object.assign(media.style, {
|
|
@@ -284,7 +349,11 @@ function bindGallery(body, row, primitives) {
|
|
|
284
349
|
probe(attempt + 1);
|
|
285
350
|
};
|
|
286
351
|
const ready = () => {
|
|
287
|
-
if (v.epoch === epoch && v.media === media)
|
|
352
|
+
if (v.epoch === epoch && v.media === media) {
|
|
353
|
+
v.fallback.style.visibility = 'hidden';
|
|
354
|
+
// Stops the sweep animation behind the picture.
|
|
355
|
+
setPlaceholderState(v, 'loaded');
|
|
356
|
+
}
|
|
288
357
|
};
|
|
289
358
|
if (media.tagName === 'VIDEO') media.onloadeddata = ready;else media.onload = ready;
|
|
290
359
|
v.media = media;
|
|
@@ -493,6 +493,14 @@ export type ActivityRow = RowBase & Readonly<{
|
|
|
493
493
|
hidden?: boolean;
|
|
494
494
|
}>;
|
|
495
495
|
descriptionActionKey?: string;
|
|
496
|
+
/**
|
|
497
|
+
* UTF-16 offset into `description` where the text that opens
|
|
498
|
+
* `descriptionActionKey` starts; the text before it stays plain. An integer
|
|
499
|
+
* in `0...description.length`: `0`, the default, makes the whole
|
|
500
|
+
* description the action and `description.length` leaves no action text.
|
|
501
|
+
* Ignored without `descriptionActionKey`.
|
|
502
|
+
*/
|
|
503
|
+
descriptionActionStart?: number;
|
|
496
504
|
footerActions?: readonly FooterAction[];
|
|
497
505
|
style?: ActivityRowStyle;
|
|
498
506
|
}>;
|
|
@@ -888,7 +896,7 @@ export type RowPatch = Readonly<{
|
|
|
888
896
|
}> | Readonly<{
|
|
889
897
|
type: 'activity';
|
|
890
898
|
key: string;
|
|
891
|
-
changes: PatchClearableChanges<ActivityRow, CommonPatchFields | 'title' | 'description' | 'status' | 'amounts' | 'badges' | 'presentation' | 'fee' | 'descriptionActionKey' | 'primaryAmount' | 'secondaryAmount' | 'leading' | 'hideLeading' | 'secondaryLeading' | 'footerActions'>;
|
|
899
|
+
changes: PatchClearableChanges<ActivityRow, CommonPatchFields | 'title' | 'description' | 'status' | 'amounts' | 'badges' | 'presentation' | 'fee' | 'descriptionActionKey' | 'descriptionActionStart' | 'primaryAmount' | 'secondaryAmount' | 'leading' | 'hideLeading' | 'secondaryLeading' | 'footerActions'>;
|
|
892
900
|
}> | Readonly<{
|
|
893
901
|
type: 'message';
|
|
894
902
|
key: string;
|
package/package.json
CHANGED
package/src/NativeList.tsx
CHANGED
|
@@ -185,10 +185,21 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
185
185
|
}
|
|
186
186
|
const expandedEpoch = disclosureSlotMounts.current.expandedEpoch;
|
|
187
187
|
const toggleEpoch = disclosureSlotMounts.current.toggleEpoch;
|
|
188
|
+
const iosHeaderPresent = Platform.OS === 'ios' && listHeader != null;
|
|
188
189
|
const [slotMeasurements, setSlotMeasurements] = useState({
|
|
189
190
|
heights: [0, 0, 0, 0, 0, 0],
|
|
190
191
|
readyEpochs: [-1, -1, -1, -1, -1, -1],
|
|
192
|
+
iosHeaderPresent,
|
|
193
|
+
headerEpoch: 0,
|
|
191
194
|
});
|
|
195
|
+
if (slotMeasurements.iosHeaderPresent !== iosHeaderPresent) {
|
|
196
|
+
setSlotMeasurements({
|
|
197
|
+
...slotMeasurements,
|
|
198
|
+
iosHeaderPresent,
|
|
199
|
+
headerEpoch: slotMeasurements.headerEpoch + 1,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
const headerEpoch = slotMeasurements.headerEpoch;
|
|
192
203
|
const hasSidecar = listSidecar !== undefined;
|
|
193
204
|
const sidecarWidth = sidecarLayout?.width;
|
|
194
205
|
const sidecarGap = sidecarLayout?.gap;
|
|
@@ -321,7 +332,12 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
321
332
|
parseInt(String(Platform.Version), 10) >= 26 &&
|
|
322
333
|
(topScrollEdgeEffect === 'hard' || topScrollEdgeEffect === 'soft') &&
|
|
323
334
|
topOverlay != null;
|
|
324
|
-
const containerSlotHeightsJson = JSON.stringify(
|
|
335
|
+
const containerSlotHeightsJson = JSON.stringify(
|
|
336
|
+
Platform.OS === 'ios' &&
|
|
337
|
+
(!iosHeaderPresent || slotMeasurements.readyEpochs[0] !== headerEpoch)
|
|
338
|
+
? [iosHeaderPresent ? null : 0, ...slotHeights.slice(1)]
|
|
339
|
+
: slotHeights
|
|
340
|
+
);
|
|
325
341
|
const defaultSlotInset =
|
|
326
342
|
snapshot.layout.contentPaddingHorizontal ??
|
|
327
343
|
snapshot.layout.contentPadding ??
|
|
@@ -351,6 +367,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
351
367
|
return;
|
|
352
368
|
}
|
|
353
369
|
setSlotMeasurements((previous) => {
|
|
370
|
+
if (index === 0 && epoch !== previous.headerEpoch) return previous;
|
|
354
371
|
if (
|
|
355
372
|
previous.heights[index] === height &&
|
|
356
373
|
previous.readyEpochs[index] === epoch
|
|
@@ -361,7 +378,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
361
378
|
const readyEpochs = [...previous.readyEpochs];
|
|
362
379
|
heights[index] = height;
|
|
363
380
|
readyEpochs[index] = epoch;
|
|
364
|
-
return { heights, readyEpochs };
|
|
381
|
+
return { ...previous, heights, readyEpochs };
|
|
365
382
|
});
|
|
366
383
|
};
|
|
367
384
|
const sidecarLayoutJson = sidecarLayout
|
|
@@ -835,7 +852,11 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
835
852
|
>
|
|
836
853
|
{slotContents.map((content, index) => (
|
|
837
854
|
<View
|
|
838
|
-
key={
|
|
855
|
+
key={
|
|
856
|
+
index === 0 && Platform.OS === 'ios'
|
|
857
|
+
? `header-${headerEpoch}`
|
|
858
|
+
: index
|
|
859
|
+
}
|
|
839
860
|
collapsable={false}
|
|
840
861
|
style={{
|
|
841
862
|
position: 'absolute',
|
|
@@ -849,7 +870,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
849
870
|
recordSlotLayout(
|
|
850
871
|
index,
|
|
851
872
|
Math.ceil(event.nativeEvent.layout.height),
|
|
852
|
-
0
|
|
873
|
+
index === 0 ? headerEpoch : 0
|
|
853
874
|
);
|
|
854
875
|
}
|
|
855
876
|
}}
|
package/src/NativeList.web.tsx
CHANGED
|
@@ -617,7 +617,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
617
617
|
pointerEvents={slotState.disclosurePresent ? 'auto' : 'none'}
|
|
618
618
|
style={
|
|
619
619
|
slotState.disclosurePresent
|
|
620
|
-
?
|
|
620
|
+
? { marginHorizontal: -padding }
|
|
621
621
|
: collapsedExpandedContentStyle
|
|
622
622
|
}
|
|
623
623
|
>
|
package/src/models.ts
CHANGED
|
@@ -616,6 +616,14 @@ export type ActivityRow = RowBase &
|
|
|
616
616
|
hidden?: boolean;
|
|
617
617
|
}>;
|
|
618
618
|
descriptionActionKey?: string;
|
|
619
|
+
/**
|
|
620
|
+
* UTF-16 offset into `description` where the text that opens
|
|
621
|
+
* `descriptionActionKey` starts; the text before it stays plain. An integer
|
|
622
|
+
* in `0...description.length`: `0`, the default, makes the whole
|
|
623
|
+
* description the action and `description.length` leaves no action text.
|
|
624
|
+
* Ignored without `descriptionActionKey`.
|
|
625
|
+
*/
|
|
626
|
+
descriptionActionStart?: number;
|
|
619
627
|
footerActions?: readonly FooterAction[];
|
|
620
628
|
style?: ActivityRowStyle;
|
|
621
629
|
}>;
|
|
@@ -1131,6 +1139,7 @@ export type RowPatch =
|
|
|
1131
1139
|
| 'presentation'
|
|
1132
1140
|
| 'fee'
|
|
1133
1141
|
| 'descriptionActionKey'
|
|
1142
|
+
| 'descriptionActionStart'
|
|
1134
1143
|
| 'primaryAmount'
|
|
1135
1144
|
| 'secondaryAmount'
|
|
1136
1145
|
| 'leading'
|