@onekeyfe/react-native-native-list 6.8.0-2 → 6.8.0-20

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 (56) hide show
  1. package/android/build.gradle +3 -0
  2. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +18 -4
  3. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +70 -33
  4. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +3 -2
  5. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +8 -1
  6. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +21 -4
  7. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
  8. package/android/src/main/java/com/onekey/nativelist/NativeListRowUpdates.kt +34 -0
  9. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
  10. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
  11. package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
  12. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentitySubtitleBindingTest.kt +177 -0
  13. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
  14. package/docs/ROW_TEMPLATES.md +3 -1
  15. package/docs/SPEC.md +165 -4
  16. package/docs/STYLE_SPEC.md +7 -1
  17. package/ios/NativeListAccessoryStack.swift +22 -0
  18. package/ios/NativeListDataRowRenderer.swift +12 -5
  19. package/ios/NativeListIdentityRenderer.swift +36 -58
  20. package/ios/NativeListLeadingVisual.swift +8 -0
  21. package/ios/NativeListMarketRenderer.swift +6 -2
  22. package/ios/NativeListModels.swift +7 -0
  23. package/ios/NativeListResolvedText.swift +9 -7
  24. package/ios/NativeListSectionHeaderRenderer.swift +9 -43
  25. package/ios/NativeListTextStyles.swift +72 -12
  26. package/ios/RNCNativeListView.swift +203 -45
  27. package/ios/tests/NativeListLifecycleTests.swift +298 -24
  28. package/lib/module/validation.js +55 -12
  29. package/lib/module/web/NativeListGeneratedIcons.js +1 -0
  30. package/lib/module/web/NativeListWebEngine.js +213 -23
  31. package/lib/module/web/templates/ActivityRowRenderer.js +1 -1
  32. package/lib/module/web/templates/DataRowRenderer.js +38 -1
  33. package/lib/module/web/templates/IdentityRowRenderer.js +12 -1
  34. package/lib/module/web/templates/MarketRowRenderer.js +2 -0
  35. package/lib/module/web/templates/MediaTileRowRenderer.js +1 -0
  36. package/lib/module/web/templates/RowElements.js +2 -2
  37. package/lib/module/web/templates/RowText.js +2 -0
  38. package/lib/typescript/src/models.d.ts +24 -1
  39. package/lib/typescript/src/web/NativeListWebEngine.d.ts +8 -1
  40. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +6 -2
  41. package/lib/typescript/src/web/templates/RowVisual.d.ts +1 -1
  42. package/package.json +1 -1
  43. package/scripts/generate-icons.test.mjs +1 -0
  44. package/scripts/native-list-icons.json +1 -1
  45. package/src/models.ts +24 -0
  46. package/src/validation.ts +129 -5
  47. package/src/web/NativeListGeneratedIcons.ts +1 -0
  48. package/src/web/NativeListWebEngine.ts +382 -27
  49. package/src/web/templates/ActivityRowRenderer.ts +1 -1
  50. package/src/web/templates/DataRowRenderer.ts +48 -1
  51. package/src/web/templates/IdentityRowRenderer.ts +23 -1
  52. package/src/web/templates/MarketRowRenderer.ts +2 -0
  53. package/src/web/templates/MediaTileRowRenderer.ts +1 -0
  54. package/src/web/templates/RowElements.ts +3 -2
  55. package/src/web/templates/RowText.ts +6 -0
  56. package/src/web/templates/RowVisual.ts +2 -1
@@ -7,6 +7,19 @@ enum NativeListTopScrollEdgeEffect {
7
7
  case none, hard, soft
8
8
  }
9
9
 
