@onekeyfe/react-native-native-list 6.7.0-alpha.466 → 6.8.0-10

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 (46) hide show
  1. package/README.md +312 -379
  2. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +15 -6
  3. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
  4. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
  5. package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
  6. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +60 -0
  7. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +5 -1
  8. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +75 -0
  9. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +25 -19
  10. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -0
  11. package/docs/ROW_TEMPLATES.md +11 -4
  12. package/docs/SPEC.md +296 -20
  13. package/docs/STYLE_SPEC.md +12 -0
  14. package/ios/NativeListActivityDetailsView.swift +13 -5
  15. package/ios/NativeListMediaPlaceholderView.swift +189 -0
  16. package/ios/NativeListMediaPreviewSlot.swift +122 -61
  17. package/ios/NativeListMediaTileRenderer.swift +13 -13
  18. package/ios/NativeListResolvedText.swift +15 -4
  19. package/ios/NativeListTextLabel.swift +106 -0
  20. package/ios/RNCNativeListView.swift +129 -32
  21. package/ios/tests/NativeListActivityPresentationTests.swift +270 -0
  22. package/ios/tests/NativeListLifecycleTests.swift +369 -40
  23. package/ios/tests/NativeListMediaVisibilityTests.swift +41 -7
  24. package/lib/module/NativeList.js +17 -4
  25. package/lib/module/NativeList.web.js +3 -1
  26. package/lib/module/validation.js +53 -4
  27. package/lib/module/web/NativeListGeneratedIcons.js +1 -0
  28. package/lib/module/web/NativeListWebEngine.js +13 -11
  29. package/lib/module/web/templates/ActivityRowRenderer.js +29 -23
  30. package/lib/module/web/templates/DataRowRenderer.js +54 -1
  31. package/lib/module/web/templates/IdentityRowRenderer.js +3 -1
  32. package/lib/module/web/templates/MediaTileRowRenderer.js +84 -15
  33. package/lib/typescript/src/models.d.ts +18 -1
  34. package/package.json +1 -1
  35. package/scripts/generate-icons.test.mjs +1 -0
  36. package/scripts/native-list-icons.json +1 -1
  37. package/src/NativeList.tsx +25 -4
  38. package/src/NativeList.web.tsx +1 -1
  39. package/src/models.ts +18 -0
  40. package/src/validation.ts +96 -1
  41. package/src/web/NativeListGeneratedIcons.ts +1 -0
  42. package/src/web/NativeListWebEngine.ts +16 -11
  43. package/src/web/templates/ActivityRowRenderer.ts +42 -32
  44. package/src/web/templates/DataRowRenderer.ts +76 -1
  45. package/src/web/templates/IdentityRowRenderer.ts +3 -3
  46. package/src/web/templates/MediaTileRowRenderer.ts +90 -15
