@onekeyfe/react-native-native-list 3.0.153 → 3.0.156

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.
@@ -3417,6 +3417,7 @@ internal class NativeListRowView(
3417
3417
  val fallbackIcon = if (index == 0) fallbackIconData else null
3418
3418
  val expectedEpoch = bindingEpoch
3419
3419
  bindImage(source, image, boundKey ?: "", index, variant,
3420
+ round = shape == "circle",
3420
3421
  onLoad = if (!ownsSourceFallback) null else ({
3421
3422
  if (bindingEpoch == expectedEpoch) {
3422
3423
  sourceFallbackKey?.let(NativeListSourceFallbackState::forget)
@@ -4226,6 +4227,7 @@ internal class NativeListRowView(
4226
4227
  token: String,
4227
4228
  slot: Int,
4228
4229
  variant: String,
4230
+ round: Boolean = false,
4229
4231
  onLoad: (() -> Unit)? = null,
4230
4232
  onError: (() -> Unit)? = null,
4231
4233
  hideUntilLoaded: Boolean = false,
@@ -4263,6 +4265,7 @@ internal class NativeListRowView(
4263
4265
  autoplay = source.optBoolean("autoplay", false),
4264
4266
  recyclingKey = recyclingKey,
4265
4267
  optimizeTos = retryAttempt == 0 && source.optBoolean("optimizeTos", true),
4268
+ round = round,
4266
4269
  overscan = source.optDouble("overscan", 1.1),
4267
4270
  loadingStrategy = source.optString("loadingStrategy", "none"),
4268
4271
  placeholderColor = imagePlaceholderColor,
@@ -4279,7 +4282,18 @@ internal class NativeListRowView(
4279
4282
  val retry = Runnable {
4280
4283
  if (bindingEpoch == expectedEpoch) {
4281
4284
  selectorImageRetries.remove(imageView)
4282
- bindImage(source, imageView, token, slot, variant, onLoad, onError, hideUntilLoaded, retryAttempt + 1)
4285
+ bindImage(
4286
+ source = source,
4287
+ imageView = imageView,
4288
+ token = token,
4289
+ slot = slot,
4290
+ variant = variant,
4291
+ round = round,
4292
+ onLoad = onLoad,
4293
+ onError = onError,
4294
+ hideUntilLoaded = hideUntilLoaded,
4295
+ retryAttempt = retryAttempt + 1,
4296
+ )
4283
4297
  }
4284
4298
  }
4285
4299
  selectorImageRetries[imageView] = retry
@@ -2,16 +2,17 @@ import Foundation
2
2
  import UIKit
3
3
 
4
4
  final class HybridNativeList: HybridNativeListSpec {
5
- private let hostView = NativeListView(frame: .zero)
5
+ private var hostView: NativeListView? = NativeListView(frame: .zero)
6
+ private let disposedView = UIView(frame: .zero)
6
7
 
7
- var view: UIView { hostView }
8
+ var view: UIView { hostView ?? disposedView }
8
9
 
9
10
  var snapshotJson: String = "" {
10
11
  didSet {
11
12
  guard snapshotJson != oldValue else { return }
12
13
  runOnMain { [weak self] in
13
14
  guard let self else { return }
14
- self.hostView.applySnapshotJson(self.snapshotJson)
15
+ self.hostView?.applySnapshotJson(self.snapshotJson)
15
16
  }
16
17
  }
17
18
  }
@@ -21,7 +22,7 @@ final class HybridNativeList: HybridNativeListSpec {
21
22
  guard keyboardDismissMode != oldValue else { return }
22
23
  runOnMain { [weak self] in
23
24
  guard let self else { return }
24
- self.hostView.setKeyboardDismissMode(self.keyboardDismissMode)
25
+ self.hostView?.setKeyboardDismissMode(self.keyboardDismissMode)
25
26
  }
26
27
  }
27
28
  }
@@ -31,7 +32,7 @@ final class HybridNativeList: HybridNativeListSpec {
31
32
  guard keyboardShouldPersistTaps != oldValue else { return }
32
33
  runOnMain { [weak self] in
33
34
  guard let self else { return }
34
- self.hostView.setKeyboardShouldPersistTaps(self.keyboardShouldPersistTaps)
35
+ self.hostView?.setKeyboardShouldPersistTaps(self.keyboardShouldPersistTaps)
35
36
  }
36
37
  }
37
38
  }
@@ -45,30 +46,30 @@ final class HybridNativeList: HybridNativeListSpec {
45
46
  didSet {
46
47
  runOnMain { [weak self] in
47
48
  guard let self else { return }
48
- self.hostView.onVisibleRangeChanged = self.onVisibleRangeChanged
49
+ self.hostView?.onVisibleRangeChanged = self.onVisibleRangeChanged
49
50
  }
50
51
  }
51
52
  }
52
53
 
53
54
  override init() {
54
55
  super.init()
55
- hostView.onRowAction = { [weak self] in self?.onRowAction?($0) }
56
- hostView.onActionAnchorInvalidated = { [weak self] in self?.onActionAnchorInvalidated?($0) }
57
- hostView.onSelectionDelta = { [weak self] in self?.onSelectionDelta?($0) }
58
- hostView.onReorder = { [weak self] in self?.onReorder?($0) }
59
- hostView.onEndReached = { [weak self] in self?.onEndReached?($0) }
56
+ hostView?.onRowAction = { [weak self] in self?.onRowAction?($0) }
57
+ hostView?.onActionAnchorInvalidated = { [weak self] in self?.onActionAnchorInvalidated?($0) }
58
+ hostView?.onSelectionDelta = { [weak self] in self?.onSelectionDelta?($0) }
59
+ hostView?.onReorder = { [weak self] in self?.onReorder?($0) }
60
+ hostView?.onEndReached = { [weak self] in self?.onEndReached?($0) }
60
61
  }
61
62
 
62
63
  func applySnapshot(snapshotJson: String) throws {
63
- runOnMain { [weak self] in self?.hostView.applySnapshotJson(snapshotJson) }
64
+ runOnMain { [weak self] in self?.hostView?.applySnapshotJson(snapshotJson) }
64
65
  }
65
66
 
66
67
  func applyPatches(patchesJson: String) throws {
67
- runOnMain { [weak self] in self?.hostView.applyPatchesJson(patchesJson) }
68
+ runOnMain { [weak self] in self?.hostView?.applyPatchesJson(patchesJson) }
68
69
  }
69
70
 
70
71
  func reconcileSelection(selectedKeysJson: String) throws {
71
- runOnMain { [weak self] in self?.hostView.reconcileSelectionJson(selectedKeysJson) }
72
+ runOnMain { [weak self] in self?.hostView?.reconcileSelectionJson(selectedKeysJson) }
72
73
  }
73
74
 
74
75
  func scrollToKey(
@@ -79,7 +80,7 @@ final class HybridNativeList: HybridNativeListSpec {
79
80
  viewOffset: Double
80
81
  ) throws {
81
82
  runOnMain { [weak self] in
82
- self?.hostView.scrollToKey(
83
+ self?.hostView?.scrollToKey(
83
84
  key,
84
85
  animated: animated,
85
86
  alignment: alignment.stringValue,
@@ -101,7 +102,7 @@ final class HybridNativeList: HybridNativeListSpec {
101
102
  index.rounded(.towardZero) == index,
102
103
  index <= Double(Int.max) else { return }
103
104
  runOnMain { [weak self] in
104
- self?.hostView.scrollToIndex(
105
+ self?.hostView?.scrollToIndex(
105
106
  Int(index),
106
107
  animated: animated,
107
108
  alignment: alignment.stringValue,
@@ -114,39 +115,52 @@ final class HybridNativeList: HybridNativeListSpec {
114
115
  func scrollToOffset(offset: Double, animated: Bool) throws {
115
116
  guard offset.isFinite, offset >= 0 else { return }
116
117
  runOnMain { [weak self] in
117
- self?.hostView.scrollToOffset(offset, animated: animated)
118
+ self?.hostView?.scrollToOffset(offset, animated: animated)
118
119
  }
119
120
  }
120
121
 
121
122
  func scrollToEnd(animated: Bool) throws {
122
- runOnMain { [weak self] in self?.hostView.scrollToEnd(animated: animated) }
123
+ runOnMain { [weak self] in self?.hostView?.scrollToEnd(animated: animated) }
123
124
  }
124
125
 
125
126
  func setActionAnchorState(stateJson: String) throws {
126
- runOnMain { [weak self] in self?.hostView.setActionAnchorStateJson(stateJson) }
127
+ runOnMain { [weak self] in self?.hostView?.setActionAnchorStateJson(stateJson) }
127
128
  }
128
129
 
129
130
  func setRefreshing(refreshing: Bool) throws {
130
- runOnMain { [weak self] in self?.hostView.setRefreshing(refreshing) }
131
+ runOnMain { [weak self] in self?.hostView?.setRefreshing(refreshing) }
131
132
  }
132
133
 
133
134
  func onDropView() {
134
- runOnMain { [weak self] in self?.hostView.disposeActionAnchor() }
135
+ runOnMain { [weak self] in self?.disposeHostView() }
135
136
  }
136
137
 
137
138
  func dispose() {
138
- runOnMain { [weak self] in self?.hostView.disposeActionAnchor() }
139
+ runOnMain { [weak self] in self?.disposeHostView() }
139
140
  }
140
141
 
141
142
  deinit {
143
+ guard let hostView else { return }
142
144
  if Thread.isMainThread {
143
- hostView.disposeActionAnchor()
145
+ hostView.dispose()
144
146
  } else {
145
- let view = hostView
146
- DispatchQueue.main.async { view.disposeActionAnchor() }
147
+ DispatchQueue.main.async { hostView.dispose() }
147
148
  }
148
149
  }
149
150
 
151
+ private func disposeHostView() {
152
+ guard let hostView else { return }
153
+ onRowAction = nil
154
+ onActionAnchorInvalidated = nil
155
+ onSelectionDelta = nil
156
+ onReorder = nil
157
+ onEndReached = nil
158
+ onVisibleRangeChanged = nil
159
+ hostView.dispose()
160
+ self.hostView = nil
161
+ snapshotJson = ""
162
+ }
163
+
150
164
  private func runOnMain(_ work: @escaping () -> Void) {
151
165
  if Thread.isMainThread {
152
166
  work()
@@ -119,6 +119,7 @@ final class NativeListView: UIView {
119
119
  private var actionAnchor: ActionAnchorRecord?
120
120
  private let actionAnchorInstanceID = UUID().uuidString
121
121
  private var actionAnchorCounter = 0
122
+ private var disposed = false
122
123
 
123
124
  private static let sectionIndexContentInset: CGFloat = 16
124
125
  private static let sectionIndexRailWidth: CGFloat = 32
@@ -1858,6 +1859,65 @@ final class NativeListView: UIView {
1858
1859
  actionAnchor = nil
1859
1860
  }
1860
1861
 
1862
+ func dispose() {
1863
+ guard !disposed else { return }
1864
+ disposed = true
1865
+
1866
+ disposeActionAnchor()
1867
+ interactiveReorderAnimator?.stopAnimation(true)
1868
+ interactiveReorderAnimator = nil
1869
+ if interactiveReorderSource != nil {
1870
+ collectionView.cancelInteractiveMovement()
1871
+ }
1872
+ resetAtomicReorderTransforms()
1873
+ interactiveReorderSource = nil
1874
+ interactiveReorderCell = nil
1875
+ interactiveMovementKeys = nil
1876
+ deferredReorderReconfigureKeys.removeAll()
1877
+
1878
+ finishSectionIndexInteraction(immediately: true)
1879
+ sectionIndexView.onSelect = nil
1880
+ sectionIndexView.onInteractionEnded = nil
1881
+ NSLayoutConstraint.deactivate(sectionIndexLayoutConstraints)
1882
+ sectionIndexLayoutConstraints.removeAll()
1883
+ sectionIndexHostHeightConstraint = nil
1884
+ sectionIndexView.removeFromSuperview()
1885
+
1886
+ collectionView.refreshControl?.removeTarget(nil, action: nil, for: .allEvents)
1887
+ collectionView.refreshControl = nil
1888
+ collectionView.delegate = nil
1889
+ collectionView.dragDelegate = nil
1890
+ collectionView.dropDelegate = nil
1891
+ keyboardTapRecognizer.delegate = nil
1892
+ keyboardDragRecognizer.delegate = nil
1893
+ listBodyGestureGuard.delegate = nil
1894
+ reorderLongPress.delegate = nil
1895
+ marketLongPress.delegate = nil
1896
+
1897
+ for case let cell as NativeListCell in collectionView.visibleCells {
1898
+ cell.onAction = nil
1899
+ cell.onBindingInvalidated = nil
1900
+ cell.prepareForReuse()
1901
+ }
1902
+ footerCell.onAction = nil
1903
+ footerCell.onBindingInvalidated = nil
1904
+ footerCell.prepareForReuse()
1905
+ collectionView.dataSource = nil
1906
+ dataSource = nil
1907
+
1908
+ config = nil
1909
+ itemsByKey.removeAll()
1910
+ sectionIndexEntries.removeAll()
1911
+ pendingScrollRequest = nil
1912
+ lastVisibleRange = nil
1913
+ onRowAction = nil
1914
+ onActionAnchorInvalidated = nil
1915
+ onSelectionDelta = nil
1916
+ onReorder = nil
1917
+ onEndReached = nil
1918
+ onVisibleRangeChanged = nil
1919
+ }
1920
+
1861
1921
  private func createActionAnchor(origin: NativeListActionOrigin) -> [String: Any]? {
1862
1922
  guard let sourceView = origin.sourceView,
1863
1923
  let ownerCell = origin.ownerCell,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-native-list",
3
- "version": "3.0.153",
3
+ "version": "3.0.156",
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",
@@ -83,8 +83,8 @@
83
83
  "typescript": "^5.9.2"
84
84
  },
85
85
  "peerDependencies": {
86
- "@onekeyfe/react-native-image": "3.0.153",
87
- "@onekeyfe/react-native-native-logger": "3.0.153",
86
+ "@onekeyfe/react-native-image": "3.0.156",
87
+ "@onekeyfe/react-native-native-logger": "3.0.156",
88
88
  "react": "*",
89
89
  "react-native": "*",
90
90
  "react-native-nitro-modules": "0.37.0"