10
+ private final class NativeListReorderLongPress: UILongPressGestureRecognizer {
11
+ var sourceItem: NativeListItem?
12
+ var bindingEpoch: Int?
13
+ weak var handle: NativeListAccessoryButton?
14
+
15
+ override func reset() {
16
+ super.reset()
17
+ sourceItem = nil
18
+ bindingEpoch = nil
19
+ handle = nil
20
+ }
21
+ }
22
+
10
23
  final class NativeListView: UIView {
11
24
  private var fonts = NativeListFontFamilies()
12
25
 
@@ -199,8 +212,10 @@ final class NativeListView: UIView {
199
212
  if !tail.retiringKeys.isEmpty {
200
213
  var snapshot = dataSource.snapshot()
201
214
  snapshot.deleteItems(Array(tail.retiringKeys))
202
- dataSource.apply(snapshot, animatingDifferences: false)
203
- itemsByKey = Dictionary(uniqueKeysWithValues: config.items.map { ($0.key, $0) })
215
+ let finishRetiringCells = replaceCellItems(
216
+ with: Dictionary(uniqueKeysWithValues: config.items.map { ($0.key, $0) }),
217
+ outgoingKeys: tail.retiringKeys)
218
+ dataSource.apply(snapshot, animatingDifferences: false, completion: finishRetiringCells)
204
219
  }
205
220
  clearStructuralTail()
206
221
  structuralSpacerHeight = 0
@@ -701,6 +716,9 @@ final class NativeListView: UIView {
701
716
  private var config: NativeListConfig?
702
717
  private var acceptedRowIndex: AcceptedRowIndex?
703
718
  private var itemsByKey: [String: NativeListItem] = [:]
719
+ private static let emptyCellReuseIdentifier = "NativeList.EmptyCell"
720
+ private var retiringCellItems: [String: (item: NativeListItem, update: UInt64)] = [:]
721
+ private var cellUpdate: UInt64 = 0
704
722
  private var endReachedGeneration: Int?
705
723
  private var lastVisibleRange: (first: Int, last: Int, firstKey: String?, lastKey: String?)?
706
724
  private var visibleEventScheduled = false
@@ -717,7 +735,7 @@ final class NativeListView: UIView {
717
735
  private var pagerCommandCancelObserver: NSObjectProtocol?
718
736
  private var pendingScrollRequest: ScrollRequest?
719
737
  private let sectionIndexFeedback = UISelectionFeedbackGenerator()
720
- private lazy var reorderLongPress = UILongPressGestureRecognizer(
738
+ private lazy var reorderLongPress = NativeListReorderLongPress(
721
739
  target: self,
722
740
  action: #selector(reorderLongPressChanged(_:))
723
741
  )
@@ -751,6 +769,8 @@ final class NativeListView: UIView {
751
769
  private let reorderStartFeedback = UIImpactFeedbackGenerator(style: .medium)
752
770
  private let reorderMoveFeedback = UISelectionFeedbackGenerator()
753
771
  private var interactiveReorderFeedbackIndex: Int?
772
+ /// Ancestor pans (for example a sheet's dismiss pan) paused while a reorder is active.
773
+ private var reorderSuspendedAncestorPans: [UIGestureRecognizer] = []
754
774
  private var interactiveMovementKeys: [String]?
755
775
  private var actionAnchor: ActionAnchorRecord?
756
776
  private let actionAnchorInstanceID = UUID().uuidString
@@ -777,6 +797,8 @@ final class NativeListView: UIView {
777
797
  self.collectionView.setContentOffset(self.collectionView.contentOffset, animated: false)
778
798
  }
779
799
  NativeListRendererRegistry.register(in: collectionView)
800
+ collectionView.register(UICollectionViewCell.self,
801
+ forCellWithReuseIdentifier: Self.emptyCellReuseIdentifier)
780
802
  collectionView.backgroundColor = .clear
781
803
  collectionView.delegate = self
782
804
  collectionView.dragDelegate = self
@@ -873,14 +895,30 @@ final class NativeListView: UIView {
873
895
  footerCell.addGestureRecognizer(footerHighlight)
874
896
  dataSource = UICollectionViewDiffableDataSource<Int, String>(collectionView: collectionView) {
875
897
  [weak self] collectionView, indexPath, key in
876
- guard let self,
877
- let item = self.itemsByKey[key],
878
- let cell = collectionView.dequeueReusableCell(
879
- withReuseIdentifier: NativeListRendererRegistry.reuseIdentifier(for: item.rendererKey),
880
- for: indexPath
881
- ) as? NativeListRowHost else { return nil }
898
+ guard let self, let item = self.itemsByKey[key] ?? self.retiringCellItems[key]?.item else {
899
+ let cell = collectionView.dequeueReusableCell(
900
+ withReuseIdentifier: NativeListView.emptyCellReuseIdentifier, for: indexPath)
901
+ cell.isUserInteractionEnabled = false
902
+ cell.accessibilityElementsHidden = true
903
+ return cell
904
+ }
905
+ let reusableCell = collectionView.dequeueReusableCell(
906
+ withReuseIdentifier: NativeListRendererRegistry.reuseIdentifier(for: item.rendererKey),
907
+ for: indexPath)
908
+ guard let cell = reusableCell as? NativeListRowHost else { return reusableCell }
909
+ if self.itemsByKey[key] == nil {
910
+ cell.onAction = nil
911
+ cell.onBindingInvalidated = nil
912
+ cell.isHidden = true
913
+ cell.isUserInteractionEnabled = false
914
+ cell.accessibilityElementsHidden = true
915
+ return cell
916
+ }
882
917
  cell.onAction = { [weak self] item, action, target, origin in
883
- self?.handleAction(item: item, actionKey: action, target: target, origin: origin)
918
+ // A child renderer can emit a different key than the collection row that owns it.
919
+ guard let self, self.itemsByKey[key] != nil,
920
+ !self.isInertPresentationKey(key) else { return }
921
+ self.handleAction(item: item, actionKey: action, target: target, origin: origin)
884
922
  }
885
923
  cell.onBindingInvalidated = { [weak self] cell, epoch in
886
924
  self?.handleBindingInvalidated(cell: cell, epoch: epoch)
@@ -1054,8 +1092,38 @@ final class NativeListView: UIView {
1054
1092
  acceptedRowIndex = AcceptedRowIndex(items: next.items)
1055
1093
  }
1056
1094
 
1095
+ // Layout can ask UIKit's outgoing snapshot for cells before apply starts or while it settles.
1096
+ // Keep those descriptors outside the accepted row lookup and release each at its own commit.
1097
+ private func replaceCellItems(
1098
+ with nextItems: [String: NativeListItem], outgoingKeys: some Sequence<String>
1099
+ ) -> (() -> Void)? {
1100
+ cellUpdate &+= 1
1101
+ let update = cellUpdate
1102
+ var retiringKeys: [String] = []
1103
+ for key in outgoingKeys where nextItems[key] == nil {
1104
+ guard let item = itemsByKey[key] ?? retiringCellItems[key]?.item else { continue }
1105
+ retiringCellItems[key] = (item, update)
1106
+ retiringKeys.append(key)
1107
+ }
1108
+ itemsByKey = nextItems
1109
+ guard !retiringKeys.isEmpty else { return nil }
1110
+ return { [weak self] in
1111
+ guard let self else { return }
1112
+ for key in retiringKeys where self.retiringCellItems[key]?.update == update {
1113
+ self.retiringCellItems.removeValue(forKey: key)
1114
+ }
1115
+ }
1116
+ }
1117
+
1057
1118
  func applySnapshotJson(_ json: String) {
1058
1119
  guard let next = try? NativeListConfig.parse(json: json) else { return }
1120
+ if let current = config,
1121
+ current.reorderable != next.reorderable ||
1122
+ current.reorderFromHandleOnly != next.reorderFromHandleOnly {
1123
+ cancelInteractiveReorderForStructuralUpdate()
1124
+ reorderLongPress.isEnabled = false
1125
+ reorderLongPress.isEnabled = true
1126
+ }
1059
1127
  let transition = next.structuralTransition
1060
1128
  let isNewTransition = transition != nil && transition?.id != consumedStructuralTransitionID
1061
1129
  let disclosureGeometryInvalid = deferredDisclosureGeometryInvalid
@@ -1244,13 +1312,14 @@ final class NativeListView: UIView {
1244
1312
  disclosureInset = next.disclosure?.expanded == true
1245
1313
  ? next.disclosure?.expandedTrailingInset ?? 0 : 0
1246
1314
  }
1247
- itemsByKey = Dictionary(uniqueKeysWithValues: next.items.map { ($0.key, $0) })
1248
- itemsByKey.merge(structuralRemovedItems) { current, _ in current }
1315
+ var nextItemsByKey = Dictionary(uniqueKeysWithValues: next.items.map { ($0.key, $0) })
1316
+ nextItemsByKey.merge(structuralRemovedItems) { current, _ in current }
1249
1317
  if let tail = structuralTail, !tail.retiringKeys.isEmpty {
1250
- itemsByKey.merge(presentationItems.filter { tail.retiringKeys.contains($0.key) }) {
1318
+ nextItemsByKey.merge(presentationItems.filter { tail.retiringKeys.contains($0.key) }) {
1251
1319
  current, _ in current
1252
1320
  }
1253
1321
  }
1322
+ let finishRetiringCells = replaceCellItems(with: nextItemsByKey, outgoingKeys: oldKeys)
1254
1323
  if !animateStructure, let tail = structuralTail {
1255
1324
  if themeChanged || tailGeometryChanged {
1256
1325
  if !newDisclosureCommand { interruptedPendingID = activePendingID }
@@ -1341,7 +1410,8 @@ final class NativeListView: UIView {
1341
1410
  let explicitScrollPendingAtApply = pendingScrollRequest != nil
1342
1411
  dataSource.apply(snapshot, animatingDifferences: animateStructure && structuralRemovedItems.isEmpty
1343
1412
  && structuralTail == nil) { [weak self] in
1344
- guard let self else { return }
1413
+ finishRetiringCells?()
1414
+ guard let self, !self.disposed else { return }
1345
1415
  self.collectionView.layoutIfNeeded()
1346
1416
  self.updateStructuralTailWindow()
1347
1417
  self.layoutContainerSlots()
@@ -1510,11 +1580,14 @@ final class NativeListView: UIView {
1510
1580
  if progress >= 1 {
1511
1581
  if !structuralRemovedItems.isEmpty {
1512
1582
  var snapshot = dataSource.snapshot()
1513
- snapshot.deleteItems(Array(structuralRemovedItems.keys))
1583
+ let outgoingKeys = Array(structuralRemovedItems.keys)
1584
+ snapshot.deleteItems(outgoingKeys)
1514
1585
  structuralRemovedItems.removeAll()
1515
1586
  structuralRemovedHeights.removeAll()
1516
- dataSource.apply(snapshot, animatingDifferences: false)
1517
- itemsByKey = Dictionary(uniqueKeysWithValues: config.items.map { ($0.key, $0) })
1587
+ let finishRetiringCells = replaceCellItems(
1588
+ with: Dictionary(uniqueKeysWithValues: config.items.map { ($0.key, $0) }),
1589
+ outgoingKeys: outgoingKeys)
1590
+ dataSource.apply(snapshot, animatingDifferences: false, completion: finishRetiringCells)
1518
1591
  collectionView.layoutIfNeeded()
1519
1592
  if !structuralScrollInterrupted && !collectionView.isTracking
1520
1593
  && !collectionView.isDragging && !collectionView.isDecelerating {
@@ -1971,11 +2044,12 @@ final class NativeListView: UIView {
1971
2044
  let point = gesture.location(in: collectionView)
1972
2045
  guard let current = config,
1973
2046
  current.reorderable,
1974
- let indexPath = collectionView.indexPathForItem(at: point),
2047
+ let indexPath = reorderSourceIndexPath(at: point),
1975
2048
  let item = item(at: indexPath),
1976
2049
  item.isReorderable,
1977
2050
  let cell = collectionView.cellForItem(at: indexPath) as? NativeListRowHost,
1978
- cell.canStartWalletGroupReorder(at: gesture.location(in: cell)) else {
2051
+ (current.reorderFromHandleOnly ||
2052
+ cell.canStartWalletGroupReorder(at: gesture.location(in: cell))) else {
1979
2053
  interactiveReorderSource = nil
1980
2054
  interactiveReorderCell = nil
1981
2055
  interactiveReorderTargetIndex = nil
@@ -2026,6 +2100,7 @@ final class NativeListView: UIView {
2026
2100
  interactiveMovementKeys = dataSource.snapshot().itemIdentifiers
2027
2101
  }
2028
2102
  interactiveReorderFeedbackIndex = indexPath.item
2103
+ suspendAncestorPansForReorder()
2029
2104
  reorderStartFeedback.impactOccurred(intensity: 0.7)
2030
2105
  reorderStartFeedback.prepare()
2031
2106
  reorderMoveFeedback.prepare()
@@ -2067,6 +2142,42 @@ final class NativeListView: UIView {
2067
2142
  }
2068
2143
  }
2069
2144
 
2145
+ // NativeOverlay implements this optional UIKit coordination hook to retain
2146
+ // ownership of its current dismiss policy. The packages can load independently.
2147
+ private static let setPanReorderSuppressed =
2148
+ NSSelectorFromString("setOneKeyNativeListReorderSuppressed:")
2149
+
2150
+ /// A reorder that has started owns the drag: an enclosing sheet or pager must
2151
+ /// not also pan (and dismiss or page) with the same finger.
2152
+ private func suspendAncestorPansForReorder() {
2153
+ resumeAncestorPansAfterReorder()
2154
+ var view = collectionView.superview
2155
+ while let current = view {
2156
+ for recognizer in current.gestureRecognizers ?? []
2157
+ where recognizer is UIPanGestureRecognizer && recognizer.delegate !== self {
2158
+ if recognizer.responds(to: Self.setPanReorderSuppressed) {
2159
+ _ = recognizer.perform(Self.setPanReorderSuppressed, with: NSNumber(value: true))
2160
+ } else {
2161
+ guard recognizer.isEnabled else { continue }
2162
+ recognizer.isEnabled = false
2163
+ }
2164
+ reorderSuspendedAncestorPans.append(recognizer)
2165
+ }
2166
+ view = current.superview
2167
+ }
2168
+ }
2169
+
2170
+ private func resumeAncestorPansAfterReorder() {
2171
+ for recognizer in reorderSuspendedAncestorPans {
2172
+ if recognizer.responds(to: Self.setPanReorderSuppressed) {
2173
+ _ = recognizer.perform(Self.setPanReorderSuppressed, with: NSNumber(value: false))
2174
+ } else {
2175
+ recognizer.isEnabled = true
2176
+ }
2177
+ }
2178
+ reorderSuspendedAncestorPans.removeAll()
2179
+ }
2180
+
2070
2181
  private func nearestReorderIndexPath(to point: CGPoint) -> IndexPath? {
2071
2182
  let isHorizontal = config?.orientation == "horizontal"
2072
2183
  return collectionView.indexPathsForVisibleItems.min { lhs, rhs in
@@ -2124,6 +2235,7 @@ final class NativeListView: UIView {
2124
2235
  }
2125
2236
 
2126
2237
  private func finishInteractiveReorder(cancelled: Bool) {
2238
+ resumeAncestorPansAfterReorder()
2127
2239
  interactiveReorderLockedCrossAxisPosition = nil
2128
2240
  if interactiveReorderUsesAtomicTargeting {
2129
2241
  finishAtomicInteractiveReorder(cancelled: cancelled)
@@ -2168,6 +2280,7 @@ final class NativeListView: UIView {
2168
2280
 
2169
2281
  private func cancelInteractiveReorderForStructuralUpdate() {
2170
2282
  guard interactiveReorderSource != nil else { return }
2283
+ resumeAncestorPansAfterReorder()
2171
2284
  interactiveReorderAnimator?.stopAnimation(true)
2172
2285
  interactiveReorderAnimator = nil
2173
2286
  interactiveMovementKeys = nil
@@ -2280,7 +2393,9 @@ final class NativeListView: UIView {
2280
2393
  // while the diffable snapshot and cell index paths keep the pre-drag order until
2281
2394
  // the move commits. Resolving sizes from the snapshot swaps row heights.
2282
2395
  private func layoutItem(at indexPath: IndexPath) -> NativeListItem? {
2283
- guard let keys = interactiveMovementKeys else { return item(at: indexPath) }
2396
+ guard let keys = interactiveMovementKeys else {
2397
+ return item(at: indexPath, includeRetiringCell: true)
2398
+ }
2284
2399
  return keys[safe: indexPath.item].flatMap { itemsByKey[$0] }
2285
2400
  }
2286
2401
 
@@ -2293,15 +2408,16 @@ final class NativeListView: UIView {
2293
2408
  interactiveMovementKeys = keys
2294
2409
  }
2295
2410
 
2296
- private func item(at indexPath: IndexPath) -> NativeListItem? {
2297
- if let key = dataSource.itemIdentifier(for: indexPath), let item = itemsByKey[key] {
2298
- return item
2411
+ private func item(at indexPath: IndexPath, includeRetiringCell: Bool = false) -> NativeListItem? {
2412
+ if let key = dataSource.itemIdentifier(for: indexPath) {
2413
+ return itemsByKey[key] ?? (includeRetiringCell ? retiringCellItems[key]?.item : nil)
2299
2414
  }
2300
2415
  return config?.items[safe: indexPath.item]
2301
2416
  }
2302
2417
 
2303
2418
  private func isInertPresentationKey(_ key: String) -> Bool {
2304
2419
  structuralTail?.indexByKey[key] != nil || structuralRemovedItems[key] != nil
2420
+ || (itemsByKey[key] == nil && retiringCellItems[key] != nil)
2305
2421
  }
2306
2422
 
2307
2423
  private func updateAtomicReorderTarget(to targetIndex: Int, key targetKey: String, animated: Bool) {
@@ -2647,7 +2763,7 @@ final class NativeListView: UIView {
2647
2763
  if item.key == interactiveReorderCompactKey {
2648
2764
  cell.setWalletGroupReorderCompact(true)
2649
2765
  }
2650
- let retiring = structuralRemovedItems[item.key] != nil
2766
+ let retiring = cell !== footerCell && structuralRemovedItems[item.key] != nil
2651
2767
  cell.structuralContentHeight = retiring
2652
2768
  ? rowHeight(item, allocatedWidth: cell.bounds.width) : nil
2653
2769
  if retiring { cell.clipsToBounds = true }
@@ -2663,7 +2779,7 @@ final class NativeListView: UIView {
2663
2779
 
2664
2780
  private func handleRowPress(_ item: NativeListItem, origin: NativeListActionOrigin?) {
2665
2781
  // OneKey patch: missing-address rows keep accessory actions available.
2666
- guard let config, item.isRowPressEnabled, !isInertPresentationKey(item.key) else { return }
2782
+ guard let config, item.isRowPressEnabled else { return }
2667
2783
  if config.rowPressToggles && item.isSelectable && config.selectionMode != "none" {
2668
2784
  updateSelection(target: NativeSelectionTarget(scope: "row", key: item.key), sourceKey: item.key)
2669
2785
  return
@@ -2699,7 +2815,7 @@ final class NativeListView: UIView {
2699
2815
  target: NativeSelectionTarget?,
2700
2816
  origin: NativeListActionOrigin?
2701
2817
  ) {
2702
- guard !item.data.bool("disabled"), !isInertPresentationKey(item.key) else { return }
2818
+ guard !item.data.bool("disabled") else { return }
2703
2819
  if let target, config?.selectionMode != "none" {
2704
2820
  updateSelection(target: target, sourceKey: item.key)
2705
2821
  return
@@ -2708,8 +2824,7 @@ final class NativeListView: UIView {
2708
2824
  }
2709
2825
 
2710
2826
  private func updateSelection(target: NativeSelectionTarget, sourceKey: String) {
2711
- guard var current = config, current.selectionMode != "none",
2712
- !isInertPresentationKey(sourceKey) else { return }
2827
+ guard var current = config, current.selectionMode != "none" else { return }
2713
2828
  let keys = selectionKeys(target: target, items: current.items)
2714
2829
  guard !keys.isEmpty else { return }
2715
2830
  let before = current.selectedKeys
@@ -2809,6 +2924,7 @@ final class NativeListView: UIView {
2809
2924
  current.selectionMode == next.selectionMode,
2810
2925
  current.rowPressToggles == next.rowPressToggles,
2811
2926
  current.reorderable == next.reorderable,
2927
+ current.reorderFromHandleOnly == next.reorderFromHandleOnly,
2812
2928
  current.pullToRefresh == next.pullToRefresh,
2813
2929
  current.refreshTriggerDistance == next.refreshTriggerDistance,
2814
2930
  current.refreshing == next.refreshing,
@@ -2821,26 +2937,23 @@ final class NativeListView: UIView {
2821
2937
  current.fixedFooter?.content == next.fixedFooter?.content,
2822
2938
  current.items.count == next.items.count else { return false }
2823
2939
 
2940
+ let controlled = next.selectionMode == "single" || next.selectionMode == "multiple"
2824
2941
  return zip(current.items, next.items).allSatisfy { old, new in
2825
- guard old.key == new.key, old.type == new.type else { return false }
2826
- if old.content == new.content { return true }
2827
- // OneKey patch: controlled echoes can also update row and checkbox selection fields.
2828
- // guard old.type == "sectionHeader",
2829
- // old.data.string("variant") == "summary",
2830
- // new.data.string("variant") == "summary" else { return false }
2831
- // var oldData = old.data
2832
- // var newData = new.data
2833
- // oldData.removeValue(forKey: "title")
2834
- // oldData.removeValue(forKey: "value")
2835
- // newData.removeValue(forKey: "title")
2836
- // newData.removeValue(forKey: "value")
2837
- let controlled = next.selectionMode == "single" || next.selectionMode == "multiple"
2838
- guard let oldData = selectionComparisonData(old.data, controlled: controlled),
2839
- let newData = selectionComparisonData(new.data, controlled: controlled) else { return false }
2840
- return jsonData(oldData) == jsonData(newData)
2942
+ isStableSelectionUpdate(from: old, to: new, controlled: controlled)
2841
2943
  }
2842
2944
  }
2843
2945
 
2946
+ // The lightweight selection rebind leaves the original row and controls mounted.
2947
+ private func isStableSelectionUpdate(
2948
+ from old: NativeListItem, to new: NativeListItem, controlled: Bool
2949
+ ) -> Bool {
2950
+ guard old.key == new.key, old.type == new.type else { return false }
2951
+ if old.content == new.content { return true }
2952
+ guard let oldData = selectionComparisonData(old.data, controlled: controlled),
2953
+ let newData = selectionComparisonData(new.data, controlled: controlled) else { return false }
2954
+ return jsonData(oldData) == jsonData(newData)
2955
+ }
2956
+
2844
2957
  private func canDeferSnapshotDuringInteractiveReorder(
2845
2958
  from current: NativeListConfig,
2846
2959
  to next: NativeListConfig
@@ -2856,6 +2969,7 @@ final class NativeListView: UIView {
2856
2969
  current.contentPaddingBottom == next.contentPaddingBottom,
2857
2970
  current.itemSpacing == next.itemSpacing,
2858
2971
  current.reorderable == next.reorderable,
2972
+ current.reorderFromHandleOnly == next.reorderFromHandleOnly,
2859
2973
  current.sectionIndexEnabled == next.sectionIndexEnabled,
2860
2974
  current.items.count == next.items.count,
2861
2975
  hasSameFooterGeometry(current.fixedFooter, next.fixedFooter) else { return false }
@@ -3108,6 +3222,7 @@ final class NativeListView: UIView {
3108
3222
  keyboardDragRecognizer.delegate = nil
3109
3223
  listBodyGestureGuard.delegate = nil
3110
3224
  reorderLongPress.delegate = nil
3225
+ resumeAncestorPansAfterReorder()
3111
3226
  marketLongPress.delegate = nil
3112
3227
 
3113
3228
  for case let cell as NativeListRowHost in collectionView.visibleCells {
@@ -3133,6 +3248,7 @@ final class NativeListView: UIView {
3133
3248
  structuralSpacerHeight = 0
3134
3249
  structuralFooterStartY = nil
3135
3250
  itemsByKey.removeAll()
3251
+ retiringCellItems.removeAll()
3136
3252
  sectionIndexEntries.removeAll()
3137
3253
  if let pagerCommandCancelObserver {
3138
3254
  NotificationCenter.default.removeObserver(pagerCommandCancelObserver)
@@ -3294,13 +3410,33 @@ final class NativeListView: UIView {
3294
3410
  }.sorted()
3295
3411
  }
3296
3412
 
3413
+ private func reorderSourceIndexPath(at point: CGPoint) -> IndexPath? {
3414
+ guard config?.reorderFromHandleOnly == true else {
3415
+ return collectionView.indexPathForItem(at: point)
3416
+ }
3417
+ let controlled = config?.selectionMode == "single" || config?.selectionMode == "multiple"
3418
+ guard let original = reorderLongPress.sourceItem,
3419
+ let handle = reorderLongPress.handle, handle.isReorderHandle,
3420
+ let indexPath = dataSource.indexPath(for: original.key),
3421
+ let cell = collectionView.cellForItem(at: indexPath) as? NativeListRowHost,
3422
+ cell.bindingEpoch == reorderLongPress.bindingEpoch,
3423
+ handle.isDescendant(of: cell),
3424
+ let current = item(at: indexPath),
3425
+ isStableSelectionUpdate(from: original, to: current, controlled: controlled)
3426
+ else { return nil }
3427
+ return indexPath
3428
+ }
3429
+
3297
3430
  override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
3298
3431
  if gestureRecognizer === keyboardDragRecognizer {
3299
3432
  return keyboardDismissMode == .onDrag && focusedTextInput(in: window) != nil
3300
3433
  }
3301
3434
  if gestureRecognizer === reorderLongPress || gestureRecognizer === marketLongPress {
3302
3435
  let point = gestureRecognizer.location(in: collectionView)
3303
- guard let indexPath = collectionView.indexPathForItem(at: point),
3436
+ let sourceIndexPath = gestureRecognizer === reorderLongPress
3437
+ ? reorderSourceIndexPath(at: point)
3438
+ : collectionView.indexPathForItem(at: point)
3439
+ guard let indexPath = sourceIndexPath,
3304
3440
  let item = item(at: indexPath), !isInertPresentationKey(item.key),
3305
3441
  !item.data.bool("disabled") else { return false }
3306
3442
  if gestureRecognizer === reorderLongPress {
@@ -3333,6 +3469,28 @@ extension NativeListView: UIGestureRecognizerDelegate {
3333
3469
  }
3334
3470
  }
3335
3471
  if gestureRecognizer === listBodyGestureGuard { return true }
3472
+ if gestureRecognizer === reorderLongPress, config?.reorderFromHandleOnly == true {
3473
+ guard reorderLongPress.sourceItem == nil else { return false }
3474
+ var view = touch.view
3475
+ var handle: NativeListAccessoryButton?
3476
+ while let current = view, current !== footerCell, current !== collectionView {
3477
+ if let button = current as? NativeListAccessoryButton, button.isReorderHandle {
3478
+ handle = button
3479
+ }
3480
+ if let cell = current as? NativeListRowHost, let handle,
3481
+ let indexPath = collectionView.indexPath(for: cell),
3482
+ let item = item(at: indexPath), item.isReorderable,
3483
+ !isInertPresentationKey(item.key),
3484
+ cell.canStartWalletGroupReorder(at: touch.location(in: cell)) {
3485
+ reorderLongPress.sourceItem = item
3486
+ reorderLongPress.bindingEpoch = cell.bindingEpoch
3487
+ reorderLongPress.handle = handle
3488
+ return true
3489
+ }
3490
+ view = current.superview
3491
+ }
3492
+ return false
3493
+ }
3336
3494
  var view = touch.view
3337
3495
  while let current = view, current !== footerCell {
3338
3496
  if current is UIControl { return false }