@@ -3,6 +3,112 @@ import UIKit
3
3
  class NativeListTextLabel: UILabel {
4
4
  var rowVerticalAlignment: String? { didSet { setNeedsDisplay() } }
5
5
  var rowOffsetY: CGFloat = 0 { didSet { setNeedsDisplay() } }
6
+ /// UTF-16 offset the touchable text starts at. `nil` keeps the label's own
7
+ /// hit testing, its whole bounds. With an offset only the drawn text from
8
+ /// there on takes touches, plus a small slop, so text before the offset and
9
+ /// the unused width of a stretched label fall through to the row behind it:
10
+ /// `0` covers all of the text, the text length leaves nothing to touch.
11
+ var touchableTextStart: Int?
12
+ private static let touchSlop = CGSize(width: 8, height: 6)
13
+
14
+ /// One rect per laid-out run of touchable text, in label coordinates. The
15
+ /// label's own layout is not public, so the runs come from a text container
16
+ /// with the label's width, line cap and truncation. A line holds one run, or
17
+ /// several where mixed-direction text puts plain text between touchable text.
18
+ var touchableTextRegions: [CGRect] {
19
+ guard let start = touchableTextStart, let attributed = attributedText, attributed.length > start,
20
+ bounds.width > 0
21
+ else { return [] }
22
+ let storage = NSTextStorage(attributedString: attributed)
23
+ let manager = NSLayoutManager()
24
+ let container = NSTextContainer(
25
+ size: CGSize(width: bounds.width, height: .greatestFiniteMagnitude))
26
+ container.lineFragmentPadding = 0
27
+ container.maximumNumberOfLines = numberOfLines
28
+ container.lineBreakMode = lineBreakMode
29
+ manager.addTextContainer(container)
30
+ storage.addLayoutManager(manager)
31
+ let glyphs = manager.glyphRange(for: container)
32
+ // Mirrors drawText: the text is centered unless the row aligns it.
33
+ let textHeight = manager.usedRect(for: container).height
34
+ var originY = (bounds.height - textHeight) / 2
35
+ if let alignment = rowVerticalAlignment {
36
+ originY = alignment == "top" ? 0 : alignment == "bottom" ? bounds.height - textHeight : originY
37
+ }
38
+ originY += rowOffsetY
39
+ var lines: [CGRect] = []
40
+ var visibleEnd = attributed.length
41
+ manager.enumerateLineFragments(forGlyphRange: glyphs) { _, usedRect, _, lineGlyphs, _ in
42
+ lines.append(usedRect)
43
+ let truncated = manager.truncatedGlyphRange(inLineFragmentForGlyphAt: lineGlyphs.location)
44
+ if truncated.location != NSNotFound {
45
+ visibleEnd = min(visibleEnd, manager.characterIndexForGlyph(at: truncated.location))
46
+ }
47
+ }
48
+ // Truncation can hide the touchable text altogether. The ellipsis then
49
+ // stands for plain text as well, so nothing is left to touch.
50
+ guard start < visibleEnd else { return [] }
51
+ // The layout engine's own rects for a character range: one per line and
52
+ // per visual run, which is what makes mixed-direction text come out right.
53
+ func runs(_ characters: NSRange) -> [CGRect] {
54
+ let range = NSIntersectionRange(
55
+ manager.glyphRange(forCharacterRange: characters, actualCharacterRange: nil), glyphs)
56
+ guard range.length > 0 else { return [] }
57
+ var rects: [CGRect] = []
58
+ manager.enumerateEnclosingRects(
59
+ forGlyphRange: range, withinSelectedGlyphRange: NSRange(location: NSNotFound, length: 0),
60
+ in: container
61
+ ) { rect, _ in
62
+ // A run that continues on the next line is reported up to the
63
+ // container edge; its text ends where the line's used rect does.
64
+ guard let used = lines.first(where: { $0.minY <= rect.midY && rect.midY < $0.maxY })
65
+ else { return }
66
+ let minX = max(rect.minX, used.minX)
67
+ let maxX = min(rect.maxX, used.maxX)
68
+ if maxX > minX {
69
+ rects.append(CGRect(x: minX, y: rect.minY, width: maxX - minX, height: rect.height))
70
+ }
71
+ }
72
+ return rects
73
+ }
74
+ let plain = runs(NSRange(location: 0, length: start))
75
+ return runs(NSRange(location: start, length: attributed.length - start)).map { run in
76
+ // The slop reaches into blank space only. Sideways it stops at plain
77
+ // text on the same line, so text before the start never takes the
78
+ // touch, however narrow it is.
79
+ var minX = run.minX - Self.touchSlop.width
80
+ var maxX = run.maxX + Self.touchSlop.width
81
+ for other in plain where other.minY < run.midY && run.midY < other.maxY {
82
+ if other.maxX <= run.minX + 0.5 { minX = max(minX, other.maxX) }
83
+ if other.minX >= run.maxX - 0.5 { maxX = min(maxX, other.minX) }
84
+ }
85
+ // Vertically it grows only past the first and last line of the whole
86
+ // layout, so it never reaches into another line.
87
+ let line = lines.firstIndex { $0.minY <= run.midY && run.midY < $0.maxY }
88
+ let top = line == 0 ? Self.touchSlop.height : 0
89
+ let bottom = line == lines.count - 1 ? Self.touchSlop.height : 0
90
+ return CGRect(
91
+ x: minX, y: run.minY + originY - top, width: maxX - minX,
92
+ height: run.height + top + bottom)
93
+ }
94
+ }
95
+
96
+ override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
97
+ guard touchableTextStart != nil else { return super.point(inside: point, with: event) }
98
+ return touchableTextRegions.contains { $0.contains(point) }
99
+ }
100
+
101
+ // Assistive activation taps this point; the label's center can be blank.
102
+ override var accessibilityActivationPoint: CGPoint {
103
+ get {
104
+ guard let region = touchableTextRegions.first else {
105
+ return super.accessibilityActivationPoint
106
+ }
107
+ let target = UIAccessibility.convertToScreenCoordinates(region.intersection(bounds), in: self)
108
+ return CGPoint(x: target.midX, y: target.midY)
109
+ }
110
+ set { super.accessibilityActivationPoint = newValue }
111
+ }
6
112
 
