@onekeyfe/react-native-native-list 6.7.0-46 → 6.7.0-47

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.
Files changed (2) hide show
  1. package/README.md +312 -379
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,92 +1,108 @@
1
+ <div align="center">
2
+
1
3
  # @onekeyfe/react-native-native-list
2
4
 
3
- Nitro View, template-driven native list for React Native 0.86. iOS renders a
4
- `UICollectionView`; Android renders a `RecyclerView`. JavaScript sends one
5
- serializable snapshot or batch patch instead of mounting a React subtree for
6
- every row.
5
+ **Template-driven native lists for OneKey surfaces — UICollectionView on iOS, RecyclerView on Android and a windowed DOM engine on Web.**
6
+
7
+ [![npm](https://img.shields.io/npm/v/%40onekeyfe%2Freact-native-native-list?label=npm&color=4D6BFE)](https://www.npmjs.com/package/@onekeyfe/react-native-native-list)
8
+ [![license](https://img.shields.io/npm/l/%40onekeyfe%2Freact-native-native-list?label=license&color=4D6BFE)](LICENSE)
9
+ ![iOS](https://img.shields.io/badge/iOS-000000?logo=apple&logoColor=white)
10
+ ![Android](https://img.shields.io/badge/Android-3DDC84?logo=android&logoColor=white)
11
+ ![Web](https://img.shields.io/badge/Web-4285F4?logo=googlechrome&logoColor=white)
12
+ ![Nitro Modules](https://img.shields.io/badge/Nitro_Modules-4D6BFE)
13
+
14
+ </div>
15
+
16
+ Renders bounded, high-volume row data without mounting a React subtree per row.
17
+ JavaScript sends one serializable snapshot — or an atomic batch of patches — to a
18
+ Nitro view, and the native host owns layout, recycling, selection, reorder and
19
+ scrolling. Rows are a strict discriminated union of thirteen fixed templates, so
20
+ there is no `renderItem`, arbitrary style dictionary or embedded React component
21
+ per cell. Web runs a separate windowed DOM engine behind the same component,
22
+ data model and imperative API.
23
+
24
+ ## Features
25
+
26
+ - **No React subtree per row** — a snapshot or patch batch is serialized once,
27
+ and native collection hosts recycle cells.
28
+ - **Thirteen fixed row templates** — identity, wallet group, rail, activity,
29
+ message, data, market, media tile, metric card, section header, action, button
30
+ group and system rows cover the OneKey list surfaces.
31
+ - **Four layouts on one model** — `linear`, `sectioned`, `grid` and `table`,
32
+ with vertical/horizontal orientation, sticky headers, fixed footer, empty
33
+ state and named container slots.
34
+ - **Native interaction** — single/multiple selection with tri-state checkboxes,
35
+ reorder with a drag preview, a section index rail, pull to refresh and
36
+ end-reached events.
37
+ - **Imperative updates and scrolling** — apply snapshots/patches, reconcile
38
+ selection after native interaction, and scroll by key, index, item, offset or
39
+ location.
40
+ - **OneKeyImage-backed cells** — row image slots bind through
41
+ `@onekeyfe/react-native-image` reusable views and keep its shared cache
42
+ pipeline.
43
+
44
+ ## Installation
45
+
46
+ ```sh
47
+ yarn add @onekeyfe/react-native-native-list \
48
+ @onekeyfe/react-native-image \
49
+ @onekeyfe/react-native-native-logger \
50
+ react-native-nitro-modules@0.37.0
51
+ ```
7
52
 
8
- ## Install
53
+ Peer dependencies: `react`, `react-native`, `react-native-nitro-modules`
54
+ 0.37.0, `@onekeyfe/react-native-image` and `@onekeyfe/react-native-native-logger`.
55
+ Keep NativeList and OneKeyImage on the same release, because recycled image
56
+ slots use the image host's native view.
9
57
 
10
- Keep NativeList and OneKeyImage on the same release because recycled image
11
- slots use the native host exported by OneKeyImage.
58
+ The package registers a native view, so install the app's iOS pods and rebuild
59
+ the native binary; a JavaScript-only install does not register it:
12
60
 
13
61
  ```sh
14
- yarn add @onekeyfe/react-native-native-list@3.0.101 \
15
- @onekeyfe/react-native-image@3.0.101 \
16
- react-native-nitro-modules@0.37.0
17
62
  cd ios && pod install
18
63
  ```
19
64
 
20
- The package requires the React Native new architecture. Its deployment floors
21
- are iOS 15.5 and Android API 24.
65
+ Android links through autolinking. The package requires the React Native new
66
+ architecture; its deployment floors are iOS 15.5 and Android API 24.
22
67
 
23
- ## Basic usage
68
+ ## Usage
24
69
 
25
70
  ```tsx
26
- import { useMemo, useRef, useState } from 'react';
71
+ import { useMemo } from 'react';
27
72
  import {
28
73
  NativeList,
29
- type NativeListRef,
30
74
  type NativeListSnapshot,
31
- type SelectionDeltaEvent,
32
75
  } from '@onekeyfe/react-native-native-list';
33
76
 
34
- export function AssetList() {
35
- const listRef = useRef<NativeListRef>(null);
36
- const [selectedKeys, setSelectedKeys] = useState<readonly string[]>([]);
37
- const snapshot = useMemo<NativeListSnapshot>(
38
- () => ({
39
- schemaVersion: 1,
40
- generation: 1,
41
- layout: { kind: 'sectioned', stickyHeaders: true, itemSpacing: 1 },
42
- selection: {
43
- mode: 'multiple',
44
- selectedKeys,
45
- rowPressToggles: true,
46
- },
47
- rows: [
48
- {
49
- type: 'identity',
50
- key: 'btc',
51
- sectionKey: 'assets',
52
- leading: {
53
- kind: 'token',
54
- image: {
55
- uri: 'https://example.com/btc.png',
56
- width: 40,
57
- height: 40,
58
- contentFit: 'cover',
59
- cachePolicy: 'memory-disk',
60
- },
61
- fallbackText: 'BT',
62
- },
63
- title: 'Bitcoin',
64
- subtitle: 'BTC · Bitcoin',
65
- trailing: [
66
- { kind: 'value', text: '$64,230' },
67
- { kind: 'checkbox', state: 'unchecked', target: { scope: 'row' } },
68
- ],
69
- },
70
- ],
71
- }),
72
- [selectedKeys]
73
- );
74
-
75
- const handleSelection = (event: SelectionDeltaEvent) => {
76
- setSelectedKeys((current) => {
77
- const next = new Set(current);
78
- event.removedKeys.forEach((key) => next.delete(key));
79
- event.addedKeys.forEach((key) => next.add(key));
80
- return [...next];
81
- });
82
- };
77
+ const snapshot: NativeListSnapshot = {
78
+ schemaVersion: 1,
79
+ generation: 1,
80
+ layout: { kind: 'sectioned', stickyHeaders: true, itemSpacing: 1 },
81
+ rows: [
82
+ {
83
+ type: 'sectionHeader',
84
+ key: 'assets',
85
+ sectionKey: 'assets',
86
+ title: 'Assets',
87
+ },
88
+ {
89
+ type: 'identity',
90
+ key: 'btc',
91
+ sectionKey: 'assets',
92
+ leading: { kind: 'icon', name: 'StarOutline' },
93
+ title: 'Bitcoin',
94
+ subtitle: 'BTC · Bitcoin',
95
+ trailing: [{ kind: 'value', text: '$64,230' }],
96
+ },
97
+ ],
98
+ };
83
99
 
100
+ export function AssetList() {
101
+ const stableSnapshot = useMemo(() => snapshot, []);
84
102
  return (
85
103
  <NativeList
86
- ref={listRef}
87
104
  style={{ flex: 1 }}
88
- snapshot={snapshot}
89
- onSelectionDelta={handleSelection}
105
+ snapshot={stableSnapshot}
90
106
  onRowAction={({ rowKey, actionKey }) => {
91
107
  console.log(rowKey, actionKey);
92
108
  }}
@@ -95,83 +111,172 @@ export function AssetList() {
95
111
  }
96
112
  ```
97
113
 
98
- Native selection is authoritative for immediate feedback. Persist the emitted
99
- delta in application state, then pass that state back in a later snapshot or
100
- call `reconcileSelection(selectedKeys)` once. Reconciliation does not emit a
101
- second delta.
114
+ The application owns the snapshot and the React chrome around the list; the
115
+ native view owns cells, recycling and gestures. Keep the snapshot referentially
116
+ stable between unrelated renders — a re-render with an older snapshot
117
+ intentionally restores that older state.
118
+
119
+ ## API
120
+
121
+ ### Component
122
+
123
+ | Prop | Type | Platforms | Description |
124
+ | --- | --- | :-: | --- |
125
+ | `snapshot` | `NativeListSnapshot` | iOS, Android, Web | Required declarative baseline: layout, rows, theme, selection, capabilities. |
126
+ | `listHeader`, `listFooter`, `listEmpty` | `ReactNode` | iOS, Android, Web | Container slots outside the data-row stream. |
127
+ | `listExpandedContent`, `listStructureToggle` | `ReactNode` | iOS, Android, Web | Native disclosure content and its toggle. |
128
+ | `listSidecar`, `sidecarLayout` | `ReactNode`, `NativeListSidecarLayout` | iOS, Android, Web | Scrolling right column for a vertical linear list; both are required together. |
129
+ | `topOverlay`, `topScrollEdgeEffect` | `ReactNode`, `'hard' \| 'soft'` | iOS 26+ | Fixed overlay above scrolling rows and UIKit's top scroll-edge effect; both are required together. |
130
+ | `initialScrollIndex` / `initialScrollKey` | `number` / `string` | iOS, Android, Web | One-shot first position; the two props are mutually exclusive. |
131
+ | `initialScrollViewPosition`, `initialScrollViewOffset` | `number` | iOS, Android, Web | Offset applied to the initial scroll target. |
132
+ | `keyboardDismissMode` | `'none' \| 'on-drag' \| 'interactive'` | iOS, Android | `interactive` behaves as `none` on Android. |
133
+ | `keyboardShouldPersistTaps` | `'never' \| 'always' \| 'handled'` | iOS, Android | Defaults to `never`. |
134
+ | `webVirtualizationEnabled` | `boolean` | Web | Defaults to `true`. |
135
+ | `webScrollHost` | host object or `null` | Web | `undefined` owns scrolling; `null` waits for a host element. |
136
+ | `webStickyInset`, `webSectionIndexContainerRef` | `number`, `RefObject` | Web | Visible sticky chrome inset and the section-index host container. |
137
+ | `scrollPositionThresholds` | `{ start, end, enabled? }` | iOS, Android | Emits initial state and hysteresis transitions, not scroll frames. |
138
+ | `onRowAction`, `onActionAnchorInvalidated` | event callbacks | iOS, Android, Web | Row/accessory actions with anchor metadata, and anchor invalidation. |
139
+ | `onSelectionDelta`, `onReorder` | event callbacks | iOS, Android, Web | Native selection delta and committed reorder range. |
140
+ | `onEndReached`, `onVisibleRangeChanged` | event callbacks | iOS, Android, Web | End-reached fires once per snapshot `generation`; visible-range events are coalesced to one per display frame. |
141
+ | `onRefresh`, `onScrollToIndexFailed` | `() => void`, `(info) => void` | iOS, Android, Web | Pull-to-refresh request and invalid explicit scroll targets. |
142
+ | `onStructuralTransitionSettled` | event callback | iOS, Android | Settled/interrupted structural row animation. |
143
+
144
+ ### Ref methods
145
+
146
+ All ref methods are available on iOS, Android and Web.
147
+
148
+ | Method | Description |
149
+ | --- | --- |
150
+ | `applySnapshot(snapshot)` | Replaces the declarative baseline. |
151
+ | `applyPatches(patches)` | Applies a validated, keyed patch batch atomically. |
152
+ | `reconcileSelection(keys)` | Replaces native selection without emitting a second delta. |
153
+ | `scrollToKey`, `scrollToIndex`, `scrollToItem` | Scroll to a row by stable key, index or row model. |
154
+ | `scrollToOffset`, `scrollToEnd`, `scrollToLocation` | Scroll by offset, to the end or to a section/item location. |
155
+ | `setActionAnchorState(state)` | Opens/closes an anchored action for a row control. |
156
+ | `setRefreshing(refreshing)` | Synchronizes the native refresh control. |
157
+
158
+ See [`src/NativeList.types.ts`](src/NativeList.types.ts) for the full prop, ref
159
+ and scroll-option types.
160
+
161
+ ### Other exports
162
+
163
+ | Export | Platforms | Description |
164
+ | --- | :-: | --- |
165
+ | `preloadNativeListAvatarImages(sources)` | iOS, Android, Web | Preloads avatar `ImageSource`s through the OneKeyImage cache. |
166
+ | `configureNativeListFonts(families)` | iOS, Android, Web | Maps the regular/medium/semibold/bold faces for mounted lists at runtime. |
167
+ | `ScrollEdgeEffect` | iOS | `hard` / `soft` values for `topScrollEdgeEffect`. |
168
+ | `validateSnapshot`, `validatePatches` | iOS, Android, Web | Validate a snapshot or patch batch before use. |
169
+ | `applyRowPatches`, `planNativeListPatches` | iOS, Android, Web | Apply a patch batch to a snapshot, or plan value-only patches between two snapshots. |
170
+ | `serializeSnapshot`, `serializePatches` | iOS, Android, Web | Produce the JSON payloads the native host consumes. |
171
+ | `reduceSelection`, `isSelectableRow`, `checkboxStateForKeys`, `checkboxStateForSection`, `selectionStateFromSnapshot` | iOS, Android, Web | Selection state helpers shared with the application store. |
172
+
173
+ ## Platform support
174
+
175
+ | Capability | iOS | Android | Web |
176
+ | --- | :-: | :-: | :-: |
177
+ | Snapshots, patches and the 13 row templates | ✅ | ✅ | ✅ |
178
+ | `linear`, `sectioned`, `grid` and `table` layouts | ✅ | ✅ | ✅ |
179
+ | Selection, row actions and tri-state checkboxes | ✅ | ✅ | ✅ |
180
+ | Reorder with a drag preview | ✅ | ✅ | ✅ |
181
+ | Section index rail | ✅ | ✅ | ✅ DOM overlay |
182
+ | Pull to refresh | ✅ | ✅ | ✅ |
183
+ | Container slots around the row stream | ✅ | ✅ | ✅ |
184
+ | Imperative scrolling and position thresholds | ✅ | ✅ | ✅ scrolling; — thresholds |
185
+ | Fixed top overlay / scroll-edge effect | ✅ iOS 26+ | — | — |
186
+
187
+ ## Caveats
188
+
189
+ > [!IMPORTANT]
190
+ > Data rows are fixed templates. The public model rejects React children,
191
+ > per-row render functions, arbitrary style dictionaries, nested lists and
192
+ > unbounded self-sizing content. Use a named container slot for React chrome
193
+ > around the row stream.
194
+
195
+ > [!WARNING]
196
+ > `snapshot` is the declarative baseline. Re-rendering with an older snapshot
197
+ > after imperative patches or a reorder intentionally restores the older state;
198
+ > derive a new snapshot only when the data changes.
199
+
200
+ > [!NOTE]
201
+ > Web runs a windowed DOM engine behind the same component and data API. It
202
+ > mirrors the mobile data and imperative contracts, but its performance is
203
+ > independent of the native implementations and must be measured separately.
204
+
205
+ ## References
206
+
207
+ - [Behavioral contract](docs/SPEC.md)
208
+ - [Row templates](docs/ROW_TEMPLATES.md)
209
+ - [Style vocabulary](docs/STYLE_SPEC.md)
210
+ - [Architecture and ownership](docs/DESIGN.md)
211
+ - [Example app page](../../example/react-native/pages/NativeListExamplePage.tsx)
212
+ - [npm package](https://www.npmjs.com/package/@onekeyfe/react-native-native-list)
213
+ - [Changelog](../../CHANGELOG.md)
214
+
215
+ ## License
216
+
217
+ MIT. The avatar PRNG/HSL algorithms in `src/web/NativeListAvatarWorker.js` are
218
+ adapted from MyCrypto `ethereum-blockies-base64` (MIT); see [LICENSE](LICENSE).
102
219
 
103
220
  ## Row and layout model
104
221
 
105
- `RowModel` is a strict discriminated union. It intentionally accepts no
106
- `ReactNode`, render function, arbitrary style object, or native object handle.
107
-
108
- | Row type | Intended template |
109
- | --------------- | ---------------------------------------------------------- |
110
- | `identity` | Asset, account, wallet, network, or settings identity |
111
- | `walletGroup` | Parent and child wallet-sidebar identity rows in one group |
112
- | `rail` | Compact horizontal item with optional native drag support |
113
- | `activity` | Transaction/activity with amounts and up to three actions |
114
- | `message` | Notification/message with bounded body lines and thumbnail |
115
- | `dataRow` | Two to four fixed table columns, optional index/checkbox |
116
- | `market` | Recycled token, stock, or perpetual quote row |
117
- | `mediaTile` | Gallery or browser-preview tile |
118
- | `metricCard` | KPI or fixed Activity/Performance portfolio card |
119
- | `sectionHeader` | Sticky/group, tri-state, or fixed list-summary header |
120
- | `action` | Fixed action row or fixed footer |
121
- | `system` | Loading, retry, end marker, or bounded spacer |
122
-
123
- Snapshots support `linear`, `sectioned`, `grid`, and `table` layout semantics.
124
- `linear` is a full-width row stream; `sectioned` gives section-header rows a
125
- native visual break and optional pinning; `grid` uses two to four native spans
126
- with structural rows spanning every column; and `table` uses compact,
127
- alternating rows with stable weighted columns and column alignment. Vertical or
128
- horizontal orientation, stable keys, grouped card geometry, empty state, and a
129
- fixed footer remain common capabilities.
130
-
131
- The required theme colors cover list, row, selection, text, separator, accent,
132
- and semantic positive/negative states. The optional `subduedBackground`,
133
- `strongBackground`, `disabledText`, `icon`, `iconSubdued`,
134
- `criticalBackground`, `inverseBackground`, and `inverseText` tokens let native
135
- templates match the OneKey palette without embedding platform-specific style
136
- objects. Identity-row trailing accessories also accept semantic native icons,
137
- for example `{ kind: 'icon', name: 'PlusCircleOutline' }`. A `valuePair` can
138
- independently set `primaryTone` and `secondaryTone` to `primary`, `secondary`,
139
- `positive`, or `negative`; omitted tones keep the original primary/secondary
140
- defaults. Token visuals can provide `networkImage` or `cornerIcon`, while media
141
- tiles can provide `networkImage`, to reproduce OneKey's bottom-right network
142
- and token-state indicators. `dataRow` supports a two-line asset/volume and
143
- price/change layout plus fixed leverage/venue badges. `metricCard` supports the
144
- fixed `activity` and `performance` composite variants used by Portfolio & PnL;
145
- their metrics and progress remain bounded serializable data.
146
-
147
- Set a section header's `variant` to `summary` for the fixed 56-point list
148
- summary template. Its optional `valueActionKey` renders a 16-point secondary
149
- action beside the 16-point medium primary title; summary headers do not accept
150
- a checkbox and do not become sticky.
222
+ `RowModel` is a strict discriminated union. It intentionally accepts no React
223
+ element, render function, arbitrary style object or native object handle, so the
224
+ same snapshot can be validated and rendered on all three platforms.
225
+
226
+ ### Row templates
227
+
228
+ | Row type | Intended template |
229
+ | --- | --- |
230
+ | `identity` | Asset, account, wallet, network or settings identity row |
231
+ | `walletGroup` | Parent and child wallet-sidebar identity rows in one group |
232
+ | `rail` | Compact horizontal item with optional native drag support |
233
+ | `activity` | Transaction/activity with amounts and up to three actions |
234
+ | `message` | Notification/message with bounded body lines and thumbnail |
235
+ | `dataRow` | Two to four fixed table columns, optional index/checkbox |
236
+ | `market` | Recycled token, stock or perpetual quote row |
237
+ | `mediaTile` | Gallery or browser-preview tile |
238
+ | `metricCard` | KPI or fixed Activity/Performance portfolio card |
239
+ | `sectionHeader` | Sticky/group, tri-state or fixed list-summary header |
240
+ | `action` | Fixed action row or fixed footer |
241
+ | `buttonGroup` | Bounded horizontal button row |
242
+ | `system` | Loading, retry, end marker or bounded spacer |
243
+
244
+ [docs/ROW_TEMPLATES.md](docs/ROW_TEMPLATES.md) defines every template with
245
+ structural illustrations, required fields, variants and styling boundaries.
246
+
247
+ ### Layout kinds
248
+
249
+ - `linear` is a full-width row stream.
250
+ - `sectioned` gives section-header rows a native visual break and optional
251
+ pinning.
252
+ - `grid` uses two to seven native spans; structural rows span every column.
253
+ - `table` uses compact, alternating rows with stable weighted columns and column
254
+ alignment.
255
+
256
+ Vertical or horizontal orientation, stable keys, grouped card geometry, an empty
257
+ state and a fixed footer are common capabilities. The required theme tokens
258
+ cover list, row, selection, text, separator, accent and semantic
259
+ positive/negative colors; optional tokens let native templates match the OneKey
260
+ palette without embedding platform-specific style objects. Set a section
261
+ header's `variant` to `summary` for the fixed list-summary template.
151
262
 
152
263
  For a native trailing section index, use a vertical `sectioned` layout, set
153
264
  `capabilities.sectionIndex` to `{ enabled: true }`, and add an `indexTitle` to
154
265
  each section header that should appear in the index. The index follows snapshot
155
- order, skips headers without `indexTitle`, and scrolls to the header's existing
156
- row `key`. Titles must be unique after Unicode NFC normalization, contain no
157
- leading/trailing whitespace, and be at most eight Unicode code points. Set
158
- `hapticsEnabled: false` to follow an application-level reduced-haptics setting.
159
- Set `centeredInWindow: true` to render the interactive index rail against the
160
- full window and center it on the window's geometric midpoint.
161
- The web implementation renders the same explicit index entries as a DOM
162
- overlay, with click and pointer-drag navigation.
163
-
164
- The templates distribute and register no font files. Call
266
+ order and scrolls to the header's existing row `key`. Titles must be unique
267
+ after Unicode NFC normalization, contain no leading/trailing whitespace and stay
268
+ within eight Unicode code points. On Web the same entries render as a DOM
269
+ overlay with click and pointer-drag navigation.
270
+
271
+ ### Fonts
272
+
273
+ Templates distribute and register no font files. Call
165
274
  `configureNativeListFonts` once during UI-runtime startup, after the host loads
166
- its fonts and before mounting lists. The four optional faces replace the whole
167
- mapping; omitted faces and `{}` use system fonts. Mounted lists subscribe to
168
- this runtime's mapping, with an independent native resolver per list. There is
169
- no public per-list override and no cross-runtime native-global mapping.
275
+ its fonts and before mounting lists:
170
276
 
171
277
  ```tsx
172
278
  import { configureNativeListFonts } from '@onekeyfe/react-native-native-list';
173
279
 
174
- // After the host provisions/registers these faces, before mounting lists:
175
280
  configureNativeListFonts({
176
281
  regular: 'Roobert-Regular',
177
282
  medium: 'Roobert-Medium',
@@ -180,89 +285,41 @@ configureNativeListFonts({
180
285
  });
181
286
  ```
182
287
 
183
- On iOS these are registered PostScript names; on Android they are React Native
184
- family keys or matching `fonts/<family>.ttf` host assets. For Web, map each face
185
- to the host's CSS family (for example, `Roobert` for all four weights) and wait
186
- for the four weight-specific font loads before rendering. The host remains
187
- responsible for licensing and provisioning. Changed mappings rebind text and
188
- invalidate list geometry without replacing snapshots or selection; identical
189
- normalized mappings do nothing. Active reorders are cancelled. Missing configured
190
- names use the platform fallback, which on Android may lose the requested weight.
191
- Names must be nonempty trimmed strings, at most 128 UTF-16 units without control
192
- characters; invalid keys/values throw before changing any configuration. See
193
- [SPEC.md](docs/SPEC.md) and [STYLE_SPEC.md](docs/STYLE_SPEC.md) for lifecycle,
194
- system fallback and text-metric acceptance requirements. Their semantic icons and checkbox marks are
195
- the same vector paths as the OneKey component
196
- library, rendered by Core Graphics/UIKit on iOS and Canvas on Android.
288
+ The four optional faces replace the whole mapping; omitted faces and `{}` use
289
+ system fonts. On iOS these are registered PostScript names, on Android they are
290
+ React Native family keys or matching `fonts/<family>.ttf` host assets, and on Web
291
+ they are the host's CSS families. The host remains responsible for licensing and
292
+ provisioning. Changed mappings rebind text and invalidate list geometry without
293
+ replacing snapshots or selection; an active reorder is cancelled. Names must be
294
+ nonempty trimmed strings of at most 128 UTF-16 units without control
295
+ characters — invalid keys or values throw before any configuration changes.
197
296
 
198
297
  ### Market rows
199
298
 
200
- `market` is a fixed native/DOM template, not a React `renderItem`. Its default
201
- token/perpetual geometry uses a 32-point leading image with a 16-point network
202
- corner; stock uses a 40-point image. The trailing change block is 80×32 with an
203
- 8-point radius. All displayed values are already formatted strings; compact
204
- zero runs can use `priceSegments`, `subtitleSegments`, or
299
+ `market` is a fixed native/DOM template, not a React `renderItem`; all displayed
300
+ values are already formatted strings. Its default token/perpetual geometry uses
301
+ a 32-point leading image with a 16-point network corner, while stock uses a
302
+ 40-point image. Compact zero runs can use `priceSegments`, `subtitleSegments` or
205
303
  `change.textSegments` with `{ style: 'subscript' }`.
206
304
 
207
- ```ts
208
- const btc = {
209
- type: 'market',
210
- key: 'btc',
211
- variant: 'token',
212
- leading: { kind: 'token', image: btcImage, networkImage: bitcoinImage },
213
- title: 'BTC',
214
- subtitle: '$1.23B',
215
- price: '$64,230.00',
216
- change: { text: '+2.40%', tone: 'positive' },
217
- badges: [
218
- {
219
- key: 'community',
220
- iconName: 'verified',
221
- tone: 'success',
222
- actionKey: 'market.communityInfo',
223
- accessibilityLabel: 'Community recognized',
224
- },
225
- ],
226
- pressInActionKey: 'market.prewarm',
227
- pressActionKey: 'market.open',
228
- longPressActionKey: 'market.menu',
229
- diagnostics: { imageBindActionKey: 'market.imageBind' },
230
- } satisfies MarketRow;
231
- ```
232
-
233
- Badges accept localized text, a bounded remote image, or the single built-in
234
- `iconName: 'verified'` glyph. A badge `actionKey` emits independently with an
235
- anchor whose source is `marketBadge`. Market long press fires after 800 ms and
236
- is cancelled when the pointer moves more than 10 logical pixels or the list
237
- scrolls. The optional diagnostic action fires when a row binds an image; quote-
238
- only patches (`price`, `priceSegments`, `change`, `accessibilityLabel`, and
239
- `revision`) update visible labels without rebinding that image.
305
+ Badges accept localized text, a bounded remote image or the built-in
306
+ `iconName: 'verified'` glyph, and a badge `actionKey` emits with an anchor whose
307
+ source is `marketBadge`. Market long press fires after 800 ms and is cancelled
308
+ when the pointer moves more than 10 logical pixels or the list scrolls.
309
+ Quote-only patches (`price`, `priceSegments`, `change`, `accessibilityLabel`,
310
+ `revision`) update visible labels without rebinding the image.
240
311
 
241
312
  `style` is deliberately finite and uses the shared row-style vocabulary in
242
- [docs/STYLE_SPEC.md](docs/STYLE_SPEC.md): `horizontalPadding`,
243
- `verticalPadding`, `leadingGap`, `lineGap`, `titleBadgeGap`, `trailingGap`,
244
- the Market-only `titleBadgeLayout: 'inline'`, `contentTrailingGap` and
245
- `subtitleTrailingPadding`, the primary `image` (width/height/shape/corner
246
- radius/content fit), `title`/`subtitle`/`price`/`change` text styles (`token`,
247
- font size, weight, `#RRGGBB`/`#RRGGBBAA` color, line height, 1–3 `lines`,
248
- `truncate`, alignment, vertical alignment and `offsetY`), the change block's
249
- `changeWidth`/`changeHeight`/`changeCornerRadius`, and the common
250
- `style.container` (explicit height, background, opacity, radius, border and
251
- content alignment). Badge `style` accepts only `fontSize`, `fontWeight`,
252
- `lineHeight`, `height` and `horizontalPadding`. Unknown keys at any level are
253
- rejected by `validateSnapshot`/`validatePatches` rather than ignored. Omitting
254
- `style` preserves the defaults. Loading, empty, retry,
255
- and pagination states use the existing `system` rows with
256
- `presentation: 'market'`. Loading rows accept `loadingStyle: 'skeleton'` for
257
- the 56-point token skeleton or `'spinner'` for the centered 52-point pagination
258
- indicator. Use `accessibilityLabel` for loading announcements. Omitting
259
- `loadingStyle` preserves each platform's existing loading rendering.
313
+ [docs/STYLE_SPEC.md](docs/STYLE_SPEC.md); unknown keys at any level are rejected
314
+ by `validateSnapshot`/`validatePatches` rather than ignored. Loading, empty,
315
+ retry and pagination states use the existing `system` rows with
316
+ `presentation: 'market'`.
260
317
 
261
318
  For native reorder, set `capabilities.reorderable` and mark eligible rail rows
262
319
  with `draggable: true`, or add a `drag` trailing accessory to an identity row.
263
320
  Reordering never crosses a `sectionKey` boundary.
264
321
 
265
- ## OneKeyImage inside cells
322
+ ### Images inside cells
266
323
 
267
324
  Pass an `ImageSource` descriptor in the row model; do not pass a
268
325
  `<OneKeyImage />` element:
@@ -283,187 +340,63 @@ const avatar = {
283
340
  ```
284
341
 
285
342
  NativeList defaults `loadingStrategy` to `none`, so source-backed images render
286
- without a loading background or terminal fallback. Set it to `static` or
287
- `skeleton` to opt into loading UI; a configured `fallbackText` or
288
- `fallbackIcon` is shown after a terminal load failure only when loading UI is
289
- enabled.
290
-
291
- Each cell owns a fixed pool of native `OneKeyImageReusableView` slots. On bind,
292
- NativeList forwards the URI, headers, content fit, cache policy, autoplay, TOS
293
- options, overscan, and loading strategy. A stable `rowKey:slot` recycling key
294
- is assigned automatically. Reuse cancels stale work before accepting the next
295
- source, while retaining the same SDWebImage cache/pipeline on iOS and Glide
296
- cache/pipeline on Android as `@onekeyfe/react-native-image`.
297
-
298
- The fixed slots cover token/network overlays, two activity visuals, a message
299
- thumbnail, and stacks of two or three images. Image width and height are
300
- required and bounded to 1–4096 logical pixels.
301
-
302
- ## Batch updates and events
303
-
304
- ```ts
305
- listRef.current?.applyPatches([
306
- {
307
- type: 'identity',
308
- key: 'btc',
309
- changes: { revision: 2, subtitle: 'Updated in one native command' },
310
- },
311
- ]);
312
-
313
- listRef.current?.scrollToKey('btc', true, 'center');
314
- listRef.current?.scrollToIndex({
315
- index: 24,
316
- animated: true,
317
- viewPosition: 0.5,
318
- viewOffset: 12,
319
- });
320
- listRef.current?.scrollToItem({ item: snapshot.rows[24] });
321
- listRef.current?.scrollToOffset({ offset: 320, animated: false });
322
- listRef.current?.scrollToEnd({ animated: true });
323
- listRef.current?.scrollToLocation({ sectionIndex: 2, itemIndex: 4 });
324
- listRef.current?.setRefreshing(false);
325
- ```
326
-
327
- The ref exposes `applySnapshot`, `applyPatches`, `reconcileSelection`,
328
- `scrollToKey`, `scrollToIndex`, `scrollToItem`, `scrollToOffset`, `scrollToEnd`,
329
- `scrollToLocation`, and `setRefreshing`. The legacy
330
- `scrollToIndex(index, animated, alignment)` and
331
- `scrollToKey(key, animated, alignment)` signatures remain supported. Object
332
- parameters follow React Native list semantics: `viewPosition` is from `0`
333
- (start) through `1` (end), and a positive `viewOffset` leaves space before the
334
- target row. Web, Android and iOS explicit position alignment also centers/ends
335
- oversized rows; `nearest` preserves its legacy behavior. See [scrolling contract](docs/SPEC.md#explicit-scroll-alignment-ok-64041)
336
- for platform status.
337
-
338
- Use `initialScrollIndex` or the stable-key extension `initialScrollKey` to set
339
- the first position. They are mutually exclusive, run once after the first
340
- snapshot and native layout are ready, and can be combined with
341
- `initialScrollViewPosition` and `initialScrollViewOffset`. Invalid index and
342
- location requests call `onScrollToIndexFailed`; native lists do not fail merely
343
- because a target row has not been mounted yet. `scrollToLocation` counts
344
- non-summary section headers, then rows carrying that header's `sectionKey`.
343
+ without a loading background or terminal fallback; set it to `static` or
344
+ `skeleton` to opt into loading UI. Image width and height are required and
345
+ bounded to 1–4096 logical pixels. Each cell owns a fixed pool of reusable native
346
+ image slots covering token/network overlays, two activity visuals, a message
347
+ thumbnail and stacks of two or three images. On bind, NativeList forwards the
348
+ URI, headers, content fit, cache policy, autoplay, TOS options, overscan and
349
+ loading strategy, assigns a stable `rowKey:slot` recycling key, and keeps the
350
+ same SDWebImage (iOS) / Glide (Android) cache pipeline as
351
+ `@onekeyfe/react-native-image`.
352
+
353
+ ### Patches, events and scrolling
345
354
 
346
355
  Patches are validated as a batch, keyed by row key, must preserve the row
347
356
  discriminator, and are applied atomically. Prefer a new snapshot for insertions,
348
- removals, layout changes, and section changes; use patches for frequently
357
+ removals, layout changes and section changes; use patches for frequently
349
358
  changing fields.
350
359
 
351
- Events are `onRowAction`, `onSelectionDelta`, `onReorder`, `onEndReached`,
352
- `onVisibleRangeChanged`, and `onRefresh`. Visible-range events are coalesced to
353
- one per display frame and only fire when the first or last visible item changes.
354
- End-reached fires once per snapshot `generation`.
355
-
356
- ## Examples and performance checks
357
-
358
- The React Native example application contains:
359
-
360
- - **Native List**: a categorized entry page. Each of the four containers, ten
361
- row templates, and checkbox selection opens its own source-labeled page; no
362
- container or row paradigm is hidden behind tabs. The scenarios mirror the
363
- corresponding list surfaces in the OneKey application.
364
- - **Native List Benchmark**: reproducible 1,000/5,000-row load, fast scroll,
365
- one-command 500-row patch, and one-command select-all paths.
366
- - **Native List Account Selector**: two independently scrolling native lists
367
- with a fixed Add Wallet footer. The stress fixture exposes 1,000 wallets x
368
- 1,000 accounts while materializing only the selected wallet's 1,000 account
369
- rows and retaining at most three wallets / 3,000 account rows in an LRU cache.
370
-
371
- ### Account Selector performance snapshot (2026-09-05)
372
-
373
- The current acceptance run exercised five page opens, two 101-switch Wallet 1 /
374
- Wallet 2 batches, 25 downward plus 20 upward account-list drags, a repeated 15
375
- downward account-list run, and 15 downward plus 15 upward wallet-list drags. It
376
- also sampled process CPU and memory and verified, after momentum settled, that
377
- the two lists scroll independently and Add Wallet remains fixed at the bottom.
378
- Android additionally covered ART `speed` compilation and ten short fast flings.
379
-
380
- | Metric | iOS Debug Simulator | Android Release-mode emulator |
381
- | ------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
382
- | Environment | iPhone 16 Pro, iOS 18.6 | API 35 arm64, 1080 x 2400, fixed 60 Hz, non-debuggable Hermes |
383
- | Page open, 5 runs | External tap-to-visible median 589 ms; the initial native visible-range callback did not emit | 5 / 5 native callbacks; mount-to-first-visible p50 110 ms; external observation p50 202 ms |
384
- | Wallet switching | 202 / 202; mean 135.3 ms, p50 134 ms, p95 143 ms, max 159 ms | 202 / 202; mean 124.4 ms, p50 118 ms, p95 155 ms, max 213 ms |
385
- | Account-list frame signal | 113.3 effective FPS; p50/p95 interval 6.67/18.33 ms; 6.6% over 17.5 ms | Repeated drag runs reported 92.09-93.06% deadline-missed frames and p50 450 ms |
386
- | Wallet-list frame signal | 78.7 effective FPS; p50/p95 interval 13.33/20.00 ms; 17.8% over 17.5 ms | Down/up runs reported 89.39-100% deadline-missed frames and p50 400 ms |
387
- | Process CPU | Wallet switching mean 48.9%; account scrolling mean 22.9% | Wallet switching mean 66.8%; account scrolling mean 67.1% on Android's per-core scale |
388
- | Retained memory | Physical footprint 286 MB before, 275 MB after the first batch, 287 MB after the second; lifetime peak 335 MB | PSS 138,459 KiB with one wallet cached, 201,668 KiB after warming three wallets, 192,700 KiB after the second batch, 193,976 KiB after scrolling |
389
- | Functional checks | Independent lists and fixed footer pass | Independent lists and fixed footer pass, including zero-difference stable screenshot crops |
390
-
391
- Across the tested environments, Android Release is faster for page opening and
392
- median wallet switching: external page-open p50 is 202 ms versus 589 ms on iOS,
393
- and wallet-switch p50 is 118 ms versus 134 ms. iOS has the tighter switch tail
394
- at p95 143 ms versus 155 ms, clearly leads both account-list and wallet-list
395
- frame results, and uses less process CPU in the measured switch and scroll runs.
396
- Both platforms pass correctness, independent scrolling, the fixed footer,
397
- switch responsiveness, and the short-run retained-memory check. The current
398
- cross-platform performance priority is Android continuous scrolling, followed
399
- by the iOS wallet list's 120 Hz tail behavior.
400
-
401
- ### Test Suite source map
402
-
403
- | Entry | OneKey application source |
404
- | ------------------- | -------------------------------------------------------------------------------------------- |
405
- | Linear container | `AssetList/components/TokenManager/TokenManagerList.tsx` |
406
- | Sectioned container | `ChainSelector/components/AllNetworksManager/NetworksSectionList.tsx` |
407
- | Grid container | `Home/components/NFTListView/index.tsx` |
408
- | Table container | `Perp/components/TokenSelector/PerpTokenSelectorRow.tsx` |
409
- | Identity rows | `Developer/pages/Gallery/Components/stories/ListItem.tsx` |
410
- | Rail rows | `Perp/components/FavoritesBar/FavoriteTokenItem.tsx` |
411
- | Activity rows | `components/TxHistoryListView/TxHistoryListItem.tsx` |
412
- | Message rows | `Notifications/components/NotificationListView.tsx` |
413
- | Data rows | `Perp/components/TokenSelector/PerpTokenSelectorRow.tsx` |
414
- | Media tile rows | `Home/components/NFTListView/NFTListItem.tsx` |
415
- | Metric card rows | `Perp/components/Portfolio/PerpPortfolioContent.tsx` |
416
- | Section header rows | `AllNetworksManager/NetworksSectionList.tsx`, `TxHistoryListView/TxHistorySectionHeader.tsx` |
417
- | Action rows | `TokenManager/TokenManagerList.tsx`, `Discovery/pages/BookmarkListModal/index.tsx` |
418
- | System rows | `components/Loading/ListLoading.tsx`, `TokenListView/CrossNetworkSearchRows.tsx` |
419
- | Checkbox selection | `components/forms/Checkbox/index.tsx`, `AllNetworksManager/NetworksSectionList.tsx` |
420
-
421
- The checkbox page exercises list, section, and row targets plus checked,
422
- unchecked, indeterminate, loading, and disabled presentation. The rail page
423
- keeps horizontal selection and native reorder isolated from the other pages.
424
-
425
- Measure a release build on a physical device. Run each scenario at least three
426
- times, record cold and warm first-visible latency, JS batch-dispatch latency,
427
- UI-thread frame time/dropped frames, and peak memory. During repeated fast
428
- scrolls verify that no stale image from a recycled row becomes visible. The
429
- benchmark page reports deterministic JS timings and visible-range milestones;
430
- use Instruments or Android Studio Profiler for native frame and memory data.
431
-
432
- ## Limits
433
-
434
- - Nitro View/new architecture only; no Paper component.
435
- - Fixed templates only. Arbitrary children, per-row render functions, and
436
- arbitrary style dictionaries are rejected by the public model.
437
- - Template heights and text line counts are bounded. There is no unbounded
438
- self-sizing content, nested list, or React component embedded in a cell.
439
- - A snapshot prop is the declarative baseline. Re-rendering with an older
440
- snapshot after imperative patches or reorder will intentionally restore the
441
- older state.
442
- - The web implementation uses a pure DOM, windowed, recycled row engine behind
443
- the React component. It mirrors the mobile data and imperative APIs, but its
444
- performance must still be measured independently from iOS and Android.
445
-
446
- Start with [docs/SPEC.md](docs/SPEC.md) for the behavioral contract and migration
447
- status. See [docs/DESIGN.md](docs/DESIGN.md) for the architecture and ownership model, and
448
- [docs/STYLE_SPEC.md](docs/STYLE_SPEC.md) for the shared style vocabulary: design
449
- tokens, local layout-safety rules, common list capabilities and current implementation
450
- gaps. [docs/ROW_TEMPLATES.md](docs/ROW_TEMPLATES.md) defines all 12 row types with
451
- structural illustrations, required fields, variants and styling boundaries.
360
+ `applyPatches` applies a validated batch to the current snapshot;
361
+ `reconcileSelection` replaces native selection without emitting a second delta. Object scroll parameters follow
362
+ React Native list semantics: `viewPosition` runs from `0` (start) through `1`
363
+ (end), and a positive `viewOffset` leaves space before the target row. Explicit
364
+ position alignment also centers/ends oversized rows on all three platforms.
365
+ `initialScrollIndex` or the stable-key extension `initialScrollKey` sets the
366
+ first position once, after the first snapshot and native layout are ready, and
367
+ can be combined with `initialScrollViewPosition` and
368
+ `initialScrollViewOffset`. `scrollToLocation` counts non-summary section headers,
369
+ then rows carrying that header's `sectionKey`. Invalid index and location
370
+ requests call `onScrollToIndexFailed`; native lists do not fail merely because a
371
+ target row has not been mounted yet.
372
+
373
+ ### Example app and native checks
374
+
375
+ The React Native example application contains a categorized native-list entry
376
+ page, a reproducible benchmark page, and an account-selector stress page
377
+ (1,000 wallets × 1,000 accounts) that materializes only the selected wallet's
378
+ rows.
379
+
380
+ - [Native list entry page](../../example/react-native/pages/NativeListExamplePage.tsx)
381
+ - [Row style page](../../example/react-native/pages/NativeListRowStylePage.tsx)
382
+ - [Benchmark page](../../example/react-native/pages/NativeListBenchmarkPage.tsx)
383
+ - [Account selector page](../../example/react-native/pages/NativeListAccountSelectorPage.tsx)
384
+
385
+ Swift geometry regressions compile the shipping helper directly:
386
+
387
+ ```sh
388
+ swift test --package-path tests/swiftpm
389
+ ```
452
390
 
453
- ## Native scrolling regression tests
391
+ The Android scroll-alignment suite runs against the package's Kotlin helper in a
392
+ configured consumer project:
454
393
 
455
- In a configured React Native example/consumer Android project, run
456
- `./gradlew :onekeyfe_react-native-native-list:testDebugUnitTest --tests com.margelo.nitro.nativelist.NativeListScrollAlignmentTest`.
457
- This uses the existing JUnit dependency and compiles the shipping Kotlin helper
458
- and NativeListView. The Gradle project name may differ in another consumer.
394
+ ```sh
395
+ ./gradlew :onekeyfe_react-native-native-list:testDebugUnitTest \
396
+ --tests com.margelo.nitro.nativelist.NativeListScrollAlignmentTest
397
+ ```
459
398
 
460
- Run `swift test --package-path tests/swiftpm` from this package for the native
461
- Swift geometry regression suite. Its source symlink compiles the shipping
462
- helper directly. These are geometry unit tests, not RecyclerView/UICollectionView
463
- integration tests. Full-app visibility, unmounted/deferred behavior and
399
+ Both are geometry unit tests. Full-app visibility, deferred behavior and
464
400
  consumer-owned layout/input cancellation require separate runtime validation;
465
- see [the scrolling spec](docs/SPEC.md).
466
-
467
- `webSectionIndexContainerRef` uses the actual View instance type through
468
- `React.ElementRef<typeof View>`. RN 0.86.2/0.88.0 declaration checks preserve its
469
- existing nullable ref API without a consumer declaration patch.
401
+ see [docs/SPEC.md](docs/SPEC.md). [docs/DESIGN.md](docs/DESIGN.md) documents the
402
+ architecture and ownership model.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-native-list",
3
- "version": "6.7.0-46",
3
+ "version": "6.7.0-47",
4
4
  "description": "Template-driven native RecyclerView and UICollectionView for React Native",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",