@onekeyfe/react-native-native-list 3.0.154 → 3.0.157-alpha.248
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/HybridNativeList.swift +39 -25
- package/ios/RNCNativeListView.swift +60 -0
- package/package.json +4 -4
|
@@ -2,16 +2,17 @@ import Foundation
|
|
|
2
2
|
import UIKit
|
|
3
3
|
|
|
4
4
|
final class HybridNativeList: HybridNativeListSpec {
|
|
5
|
-
private
|
|
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
|
|
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
|
|
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
|
|
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
|
|
49
|
+
self.hostView?.onVisibleRangeChanged = self.onVisibleRangeChanged
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
override init() {
|
|
54
55
|
super.init()
|
|
55
|
-
hostView
|
|
56
|
-
hostView
|
|
57
|
-
hostView
|
|
58
|
-
hostView
|
|
59
|
-
hostView
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
131
|
+
runOnMain { [weak self] in self?.hostView?.setRefreshing(refreshing) }
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
func onDropView() {
|
|
134
|
-
runOnMain { [weak self] in self?.
|
|
135
|
+
runOnMain { [weak self] in self?.disposeHostView() }
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
func dispose() {
|
|
138
|
-
runOnMain { [weak self] in self?.
|
|
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.
|
|
145
|
+
hostView.dispose()
|
|
144
146
|
} else {
|
|
145
|
-
|
|
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.
|
|
3
|
+
"version": "3.0.157-alpha.248",
|
|
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",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"typecheck": "tsc -b",
|
|
40
40
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
41
41
|
"test": "jest --runInBand",
|
|
42
|
-
"release": "yarn prepare && npm whoami && npm publish --access public"
|
|
42
|
+
"release": "yarn nitrogen && yarn prepare && npm whoami && npm publish --access public"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
45
45
|
"react-native",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"typescript": "^5.9.2"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@onekeyfe/react-native-image": "3.0.
|
|
87
|
-
"@onekeyfe/react-native-native-logger": "3.0.
|
|
86
|
+
"@onekeyfe/react-native-image": "3.0.157-alpha.248",
|
|
87
|
+
"@onekeyfe/react-native-native-logger": "3.0.157-alpha.248",
|
|
88
88
|
"react": "*",
|
|
89
89
|
"react-native": "*",
|
|
90
90
|
"react-native-nitro-modules": "0.37.0"
|