7
113
  override func drawText(in rect: CGRect) {
8
114
  var target = rect
@@ -31,6 +31,8 @@ final class NativeListView: UIView {
31
31
  private var refreshEmittedForDrag = false
32
32
  private var minimumDragOffset: CGFloat = 0
33
33
  private var containerSlotHeights: [CGFloat] = [0, 0, 0, 0, 0, 0]
34
+ private var containerHeaderHeightIsAuthoritative = false
35
+ private weak var currentHeaderRoot: UIView?
34
36
  private var disclosureCVisibleHeight: CGFloat = 0
35
37
  private var disclosureInset: CGFloat = 0
36
38
  private var disclosureStartCHeight: CGFloat = 0
@@ -197,8 +199,10 @@ final class NativeListView: UIView {
197
199
  if !tail.retiringKeys.isEmpty {
198
200
  var snapshot = dataSource.snapshot()
199
201
  snapshot.deleteItems(Array(tail.retiringKeys))
200
- dataSource.apply(snapshot, animatingDifferences: false)
201
- itemsByKey = Dictionary(uniqueKeysWithValues: config.items.map { ($0.key, $0) })
202
+ let finishRetiringCells = replaceCellItems(
203
+ with: Dictionary(uniqueKeysWithValues: config.items.map { ($0.key, $0) }),
204
+ outgoingKeys: tail.retiringKeys)
205
+ dataSource.apply(snapshot, animatingDifferences: false, completion: finishRetiringCells)
202
206
  }
203
207
  clearStructuralTail()
204
208
  structuralSpacerHeight = 0
@@ -295,6 +299,10 @@ final class NativeListView: UIView {
295
299
  host.addSubview(view)
296
300
  reactContainerSlots.insert((view, host), at: min(index, reactContainerSlots.count))
297
301
  collectionView.addSubview(host)
302
+ if index == 0 {
303
+ currentHeaderRoot = view
304
+ if !containerHeaderHeightIsAuthoritative { updatePendingHeaderHeight() }
305
+ }
298
306
  layoutContainerSlots()
299
307
  setNeedsLayout()
300
308
  }
@@ -306,12 +314,17 @@ final class NativeListView: UIView {
306
314
  updateTopScrollEdge()
307
315
  return
308
316
  }
317
+ let removedCurrentHeader = currentHeaderRoot === view
318
+ if removedCurrentHeader { currentHeaderRoot = nil }
309
319
  reactContainerSlots.removeAll { slot in
310
320
  guard slot.content === view else { return false }
311
321
  view.removeFromSuperview()
312
322
  slot.host.removeFromSuperview()
313
323
  return true
314
324
  }
325
+ if removedCurrentHeader && !containerHeaderHeightIsAuthoritative {
326
+ updatePendingHeaderHeight()
327
+ }
315
328
  }
316
329
 
317
330
  func setTopScrollEdge(effect: NativeListTopScrollEdgeEffect, overlayHeight: CGFloat) {
@@ -376,12 +389,37 @@ final class NativeListView: UIView {
376
389
 
377
390
  func setContainerSlotHeightsJson(_ json: String, followedBySnapshot: Bool = false) {
378
391
  guard let data = json.data(using: .utf8),
379
- let heights = try? JSONSerialization.jsonObject(with: data) as? [Double],
380
- (heights.count == 4 || heights.count == 6),
392
+ var values = try? JSONSerialization.jsonObject(with: data) as? [Any],
393
+ (values.count == 4 || values.count == 6) else { return }
394
+ let headerPending = values[0] is NSNull
395
+ if headerPending { values[0] = 0.0 }
396
+ guard let heights = values as? [Double],
381
397
  heights.allSatisfy({ $0.isFinite && $0 >= 0 }) else { return }
398
+ containerHeaderHeightIsAuthoritative = !headerPending
399
+ var next = heights.map { CGFloat($0) } + (heights.count == 4 ? [0, 0] : [])
400
+ if headerPending { next[0] = pendingHeaderHeight() }
401
+ applyContainerSlotHeights(next, followedBySnapshot: followedBySnapshot)
402
+ }
403
+
404
+ private func pendingHeaderHeight() -> CGFloat {
405
+ guard let bounds = currentHeaderRoot?.bounds,
406
+ bounds.width.isFinite, bounds.width > 0,
407
+ bounds.height.isFinite, bounds.height >= 0 else { return 0 }
408
+ return ceil(bounds.height)
409
+ }
410
+
411
+ private func updatePendingHeaderHeight() {
412
+ let height = pendingHeaderHeight()
413
+ guard height != containerSlotHeights[0] else { return }
414
+ var next = containerSlotHeights
415
+ next[0] = height
416
+ applyContainerSlotHeights(next)
417
+ }
418
+
419
+ private func applyContainerSlotHeights(_ heights: [CGFloat], followedBySnapshot: Bool = false) {
382
420
  let previousHeights = containerSlotHeights
383
- let footerDelta = containerSlotHeights[2] - CGFloat(heights[2])
384
- containerSlotHeights = heights.map { CGFloat($0) } + (heights.count == 4 ? [0, 0] : [])
421
+ let footerDelta = containerSlotHeights[2] - heights[2]
422
+ containerSlotHeights = heights
385
423
  let contentHeightChanged = previousHeights[4] != containerSlotHeights[4]
386
424
  let toggleHeightChanged = previousHeights[5] != containerSlotHeights[5]
387
425
  let disclosureGeometryInvalid = structuralTail != nil && config?.disclosure != nil
@@ -665,6 +703,9 @@ final class NativeListView: UIView {
665
703
  private var config: NativeListConfig?
666
704
  private var acceptedRowIndex: AcceptedRowIndex?
667
705
  private var itemsByKey: [String: NativeListItem] = [:]
706
+ private static let emptyCellReuseIdentifier = "NativeList.EmptyCell"
707
+ private var retiringCellItems: [String: (item: NativeListItem, update: UInt64)] = [:]
708
+ private var cellUpdate: UInt64 = 0
668
709
  private var endReachedGeneration: Int?
669
710
  private var lastVisibleRange: (first: Int, last: Int, firstKey: String?, lastKey: String?)?
670
711
  private var visibleEventScheduled = false
@@ -741,6 +782,8 @@ final class NativeListView: UIView {
741
782
  self.collectionView.setContentOffset(self.collectionView.contentOffset, animated: false)
742
783
  }
743
784
  NativeListRendererRegistry.register(in: collectionView)
785
+ collectionView.register(UICollectionViewCell.self,
786
+ forCellWithReuseIdentifier: Self.emptyCellReuseIdentifier)
744
787
  collectionView.backgroundColor = .clear
745
788
  collectionView.delegate = self
746
789
  collectionView.dragDelegate = self
@@ -837,14 +880,30 @@ final class NativeListView: UIView {
837
880
  footerCell.addGestureRecognizer(footerHighlight)
838
881
  dataSource = UICollectionViewDiffableDataSource<Int, String>(collectionView: collectionView) {
839
882
  [weak self] collectionView, indexPath, key in
840
- guard let self,
841
- let item = self.itemsByKey[key],
842
- let cell = collectionView.dequeueReusableCell(
843
- withReuseIdentifier: NativeListRendererRegistry.reuseIdentifier(for: item.rendererKey),
844
- for: indexPath
845
- ) as? NativeListRowHost else { return nil }
883
+ guard let self, let item = self.itemsByKey[key] ?? self.retiringCellItems[key]?.item else {
884
+ let cell = collectionView.dequeueReusableCell(
885
+ withReuseIdentifier: NativeListView.emptyCellReuseIdentifier, for: indexPath)
886
+ cell.isUserInteractionEnabled = false
887
+ cell.accessibilityElementsHidden = true
888
+ return cell
889
+ }
890
+ let reusableCell = collectionView.dequeueReusableCell(
891
+ withReuseIdentifier: NativeListRendererRegistry.reuseIdentifier(for: item.rendererKey),
892
+ for: indexPath)
893
+ guard let cell = reusableCell as? NativeListRowHost else { return reusableCell }
894
+ if self.itemsByKey[key] == nil {
895
+ cell.onAction = nil
896
+ cell.onBindingInvalidated = nil
897
+ cell.isHidden = true
898
+ cell.isUserInteractionEnabled = false
899
+ cell.accessibilityElementsHidden = true
900
+ return cell
901
+ }
846
902
  cell.onAction = { [weak self] item, action, target, origin in
847
- self?.handleAction(item: item, actionKey: action, target: target, origin: origin)
903
+ // A child renderer can emit a different key than the collection row that owns it.
904
+ guard let self, self.itemsByKey[key] != nil,
905
+ !self.isInertPresentationKey(key) else { return }
906
+ self.handleAction(item: item, actionKey: action, target: target, origin: origin)
848
907
  }
849
908
  cell.onBindingInvalidated = { [weak self] cell, epoch in
850
909
  self?.handleBindingInvalidated(cell: cell, epoch: epoch)
@@ -937,6 +996,7 @@ final class NativeListView: UIView {
937
996
  guard !disposed,
938
997
  window != nil,
939
998
  collectionView.delegate === self,
999
+ flowLayout.scrollDirection == .vertical,
940
1000
  collectionView.bounds.width > 0,
941
1001
  collectionView.bounds.height > 0 else { return }
942
1002
  NotificationCenter.default.post(
@@ -971,11 +1031,11 @@ final class NativeListView: UIView {
971
1031
  configureLayout(config)
972
1032
  if lastLayoutDirection != direction { rebindRowsForLayoutDirection(config) }
973
1033
  }
974
- performPendingScrollIfNeeded()
975
- layoutContainerSlots()
976
1034
  if !hadUsableBounds && collectionView.bounds.width > 0 && collectionView.bounds.height > 0 {
977
1035
  notifyPagerScrollViewReadyIfNeeded()
978
1036
  }
1037
+ performPendingScrollIfNeeded()
1038
+ layoutContainerSlots()
979
1039
  }
980
1040
 
981
1041
  // A layout-direction change may arrive without a layout pass (semantic attribute or trait).
@@ -1017,6 +1077,29 @@ final class NativeListView: UIView {
1017
1077
  acceptedRowIndex = AcceptedRowIndex(items: next.items)
1018
1078
  }
1019
1079
 
1080
+ // Layout can ask UIKit's outgoing snapshot for cells before apply starts or while it settles.
1081
+ // Keep those descriptors outside the accepted row lookup and release each at its own commit.
1082
+ private func replaceCellItems(
1083
+ with nextItems: [String: NativeListItem], outgoingKeys: some Sequence<String>
1084
+ ) -> (() -> Void)? {
1085
+ cellUpdate &+= 1
1086
+ let update = cellUpdate
1087
+ var retiringKeys: [String] = []
1088
+ for key in outgoingKeys where nextItems[key] == nil {
1089
+ guard let item = itemsByKey[key] ?? retiringCellItems[key]?.item else { continue }
1090
+ retiringCellItems[key] = (item, update)
1091
+ retiringKeys.append(key)
1092
+ }
1093
+ itemsByKey = nextItems
1094
+ guard !retiringKeys.isEmpty else { return nil }
1095
+ return { [weak self] in
1096
+ guard let self else { return }
1097
+ for key in retiringKeys where self.retiringCellItems[key]?.update == update {
1098
+ self.retiringCellItems.removeValue(forKey: key)
1099
+ }
1100
+ }
1101
+ }
1102
+
1020
1103
  func applySnapshotJson(_ json: String) {
1021
1104
  guard let next = try? NativeListConfig.parse(json: json) else { return }
1022
1105
  let transition = next.structuralTransition
@@ -1207,13 +1290,14 @@ final class NativeListView: UIView {
1207
1290
  disclosureInset = next.disclosure?.expanded == true
1208
1291
  ? next.disclosure?.expandedTrailingInset ?? 0 : 0
1209
1292
  }
1210
- itemsByKey = Dictionary(uniqueKeysWithValues: next.items.map { ($0.key, $0) })
1211
- itemsByKey.merge(structuralRemovedItems) { current, _ in current }
1293
+ var nextItemsByKey = Dictionary(uniqueKeysWithValues: next.items.map { ($0.key, $0) })
1294
+ nextItemsByKey.merge(structuralRemovedItems) { current, _ in current }
1212
1295
  if let tail = structuralTail, !tail.retiringKeys.isEmpty {
1213
- itemsByKey.merge(presentationItems.filter { tail.retiringKeys.contains($0.key) }) {
1296
+ nextItemsByKey.merge(presentationItems.filter { tail.retiringKeys.contains($0.key) }) {
1214
1297
  current, _ in current
1215
1298
  }
1216
1299
  }
1300
+ let finishRetiringCells = replaceCellItems(with: nextItemsByKey, outgoingKeys: oldKeys)
1217
1301
  if !animateStructure, let tail = structuralTail {
1218
1302
  if themeChanged || tailGeometryChanged {
1219
1303
  if !newDisclosureCommand { interruptedPendingID = activePendingID }
@@ -1304,7 +1388,8 @@ final class NativeListView: UIView {
1304
1388
  let explicitScrollPendingAtApply = pendingScrollRequest != nil
1305
1389
  dataSource.apply(snapshot, animatingDifferences: animateStructure && structuralRemovedItems.isEmpty
1306
1390
  && structuralTail == nil) { [weak self] in
1307
- guard let self else { return }
1391
+ finishRetiringCells?()
1392
+ guard let self, !self.disposed else { return }
1308
1393
  self.collectionView.layoutIfNeeded()
1309
1394
  self.updateStructuralTailWindow()
1310
1395
  self.layoutContainerSlots()
@@ -1473,11 +1558,14 @@ final class NativeListView: UIView {
1473
1558
  if progress >= 1 {
1474
1559
  if !structuralRemovedItems.isEmpty {
1475
1560
  var snapshot = dataSource.snapshot()
1476
- snapshot.deleteItems(Array(structuralRemovedItems.keys))
1561
+ let outgoingKeys = Array(structuralRemovedItems.keys)
1562
+ snapshot.deleteItems(outgoingKeys)
1477
1563
  structuralRemovedItems.removeAll()
1478
1564
  structuralRemovedHeights.removeAll()
1479
- dataSource.apply(snapshot, animatingDifferences: false)
1480
- itemsByKey = Dictionary(uniqueKeysWithValues: config.items.map { ($0.key, $0) })
1565
+ let finishRetiringCells = replaceCellItems(
1566
+ with: Dictionary(uniqueKeysWithValues: config.items.map { ($0.key, $0) }),
1567
+ outgoingKeys: outgoingKeys)
1568
+ dataSource.apply(snapshot, animatingDifferences: false, completion: finishRetiringCells)
1481
1569
  collectionView.layoutIfNeeded()
1482
1570
  if !structuralScrollInterrupted && !collectionView.isTracking
1483
1571
  && !collectionView.isDragging && !collectionView.isDecelerating {
@@ -1653,6 +1741,7 @@ final class NativeListView: UIView {
1653
1741
  requestScroll(.index(index, animated, alignment, viewPosition, viewOffset))
1654
1742
  }
1655
1743
 
1744
+ @objc(onekeyScrollToOffset:animated:)
1656
1745
  func scrollToOffset(_ offset: Double, animated: Bool) {
1657
1746
  requestScroll(.offset(offset, animated))
1658
1747
  }
@@ -2242,7 +2331,9 @@ final class NativeListView: UIView {
2242
2331
  // while the diffable snapshot and cell index paths keep the pre-drag order until
2243
2332
  // the move commits. Resolving sizes from the snapshot swaps row heights.
2244
2333
  private func layoutItem(at indexPath: IndexPath) -> NativeListItem? {
2245
- guard let keys = interactiveMovementKeys else { return item(at: indexPath) }
2334
+ guard let keys = interactiveMovementKeys else {
2335
+ return item(at: indexPath, includeRetiringCell: true)
2336
+ }
2246
2337
  return keys[safe: indexPath.item].flatMap { itemsByKey[$0] }
2247
2338
  }
2248
2339
 
@@ -2255,15 +2346,16 @@ final class NativeListView: UIView {
2255
2346
  interactiveMovementKeys = keys
2256
2347
  }
2257
2348
 
2258
- private func item(at indexPath: IndexPath) -> NativeListItem? {
2259
- if let key = dataSource.itemIdentifier(for: indexPath), let item = itemsByKey[key] {
2260
- return item
2349
+ private func item(at indexPath: IndexPath, includeRetiringCell: Bool = false) -> NativeListItem? {
2350
+ if let key = dataSource.itemIdentifier(for: indexPath) {
2351
+ return itemsByKey[key] ?? (includeRetiringCell ? retiringCellItems[key]?.item : nil)
2261
2352
  }
2262
2353
  return config?.items[safe: indexPath.item]
2263
2354
  }
2264
2355
 
2265
2356
  private func isInertPresentationKey(_ key: String) -> Bool {
2266
2357
  structuralTail?.indexByKey[key] != nil || structuralRemovedItems[key] != nil
2358
+ || (itemsByKey[key] == nil && retiringCellItems[key] != nil)
2267
2359
  }
2268
2360
 
2269
2361
  private func updateAtomicReorderTarget(to targetIndex: Int, key targetKey: String, animated: Bool) {
@@ -2609,7 +2701,7 @@ final class NativeListView: UIView {
2609
2701
  if item.key == interactiveReorderCompactKey {
2610
2702
  cell.setWalletGroupReorderCompact(true)
2611
2703
  }
2612
- let retiring = structuralRemovedItems[item.key] != nil
2704
+ let retiring = cell !== footerCell && structuralRemovedItems[item.key] != nil
2613
2705
  cell.structuralContentHeight = retiring
2614
2706
  ? rowHeight(item, allocatedWidth: cell.bounds.width) : nil
2615
2707
  if retiring { cell.clipsToBounds = true }
@@ -2625,7 +2717,7 @@ final class NativeListView: UIView {
2625
2717
 
2626
2718
  private func handleRowPress(_ item: NativeListItem, origin: NativeListActionOrigin?) {
2627
2719
  // OneKey patch: missing-address rows keep accessory actions available.
2628
- guard let config, item.isRowPressEnabled, !isInertPresentationKey(item.key) else { return }
2720
+ guard let config, item.isRowPressEnabled else { return }
2629
2721
  if config.rowPressToggles && item.isSelectable && config.selectionMode != "none" {
2630
2722
  updateSelection(target: NativeSelectionTarget(scope: "row", key: item.key), sourceKey: item.key)
2631
2723
  return
@@ -2661,7 +2753,7 @@ final class NativeListView: UIView {
2661
2753
  target: NativeSelectionTarget?,
2662
2754
  origin: NativeListActionOrigin?
2663
2755
  ) {
2664
- guard !item.data.bool("disabled"), !isInertPresentationKey(item.key) else { return }
2756
+ guard !item.data.bool("disabled") else { return }
2665
2757
  if let target, config?.selectionMode != "none" {
2666
2758
  updateSelection(target: target, sourceKey: item.key)
2667
2759
  return
@@ -2670,8 +2762,7 @@ final class NativeListView: UIView {
2670
2762
  }
2671
2763
 
2672
2764
  private func updateSelection(target: NativeSelectionTarget, sourceKey: String) {
2673
- guard var current = config, current.selectionMode != "none",
2674
- !isInertPresentationKey(sourceKey) else { return }
2765
+ guard var current = config, current.selectionMode != "none" else { return }
2675
2766
  let keys = selectionKeys(target: target, items: current.items)
2676
2767
  guard !keys.isEmpty else { return }
2677
2768
  let before = current.selectedKeys
@@ -3084,6 +3175,9 @@ final class NativeListView: UIView {
3084
3175
  dataSource = nil
3085
3176
 
3086
3177
  config = nil
3178
+ currentHeaderRoot = nil
3179
+ containerHeaderHeightIsAuthoritative = false
3180
+ containerSlotHeights[0] = 0
3087
3181
  acceptedRowIndex = nil
3088
3182
  pagerStickyHeights.removeAllObjects()
3089
3183
  for slot in reactContainerSlots { slot.host.layer.mask = nil }
@@ -3092,6 +3186,7 @@ final class NativeListView: UIView {
3092
3186
  structuralSpacerHeight = 0
3093
3187
  structuralFooterStartY = nil
3094
3188
  itemsByKey.removeAll()
3189
+ retiringCellItems.removeAll()
3095
3190
  sectionIndexEntries.removeAll()
3096
3191
  if let pagerCommandCancelObserver {
3097
3192
  NotificationCenter.default.removeObserver(pagerCommandCancelObserver)
@@ -3573,7 +3668,9 @@ final class NativeListFlowLayout: UICollectionViewFlowLayout {
3573
3668
  guard scrollDirection == .horizontal, let collectionView else { return }
3574
3669
 
3575
3670
  var nextX = sectionInset.left
3576
- let itemCount = collectionView.numberOfItems(inSection: 0)
3671
+ let itemCount = collectionView.numberOfSections > 0
3672
+ ? collectionView.numberOfItems(inSection: 0)
3673
+ : 0
3577
3674
  for item in 0..<itemCount {
3578
3675
  let indexPath = IndexPath(item: item, section: 0)
3579
3676
  guard let attributes = super.layoutAttributesForItem(at: indexPath)?.copy()