@onekeyfe/react-native-native-list 6.7.0-alpha.343 → 6.7.0-alpha.354
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/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +7 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +240 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +7 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +6 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +87 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +135 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +43 -14
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +17 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +22 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +585 -21
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +1 -0
- package/docs/ROW_TEMPLATES.md +60 -9
- package/docs/SPEC.md +361 -8
- package/docs/STYLE_SPEC.md +6 -0
- package/ios/HybridNativeList.swift +10 -0
- package/ios/NativeListAccessoryStack.swift +220 -37
- package/ios/NativeListActivityDetailsView.swift +18 -8
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +105 -8
- package/ios/NativeListDesignAssets.swift +3 -0
- package/ios/NativeListIdentityRenderer.swift +119 -4
- package/ios/NativeListLeadingVisual.swift +49 -14
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListModels.swift +16 -2
- package/ios/NativeListRendererRegistry.swift +1 -0
- package/ios/NativeListResolvedText.swift +2 -1
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +88 -0
- package/ios/RNCNativeListView.swift +331 -29
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +56 -0
- package/ios/tests/NativeListLifecycleTests.swift +890 -3
- package/lib/module/NativeList.js +64 -27
- package/lib/module/NativeList.web.js +84 -17
- package/lib/module/models.js +1 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +532 -18
- package/lib/module/web/NativeListWebEngine.js +391 -24
- package/lib/module/web/templates/ActivityRowRenderer.js +8 -7
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +40 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +90 -4
- package/lib/module/web/templates/MessageRowRenderer.js +18 -2
- package/lib/module/web/templates/RowContainerStyle.js +1 -0
- package/lib/module/web/templates/RowRendererRegistry.js +3 -0
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +9 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +5 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +6 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +7 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +6 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +11 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +2 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +3 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +1 -0
- package/lib/typescript/src/NativeList.d.ts +2 -2
- package/lib/typescript/src/NativeList.nitro.d.ts +1 -0
- package/lib/typescript/src/NativeList.types.d.ts +8 -0
- package/lib/typescript/src/models.d.ts +101 -9
- package/lib/typescript/src/validation.d.ts +13 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +26 -0
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +9 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +5 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +6 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +7 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +6 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +11 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +2 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +3 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +1 -0
- package/package.json +3 -3
- package/react-native-native-list.podspec +1 -0
- package/src/NativeList.nitro.ts +1 -0
- package/src/NativeList.tsx +155 -69
- package/src/NativeList.types.ts +9 -0
- package/src/NativeList.web.tsx +159 -49
- package/src/models.ts +113 -3
- package/src/selection.ts +1 -0
- package/src/validation.ts +1156 -18
- package/src/web/NativeListWebEngine.ts +594 -28
- package/src/web/templates/ActivityRowRenderer.ts +14 -6
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +150 -5
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +11 -1
- package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
|
@@ -30,11 +30,13 @@ final class NativeListView: UIView {
|
|
|
30
30
|
}
|
|
31
31
|
private var refreshEmittedForDrag = false
|
|
32
32
|
private var minimumDragOffset: CGFloat = 0
|
|
33
|
-
private var containerSlotHeights: [CGFloat] = [0, 0, 0]
|
|
33
|
+
private var containerSlotHeights: [CGFloat] = [0, 0, 0, 0]
|
|
34
34
|
// Fabric keeps assigning each slot root the frame React computed (inset, 0, width, height).
|
|
35
35
|
// Each root therefore lives in a list-owned host whose origin the list alone controls, so a
|
|
36
36
|
// React layout update can never move a slot out of its native position, even for a frame.
|
|
37
37
|
private var reactContainerSlots: [(content: UIView, host: UIView)] = []
|
|
38
|
+
private var sidecarLayout: (width: CGFloat, gap: CGFloat, maxContentWidth: CGFloat)?
|
|
39
|
+
private let pagerStickyHeights = NSMapTable<AnyObject, NSNumber>(keyOptions: .weakMemory, valueOptions: .strongMemory)
|
|
38
40
|
private let topOverlayHost = UIView()
|
|
39
41
|
private weak var topOverlayContent: UIView?
|
|
40
42
|
private var topEdgeInteraction: UIInteraction?
|
|
@@ -47,9 +49,23 @@ final class NativeListView: UIView {
|
|
|
47
49
|
private var lastLaidOutContentHeight: CGFloat?
|
|
48
50
|
private var needsContentShrinkCorrection = false
|
|
49
51
|
private var contentShrinkCorrectionScheduled = false
|
|
52
|
+
private var consumedStructuralTransitionID: String?
|
|
53
|
+
private var structuralDisplayLink: CADisplayLink?
|
|
54
|
+
private var structuralSpacerHeight: CGFloat = 0
|
|
55
|
+
private var structuralAnimationStart: CFTimeInterval = 0
|
|
56
|
+
private var structuralAnimationDuration: CFTimeInterval = 0
|
|
57
|
+
private var structuralStartSpacer: CGFloat = 0
|
|
58
|
+
private var structuralStartOffset: CGFloat = 0
|
|
59
|
+
private var structuralTargetOffset: CGFloat = 0
|
|
60
|
+
private var structuralScrollInterrupted = false
|
|
61
|
+
private var structuralFooterStartY: CGFloat?
|
|
62
|
+
private var structuralFooterProgress: CGFloat = 0
|
|
63
|
+
private var structuralRemovedItems: [String: NativeListItem] = [:]
|
|
64
|
+
private var structuralRemovedHeights: [String: CGFloat] = [:]
|
|
65
|
+
private var structuralRemovalProgress: CGFloat = 0
|
|
50
66
|
|
|
51
67
|
@objc func mountContainerSlot(_ view: UIView, atIndex index: Int) {
|
|
52
|
-
if index ==
|
|
68
|
+
if index == 4 {
|
|
53
69
|
topOverlayContent?.removeFromSuperview()
|
|
54
70
|
topOverlayContent = view
|
|
55
71
|
topOverlayHost.addSubview(view)
|
|
@@ -145,13 +161,59 @@ final class NativeListView: UIView {
|
|
|
145
161
|
func setContainerSlotHeightsJson(_ json: String) {
|
|
146
162
|
guard let data = json.data(using: .utf8),
|
|
147
163
|
let heights = try? JSONSerialization.jsonObject(with: data) as? [Double],
|
|
148
|
-
heights.count ==
|
|
164
|
+
heights.count == 4, heights.allSatisfy({ $0.isFinite && $0 >= 0 }) else { return }
|
|
165
|
+
let footerDelta = containerSlotHeights[2] - CGFloat(heights[2])
|
|
149
166
|
containerSlotHeights = heights.map { CGFloat($0) }
|
|
167
|
+
if structuralDisplayLink != nil, footerDelta != 0 {
|
|
168
|
+
let progress = min(1, max(0,
|
|
169
|
+
(CACurrentMediaTime() - structuralAnimationStart) / max(0.001, structuralAnimationDuration)))
|
|
170
|
+
let eased = progress * progress * (3 - 2 * progress)
|
|
171
|
+
structuralStartSpacer = max(0, structuralStartSpacer + footerDelta)
|
|
172
|
+
structuralSpacerHeight = structuralStartSpacer * (1 - eased)
|
|
173
|
+
if let startY = structuralFooterStartY { structuralFooterStartY = startY + footerDelta }
|
|
174
|
+
}
|
|
175
|
+
if let config { configureLayout(config) }
|
|
176
|
+
if structuralDisplayLink != nil {
|
|
177
|
+
collectionView.layoutIfNeeded()
|
|
178
|
+
let inset = collectionView.adjustedContentInset
|
|
179
|
+
let finalMaximum = max(-inset.top,
|
|
180
|
+
collectionView.contentSize.height - structuralSpacerHeight
|
|
181
|
+
- collectionView.bounds.height + inset.bottom)
|
|
182
|
+
structuralTargetOffset = min(structuralTargetOffset, finalMaximum)
|
|
183
|
+
}
|
|
184
|
+
layoutContainerSlots()
|
|
185
|
+
setNeedsLayout()
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
func setSidecarLayoutJson(_ json: String) {
|
|
189
|
+
if json.isEmpty {
|
|
190
|
+
sidecarLayout = nil
|
|
191
|
+
} else if let data = json.data(using: .utf8),
|
|
192
|
+
let value = try? JSONSerialization.jsonObject(with: data) as? [String: Double],
|
|
193
|
+
let width = value["width"], let gap = value["gap"],
|
|
194
|
+
let maxWidth = value["maxContentWidth"],
|
|
195
|
+
width.isFinite, width > 0, gap.isFinite, gap >= 0,
|
|
196
|
+
maxWidth.isFinite, maxWidth > width + gap {
|
|
197
|
+
sidecarLayout = (CGFloat(width), CGFloat(gap), CGFloat(maxWidth))
|
|
198
|
+
} else { return }
|
|
150
199
|
if let config { configureLayout(config) }
|
|
151
200
|
layoutContainerSlots()
|
|
152
201
|
setNeedsLayout()
|
|
153
202
|
}
|
|
154
203
|
|
|
204
|
+
private func sidecarBaseInset(_ width: CGFloat) -> CGFloat {
|
|
205
|
+
guard let sidecarLayout else { return 0 }
|
|
206
|
+
return max(0, (width - min(width, sidecarLayout.maxContentWidth)) / 2)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@objc(setPagerStickyHeight:forOwner:)
|
|
210
|
+
func setPagerStickyHeight(_ height: CGFloat, forOwner owner: AnyObject) {
|
|
211
|
+
let next = height.isFinite ? max(0, height) : 0
|
|
212
|
+
if next == 0 { pagerStickyHeights.removeObject(forKey: owner) }
|
|
213
|
+
else { pagerStickyHeights.setObject(NSNumber(value: Double(next)), forKey: owner) }
|
|
214
|
+
layoutContainerSlots()
|
|
215
|
+
}
|
|
216
|
+
|
|
155
217
|
private func layoutContainerSlots() {
|
|
156
218
|
let empty = config?.items.isEmpty ?? true
|
|
157
219
|
let header = containerSlotHeights[0]
|
|
@@ -160,14 +222,43 @@ final class NativeListView: UIView {
|
|
|
160
222
|
let paddingTop = config?.contentPaddingTop ?? 0
|
|
161
223
|
let paddingBottom = config?.contentPaddingBottom ?? 0
|
|
162
224
|
let footerY = max(paddingTop + header + emptyHeight,
|
|
163
|
-
|
|
164
|
-
let
|
|
225
|
+
flowLayout.bodyContentHeight - paddingBottom - footer)
|
|
226
|
+
let footerPosition = structuralRemovedItems.isEmpty ? structuralFooterStartY.map {
|
|
227
|
+
$0 + (footerY - $0) * structuralFooterProgress
|
|
228
|
+
} ?? footerY : footerY
|
|
229
|
+
let positions = [paddingTop, paddingTop + header, footerPosition]
|
|
165
230
|
for (index, slot) in reactContainerSlots.prefix(3).enumerated() {
|
|
166
231
|
slot.host.isHidden = index == 1 && !empty
|
|
167
232
|
// React places the root at the horizontal inset inside this full-width host.
|
|
168
233
|
slot.host.frame = CGRect(x: 0, y: positions[index],
|
|
169
234
|
width: collectionView.bounds.width, height: containerSlotHeights[index])
|
|
170
235
|
}
|
|
236
|
+
if reactContainerSlots.count > 3 {
|
|
237
|
+
let slot = reactContainerSlots[3]
|
|
238
|
+
let width = sidecarLayout?.width ?? 0
|
|
239
|
+
let base = sidecarBaseInset(collectionView.bounds.width)
|
|
240
|
+
slot.host.isHidden = sidecarLayout == nil || containerSlotHeights[3] <= 0
|
|
241
|
+
let x = effectiveUserInterfaceLayoutDirection == .rightToLeft
|
|
242
|
+
? base : collectionView.bounds.width - base - width
|
|
243
|
+
slot.host.frame = CGRect(x: x,
|
|
244
|
+
y: paddingTop, width: width, height: containerSlotHeights[3])
|
|
245
|
+
}
|
|
246
|
+
var stickyHeight: CGFloat = 0
|
|
247
|
+
for case let value as NSNumber in pagerStickyHeights.objectEnumerator()?.allObjects ?? [] {
|
|
248
|
+
stickyHeight += CGFloat(value.doubleValue)
|
|
249
|
+
}
|
|
250
|
+
CATransaction.begin()
|
|
251
|
+
CATransaction.setDisableActions(true)
|
|
252
|
+
for slot in reactContainerSlots {
|
|
253
|
+
guard stickyHeight > 0 else { slot.host.layer.mask = nil; continue }
|
|
254
|
+
let mask = slot.host.layer.mask ?? CALayer()
|
|
255
|
+
mask.backgroundColor = UIColor.black.cgColor
|
|
256
|
+
let top = max(0, collectionView.contentOffset.y + stickyHeight - slot.host.frame.minY)
|
|
257
|
+
mask.frame = CGRect(x: 0, y: top, width: slot.host.bounds.width,
|
|
258
|
+
height: max(0, slot.host.bounds.height - top))
|
|
259
|
+
slot.host.layer.mask = mask
|
|
260
|
+
}
|
|
261
|
+
CATransaction.commit()
|
|
171
262
|
}
|
|
172
263
|
|
|
173
264
|
private final class ActionAnchorRecord {
|
|
@@ -539,14 +630,14 @@ final class NativeListView: UIView {
|
|
|
539
630
|
height: requestedTopOverlayHeight)
|
|
540
631
|
updateSectionIndexAttachment()
|
|
541
632
|
let direction = effectiveUserInterfaceLayoutDirection
|
|
542
|
-
|
|
543
|
-
|
|
633
|
+
let sizeChanged = lastLayoutSize != nil && lastLayoutSize != bounds.size
|
|
634
|
+
if sizeChanged || lastLayoutDirection != nil && lastLayoutDirection != direction {
|
|
544
635
|
invalidateActionAnchor(reason: "layout")
|
|
545
636
|
}
|
|
546
637
|
lastLayoutSize = bounds.size
|
|
547
|
-
if lastLayoutDirection != direction, let config {
|
|
638
|
+
if (lastLayoutDirection != direction || sizeChanged && sidecarLayout != nil), let config {
|
|
548
639
|
configureLayout(config)
|
|
549
|
-
rebindRowsForLayoutDirection(config)
|
|
640
|
+
if lastLayoutDirection != direction { rebindRowsForLayoutDirection(config) }
|
|
550
641
|
}
|
|
551
642
|
performPendingScrollIfNeeded()
|
|
552
643
|
layoutContainerSlots()
|
|
@@ -581,8 +672,83 @@ final class NativeListView: UIView {
|
|
|
581
672
|
|
|
582
673
|
func applySnapshotJson(_ json: String) {
|
|
583
674
|
guard let next = try? NativeListConfig.parse(json: json) else { return }
|
|
675
|
+
let oldKeys = dataSource.snapshot().itemIdentifiers
|
|
676
|
+
let logicalOldKeys = config?.items.map(\.key) ?? []
|
|
677
|
+
let presentationItems = itemsByKey
|
|
678
|
+
let newKeys = next.items.map(\.key)
|
|
679
|
+
let transition = next.structuralTransition
|
|
680
|
+
let isNewTransition = transition != nil && transition?.id != consumedStructuralTransitionID
|
|
681
|
+
if let transition { consumedStructuralTransitionID = transition.id }
|
|
682
|
+
let animateStructure = config != nil && isNewTransition && logicalOldKeys != newKeys
|
|
683
|
+
&& next.orientation == "vertical" && (next.layout == "linear" || next.layout == "table")
|
|
684
|
+
&& !UIAccessibility.isReduceMotionEnabled
|
|
685
|
+
&& (transition?.duration ?? 0) > 0
|
|
686
|
+
let presentationHeights: [String: CGFloat] = animateStructure ? Dictionary(uniqueKeysWithValues: oldKeys.compactMap { key -> (String, CGFloat)? in
|
|
687
|
+
guard let item = presentationItems[key] else { return nil }
|
|
688
|
+
let height = structuralRemovedHeights[key].map { $0 * (1 - structuralRemovalProgress) }
|
|
689
|
+
?? rowHeight(item)
|
|
690
|
+
return (key, height)
|
|
691
|
+
}) : [:]
|
|
692
|
+
let previousOffset = collectionView.contentOffset.y
|
|
693
|
+
let oldLeftContentHeight = animateStructure ? flowLayout.bodyContentHeight : 0
|
|
694
|
+
let oldSpacerHeight = structuralSpacerHeight
|
|
695
|
+
let oldRowsHeight = animateStructure
|
|
696
|
+
? presentationHeights.values.reduce(CGFloat(0), +)
|
|
697
|
+
+ CGFloat(max(0, oldKeys.count - 1)) * (config?.itemSpacing ?? 0)
|
|
698
|
+
: 0
|
|
699
|
+
let newRowsHeight = animateStructure
|
|
700
|
+
? next.items.reduce(CGFloat(0)) { $0 + rowHeight($1) }
|
|
701
|
+
+ CGFloat(max(0, newKeys.count - 1)) * next.itemSpacing
|
|
702
|
+
: 0
|
|
703
|
+
let survivingKeys = animateStructure ? Set(newKeys) : Set<String>()
|
|
704
|
+
let visibleAnchor = animateStructure
|
|
705
|
+
? collectionView.indexPathsForVisibleItems.sorted().first {
|
|
706
|
+
oldKeys.indices.contains($0.item) && survivingKeys.contains(oldKeys[$0.item])
|
|
707
|
+
}
|
|
708
|
+
: nil
|
|
709
|
+
let anchorKey = visibleAnchor.map { oldKeys[$0.item] }
|
|
710
|
+
let oldPrefix = (animateStructure ? anchorKey : nil).flatMap { key -> CGFloat? in
|
|
711
|
+
guard let index = oldKeys.firstIndex(of: key) else { return nil }
|
|
712
|
+
return oldKeys.prefix(index).reduce(CGFloat(0)) { $0 + (presentationHeights[$1] ?? 0) }
|
|
713
|
+
+ CGFloat(index) * (config?.itemSpacing ?? 0)
|
|
714
|
+
} ?? 0
|
|
715
|
+
let newPrefix = (animateStructure ? anchorKey : nil).flatMap { key -> CGFloat? in
|
|
716
|
+
guard let index = newKeys.firstIndex(of: key) else { return nil }
|
|
717
|
+
return next.items.prefix(index).reduce(CGFloat(0)) { $0 + rowHeight($1) }
|
|
718
|
+
+ CGFloat(index) * next.itemSpacing
|
|
719
|
+
} ?? 0
|
|
720
|
+
if animateStructure {
|
|
721
|
+
stopStructuralAnimation()
|
|
722
|
+
structuralScrollInterrupted = false
|
|
723
|
+
structuralFooterStartY = reactContainerSlots.count > 2
|
|
724
|
+
? reactContainerSlots[2].host.frame.minY : nil
|
|
725
|
+
structuralFooterProgress = 0
|
|
726
|
+
// Keep deletion-only snapshots in their presentation order until their heights
|
|
727
|
+
// reach zero. Replacing these rows with a spacer produces a blank viewport.
|
|
728
|
+
let removedKeys = Set(oldKeys).subtracting(newKeys)
|
|
729
|
+
let retainsOrder = oldKeys.filter { survivingKeys.contains($0) } == newKeys
|
|
730
|
+
structuralRemovedItems = retainsOrder
|
|
731
|
+
? presentationItems.filter { removedKeys.contains($0.key) } : [:]
|
|
732
|
+
structuralRemovedHeights = retainsOrder
|
|
733
|
+
? presentationHeights.filter { removedKeys.contains($0.key) } : [:]
|
|
734
|
+
structuralRemovalProgress = 0
|
|
735
|
+
structuralSpacerHeight = structuralRemovedItems.isEmpty
|
|
736
|
+
? max(0, structuralSpacerHeight + oldRowsHeight - newRowsHeight) : 0
|
|
737
|
+
NotificationCenter.default.post(name: Notification.Name("OneKeyNativeListScrollCommandAccepted"),
|
|
738
|
+
object: collectionView, userInfo: ["phase": 0])
|
|
739
|
+
NotificationCenter.default.post(name: Notification.Name("OneKeyNativeListScrollCommandAccepted"),
|
|
740
|
+
object: collectionView, userInfo: ["phase": 1])
|
|
741
|
+
needsContentShrinkCorrection = false
|
|
742
|
+
} else if logicalOldKeys != newKeys {
|
|
743
|
+
stopStructuralAnimation()
|
|
744
|
+
structuralSpacerHeight = 0
|
|
745
|
+
structuralFooterStartY = nil
|
|
746
|
+
structuralRemovedItems.removeAll()
|
|
747
|
+
structuralRemovedHeights.removeAll()
|
|
748
|
+
}
|
|
584
749
|
invalidateActionAnchor(reason: "snapshot")
|
|
585
|
-
if let current = config,
|
|
750
|
+
if let current = config, structuralRemovedItems.isEmpty,
|
|
751
|
+
isControlledSelectionSnapshotUpdate(from: current, to: next) {
|
|
586
752
|
config = next
|
|
587
753
|
itemsByKey = Dictionary(uniqueKeysWithValues: next.items.map { ($0.key, $0) })
|
|
588
754
|
// OneKey patch: A controlled selection echo is fully handled by the
|
|
@@ -602,17 +768,41 @@ final class NativeListView: UIView {
|
|
|
602
768
|
// rows whose own content is unchanged.
|
|
603
769
|
let themeChanged = !dictionariesEqual(config?.theme, next.theme)
|
|
604
770
|
|| !dictionariesEqual(config?.listStyle, next.listStyle)
|
|
771
|
+
|| config?.layout != next.layout
|
|
605
772
|
if config?.generation != next.generation { endReachedGeneration = nil }
|
|
606
773
|
config = next
|
|
607
774
|
itemsByKey = Dictionary(uniqueKeysWithValues: next.items.map { ($0.key, $0) })
|
|
775
|
+
itemsByKey.merge(structuralRemovedItems) { current, _ in current }
|
|
608
776
|
configureSectionIndex(next)
|
|
609
777
|
configureLayout(next)
|
|
610
778
|
configureRefresh(next)
|
|
611
779
|
configureFooter(next)
|
|
612
780
|
|
|
781
|
+
if animateStructure, let transition {
|
|
782
|
+
let inset = collectionView.adjustedContentInset
|
|
783
|
+
let finalLeftHeight = max(0,
|
|
784
|
+
oldLeftContentHeight + newRowsHeight - oldRowsHeight - oldSpacerHeight)
|
|
785
|
+
let sidecarHeight = sidecarLayout == nil ? 0 :
|
|
786
|
+
next.contentPaddingTop + containerSlotHeights[3] + next.contentPaddingBottom
|
|
787
|
+
let finalHeight = max(finalLeftHeight, sidecarHeight)
|
|
788
|
+
let finalMaximum = max(-inset.top, finalHeight - collectionView.bounds.height + inset.bottom)
|
|
789
|
+
structuralStartSpacer = structuralSpacerHeight
|
|
790
|
+
structuralStartOffset = previousOffset
|
|
791
|
+
var targetOffset = min(max(-inset.top, previousOffset + newPrefix - oldPrefix), finalMaximum)
|
|
792
|
+
if visibleAnchor == nil, let fallbackKey = transition.anchorKey,
|
|
793
|
+
let fallbackIndex = newKeys.firstIndex(of: fallbackKey) {
|
|
794
|
+
let fallbackY = next.contentPaddingTop + containerSlotHeights[0]
|
|
795
|
+
+ next.items.prefix(fallbackIndex).reduce(CGFloat(0)) { $0 + rowHeight($1) }
|
|
796
|
+
+ CGFloat(fallbackIndex) * next.itemSpacing
|
|
797
|
+
targetOffset = min(targetOffset, max(-inset.top, fallbackY - inset.top))
|
|
798
|
+
}
|
|
799
|
+
structuralTargetOffset = targetOffset
|
|
800
|
+
structuralAnimationDuration = transition.duration
|
|
801
|
+
}
|
|
802
|
+
|
|
613
803
|
var snapshot = NSDiffableDataSourceSnapshot<Int, String>()
|
|
614
804
|
snapshot.appendSections([0])
|
|
615
|
-
let keys =
|
|
805
|
+
let keys = structuralRemovedItems.isEmpty ? newKeys : oldKeys
|
|
616
806
|
snapshot.appendItems(keys, toSection: 0)
|
|
617
807
|
var changedKeys = Set(keys.filter { key in
|
|
618
808
|
guard let old = oldItems[key], let new = itemsByKey[key] else { return false }
|
|
@@ -627,7 +817,7 @@ final class NativeListView: UIView {
|
|
|
627
817
|
let replacedKeys = changedRetainedKeys.filter { oldItems[$0]?.rendererKey != itemsByKey[$0]?.rendererKey }
|
|
628
818
|
snapshot.reloadItems(Array(replacedKeys))
|
|
629
819
|
snapshot.reconfigureItems(Array(changedRetainedKeys.subtracting(replacedKeys)))
|
|
630
|
-
dataSource.apply(snapshot, animatingDifferences:
|
|
820
|
+
dataSource.apply(snapshot, animatingDifferences: animateStructure && structuralRemovedItems.isEmpty) { [weak self] in
|
|
631
821
|
guard let self else { return }
|
|
632
822
|
self.collectionView.layoutIfNeeded()
|
|
633
823
|
self.performPendingScrollIfNeeded()
|
|
@@ -635,6 +825,88 @@ final class NativeListView: UIView {
|
|
|
635
825
|
self.checkEndReached()
|
|
636
826
|
self.syncSectionIndexToVisibleRows()
|
|
637
827
|
}
|
|
828
|
+
if animateStructure {
|
|
829
|
+
structuralAnimationStart = CACurrentMediaTime()
|
|
830
|
+
let displayLink = CADisplayLink(target: self, selector: #selector(advanceStructuralAnimation))
|
|
831
|
+
structuralDisplayLink = displayLink
|
|
832
|
+
displayLink.add(to: .main, forMode: .common)
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
private func stopStructuralAnimation() {
|
|
837
|
+
if structuralDisplayLink != nil {
|
|
838
|
+
NotificationCenter.default.post(name: Notification.Name("OneKeyNativeListScrollCommandAccepted"),
|
|
839
|
+
object: collectionView, userInfo: ["phase": 2])
|
|
840
|
+
}
|
|
841
|
+
structuralDisplayLink?.invalidate()
|
|
842
|
+
structuralDisplayLink = nil
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
@objc private func advanceStructuralAnimation() {
|
|
846
|
+
guard let config else { stopStructuralAnimation(); return }
|
|
847
|
+
let elapsed = CACurrentMediaTime() - structuralAnimationStart
|
|
848
|
+
let progress = min(1, max(0, elapsed / max(0.001, structuralAnimationDuration)))
|
|
849
|
+
let eased = progress * progress * (3 - 2 * progress)
|
|
850
|
+
structuralSpacerHeight = structuralStartSpacer * (1 - eased)
|
|
851
|
+
structuralFooterProgress = CGFloat(eased)
|
|
852
|
+
structuralRemovalProgress = CGFloat(eased)
|
|
853
|
+
for case let cell as NativeListRowHost in collectionView.visibleCells {
|
|
854
|
+
guard let indexPath = collectionView.indexPath(for: cell),
|
|
855
|
+
let key = dataSource.itemIdentifier(for: indexPath) else { continue }
|
|
856
|
+
cell.structuralContentHeight = structuralRemovedItems[key].map {
|
|
857
|
+
rowHeight($0, allocatedWidth: cell.bounds.width)
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
var inset = flowLayout.sectionInset
|
|
861
|
+
inset.bottom = config.contentPaddingBottom + containerSlotHeights[2] + structuralSpacerHeight
|
|
862
|
+
flowLayout.sectionInset = inset
|
|
863
|
+
flowLayout.invalidateLayout()
|
|
864
|
+
collectionView.layoutIfNeeded()
|
|
865
|
+
if !structuralScrollInterrupted && !collectionView.isTracking
|
|
866
|
+
&& !collectionView.isDragging && !collectionView.isDecelerating {
|
|
867
|
+
collectionView.contentOffset.y = structuralStartOffset
|
|
868
|
+
+ (structuralTargetOffset - structuralStartOffset) * eased
|
|
869
|
+
// Materialize the new viewport before updating presentation cells.
|
|
870
|
+
collectionView.layoutIfNeeded()
|
|
871
|
+
}
|
|
872
|
+
for cell in collectionView.visibleCells {
|
|
873
|
+
guard let indexPath = collectionView.indexPath(for: cell),
|
|
874
|
+
let key = dataSource.itemIdentifier(for: indexPath) else { continue }
|
|
875
|
+
let retiring = structuralRemovedItems[key] != nil
|
|
876
|
+
if retiring { cell.clipsToBounds = true }
|
|
877
|
+
cell.alpha = retiring ? 1 - structuralRemovalProgress : 1
|
|
878
|
+
cell.isUserInteractionEnabled = !retiring && !(itemsByKey[key]?.data.bool("disabled") ?? false)
|
|
879
|
+
}
|
|
880
|
+
layoutContainerSlots()
|
|
881
|
+
if progress >= 1 {
|
|
882
|
+
if !structuralRemovedItems.isEmpty {
|
|
883
|
+
var snapshot = dataSource.snapshot()
|
|
884
|
+
snapshot.deleteItems(Array(structuralRemovedItems.keys))
|
|
885
|
+
structuralRemovedItems.removeAll()
|
|
886
|
+
structuralRemovedHeights.removeAll()
|
|
887
|
+
dataSource.apply(snapshot, animatingDifferences: false)
|
|
888
|
+
itemsByKey = Dictionary(uniqueKeysWithValues: config.items.map { ($0.key, $0) })
|
|
889
|
+
collectionView.layoutIfNeeded()
|
|
890
|
+
if !structuralScrollInterrupted && !collectionView.isTracking
|
|
891
|
+
&& !collectionView.isDragging && !collectionView.isDecelerating {
|
|
892
|
+
let inset = collectionView.adjustedContentInset
|
|
893
|
+
let maximum = max(-inset.top,
|
|
894
|
+
collectionView.contentSize.height - collectionView.bounds.height + inset.bottom)
|
|
895
|
+
let target = min(max(-inset.top, structuralTargetOffset), maximum)
|
|
896
|
+
// Cancel UIKit's residual content-shrink scroll animation after deleting retired rows.
|
|
897
|
+
collectionView.setContentOffset(
|
|
898
|
+
CGPoint(x: collectionView.contentOffset.x, y: target), animated: false)
|
|
899
|
+
collectionView.layoutIfNeeded()
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
stopStructuralAnimation()
|
|
903
|
+
structuralSpacerHeight = 0
|
|
904
|
+
structuralFooterStartY = nil
|
|
905
|
+
layoutContainerSlots()
|
|
906
|
+
emitVisibleRangeIfNeeded()
|
|
907
|
+
checkEndReached()
|
|
908
|
+
scheduleContentShrinkCorrection()
|
|
909
|
+
}
|
|
638
910
|
}
|
|
639
911
|
|
|
640
912
|
func applyPatchesJson(_ json: String) {
|
|
@@ -696,6 +968,7 @@ final class NativeListView: UIView {
|
|
|
696
968
|
}
|
|
697
969
|
config = current
|
|
698
970
|
itemsByKey = Dictionary(uniqueKeysWithValues: current.items.map { ($0.key, $0) })
|
|
971
|
+
itemsByKey.merge(structuralRemovedItems) { current, _ in current }
|
|
699
972
|
for indexPath in collectionView.indexPathsForVisibleItems {
|
|
700
973
|
guard let item = item(at: indexPath),
|
|
701
974
|
marketQuoteKeys.contains(item.key),
|
|
@@ -959,6 +1232,7 @@ final class NativeListView: UIView {
|
|
|
959
1232
|
guard let self else { return }
|
|
960
1233
|
self.contentShrinkCorrectionScheduled = false
|
|
961
1234
|
guard !self.disposed, self.needsContentShrinkCorrection,
|
|
1235
|
+
self.structuralDisplayLink == nil,
|
|
962
1236
|
!self.collectionView.isTracking, !self.collectionView.isDragging,
|
|
963
1237
|
!self.collectionView.isDecelerating,
|
|
964
1238
|
self.collectionView.refreshControl?.isRefreshing != true,
|
|
@@ -994,15 +1268,21 @@ final class NativeListView: UIView {
|
|
|
994
1268
|
flowLayout.scrollDirection = isHorizontal ? .horizontal : .vertical
|
|
995
1269
|
flowLayout.minimumLineSpacing = config.itemSpacing
|
|
996
1270
|
flowLayout.minimumInteritemSpacing = config.itemSpacing
|
|
1271
|
+
let sidecarInset = sidecarBaseInset(collectionView.bounds.width)
|
|
1272
|
+
let sidecarSpace = sidecarLayout.map { $0.width + $0.gap } ?? 0
|
|
1273
|
+
let horizontalInset = config.contentPaddingHorizontal + sidecarInset
|
|
997
1274
|
flowLayout.sectionInset = UIEdgeInsets(
|
|
998
1275
|
top: config.contentPaddingTop + containerSlotHeights[0],
|
|
999
|
-
left:
|
|
1000
|
-
bottom: config.contentPaddingBottom + containerSlotHeights[2],
|
|
1001
|
-
right:
|
|
1276
|
+
left: horizontalInset + (isRightToLeft ? sidecarSpace + indexGutter : 0),
|
|
1277
|
+
bottom: config.contentPaddingBottom + containerSlotHeights[2] + structuralSpacerHeight,
|
|
1278
|
+
right: horizontalInset + (isRightToLeft ? 0 : sidecarSpace + indexGutter)
|
|
1002
1279
|
)
|
|
1003
|
-
|
|
1004
|
-
? config.contentPaddingTop + config.contentPaddingBottom + containerSlotHeights.reduce(0, +)
|
|
1280
|
+
let emptyMinimum = config.items.isEmpty
|
|
1281
|
+
? config.contentPaddingTop + config.contentPaddingBottom + containerSlotHeights.prefix(3).reduce(0, +)
|
|
1005
1282
|
: 0
|
|
1283
|
+
let sidecarMinimum = sidecarLayout == nil ? 0 :
|
|
1284
|
+
config.contentPaddingTop + containerSlotHeights[3] + config.contentPaddingBottom
|
|
1285
|
+
flowLayout.minimumContainerContentHeight = max(emptyMinimum, sidecarMinimum)
|
|
1006
1286
|
flowLayout.stickyItemIndexes = config.stickyHeaders
|
|
1007
1287
|
? Set(config.items.enumerated().compactMap {
|
|
1008
1288
|
$0.element.type == "sectionHeader" && $0.element.data.bool("sticky", default: true) && $0.element.data.string("variant") != "summary"
|
|
@@ -1696,6 +1976,12 @@ final class NativeListView: UIView {
|
|
|
1696
1976
|
if item.key == interactiveReorderCompactKey {
|
|
1697
1977
|
cell.setWalletGroupReorderCompact(true)
|
|
1698
1978
|
}
|
|
1979
|
+
let retiring = structuralRemovedItems[item.key] != nil
|
|
1980
|
+
cell.structuralContentHeight = retiring
|
|
1981
|
+
? rowHeight(item, allocatedWidth: cell.bounds.width) : nil
|
|
1982
|
+
if retiring { cell.clipsToBounds = true }
|
|
1983
|
+
cell.alpha = retiring ? 1 - structuralRemovalProgress : 1
|
|
1984
|
+
cell.isUserInteractionEnabled = !retiring && !item.data.bool("disabled")
|
|
1699
1985
|
}
|
|
1700
1986
|
|
|
1701
1987
|
private func handleRowPress(_ item: NativeListItem, origin: NativeListActionOrigin?) {
|
|
@@ -1720,8 +2006,8 @@ final class NativeListView: UIView {
|
|
|
1720
2006
|
guard gesture.state == .began else { return }
|
|
1721
2007
|
let point = gesture.location(in: collectionView)
|
|
1722
2008
|
guard let indexPath = collectionView.indexPathForItem(at: point),
|
|
1723
|
-
let item =
|
|
1724
|
-
item.type == "market",
|
|
2009
|
+
let item = item(at: indexPath), structuralRemovedItems[item.key] == nil,
|
|
2010
|
+
(item.type == "market" || item.type == "identity"),
|
|
1725
2011
|
item.isRowPressEnabled else { return }
|
|
1726
2012
|
let actionKey = item.data.string("longPressActionKey")
|
|
1727
2013
|
guard !actionKey.isEmpty else { return }
|
|
@@ -2157,6 +2443,11 @@ final class NativeListView: UIView {
|
|
|
2157
2443
|
dataSource = nil
|
|
2158
2444
|
|
|
2159
2445
|
config = nil
|
|
2446
|
+
pagerStickyHeights.removeAllObjects()
|
|
2447
|
+
for slot in reactContainerSlots { slot.host.layer.mask = nil }
|
|
2448
|
+
stopStructuralAnimation()
|
|
2449
|
+
structuralSpacerHeight = 0
|
|
2450
|
+
structuralFooterStartY = nil
|
|
2160
2451
|
itemsByKey.removeAll()
|
|
2161
2452
|
sectionIndexEntries.removeAll()
|
|
2162
2453
|
if let pagerCommandCancelObserver {
|
|
@@ -2272,7 +2563,8 @@ final class NativeListView: UIView {
|
|
|
2272
2563
|
DispatchQueue.main.async { [weak self] in
|
|
2273
2564
|
guard let self else { return }
|
|
2274
2565
|
self.visibleEventScheduled = false
|
|
2275
|
-
guard
|
|
2566
|
+
guard self.structuralRemovedItems.isEmpty,
|
|
2567
|
+
let onVisibleRangeChanged = self.onVisibleRangeChanged else { return }
|
|
2276
2568
|
let indexes = self.collectionView.indexPathsForVisibleItems.map(\.item).sorted()
|
|
2277
2569
|
let first = indexes.first ?? -1
|
|
2278
2570
|
let last = indexes.last ?? -1
|
|
@@ -2291,7 +2583,7 @@ final class NativeListView: UIView {
|
|
|
2291
2583
|
}
|
|
2292
2584
|
|
|
2293
2585
|
private func checkEndReached() {
|
|
2294
|
-
guard let config,
|
|
2586
|
+
guard let config, structuralRemovedItems.isEmpty,
|
|
2295
2587
|
config.loadMore,
|
|
2296
2588
|
endReachedGeneration != config.generation,
|
|
2297
2589
|
!config.items.isEmpty else { return }
|
|
@@ -2316,7 +2608,8 @@ final class NativeListView: UIView {
|
|
|
2316
2608
|
if gestureRecognizer === reorderLongPress {
|
|
2317
2609
|
return config?.reorderable == true && item.isReorderable
|
|
2318
2610
|
}
|
|
2319
|
-
return item.type == "market"
|
|
2611
|
+
return (item.type == "market" || item.type == "identity")
|
|
2612
|
+
&& item.isRowPressEnabled && !item.data.string("longPressActionKey").isEmpty
|
|
2320
2613
|
}
|
|
2321
2614
|
guard gestureRecognizer === listBodyGestureGuard,
|
|
2322
2615
|
let pan = gestureRecognizer as? UIPanGestureRecognizer else { return true }
|
|
@@ -2427,14 +2720,16 @@ extension NativeListView: UICollectionViewDelegateFlowLayout {
|
|
|
2427
2720
|
return CGSize(width: width, height: height)
|
|
2428
2721
|
}
|
|
2429
2722
|
let available = max(0, collectionView.bounds.width - insets.left - insets.right)
|
|
2430
|
-
let structural = item.type == "sectionHeader" || item.type == "system" || item.type == "action"
|
|
2723
|
+
let structural = item.type == "sectionHeader" || item.type == "system" || item.type == "action" || item.type == "buttonGroup"
|
|
2431
2724
|
if config.layout == "grid", !structural {
|
|
2432
2725
|
let spacing = CGFloat(config.gridColumns - 1) * config.itemSpacing
|
|
2433
2726
|
let width = floor((available - spacing) / CGFloat(config.gridColumns))
|
|
2434
2727
|
let height = item.styledHeight ?? (item.type == "mediaTile" && item.data["height"] == nil ? width + 48 : rowHeight(item, allocatedWidth: width))
|
|
2435
2728
|
return CGSize(width: width, height: height)
|
|
2436
2729
|
}
|
|
2437
|
-
|
|
2730
|
+
let height = structuralRemovedHeights[item.key].map { $0 * (1 - structuralRemovalProgress) }
|
|
2731
|
+
?? rowHeight(item, allocatedWidth: available)
|
|
2732
|
+
return CGSize(width: available, height: max(0.01, height))
|
|
2438
2733
|
}
|
|
2439
2734
|
|
|
2440
2735
|
private func railWidth(_ item: NativeListItem) -> CGFloat {
|
|
@@ -2442,19 +2737,20 @@ extension NativeListView: UICollectionViewDelegateFlowLayout {
|
|
|
2442
2737
|
}
|
|
2443
2738
|
|
|
2444
2739
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
2445
|
-
guard let item =
|
|
2740
|
+
guard let item = item(at: indexPath), structuralRemovedItems[item.key] == nil else { return }
|
|
2446
2741
|
if item.type == "walletGroup" { return }
|
|
2447
2742
|
let origin = (collectionView.cellForItem(at: indexPath) as? NativeListRowHost)?.rowActionOrigin()
|
|
2448
2743
|
handleRowPress(item, origin: origin)
|
|
2449
2744
|
}
|
|
2450
2745
|
|
|
2451
2746
|
func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool {
|
|
2452
|
-
guard let item =
|
|
2747
|
+
guard let item = item(at: indexPath), structuralRemovedItems[item.key] == nil else { return false }
|
|
2453
2748
|
return item.isRowPressEnabled
|
|
2454
2749
|
}
|
|
2455
2750
|
|
|
2456
2751
|
func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath) {
|
|
2457
|
-
guard let item =
|
|
2752
|
+
guard let item = item(at: indexPath), structuralRemovedItems[item.key] == nil,
|
|
2753
|
+
item.type == "market" else { return }
|
|
2458
2754
|
let actionKey = item.data.string("pressInActionKey")
|
|
2459
2755
|
guard !actionKey.isEmpty else { return }
|
|
2460
2756
|
let origin = (collectionView.cellForItem(at: indexPath) as? NativeListRowHost)?.rowActionOrigin()
|
|
@@ -2462,7 +2758,7 @@ extension NativeListView: UICollectionViewDelegateFlowLayout {
|
|
|
2462
2758
|
}
|
|
2463
2759
|
|
|
2464
2760
|
func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
|
|
2465
|
-
guard let item =
|
|
2761
|
+
guard let item = item(at: indexPath), structuralRemovedItems[item.key] == nil else { return false }
|
|
2466
2762
|
return item.isRowPressEnabled
|
|
2467
2763
|
}
|
|
2468
2764
|
|
|
@@ -2474,6 +2770,11 @@ extension NativeListView: UICollectionViewDelegateFlowLayout {
|
|
|
2474
2770
|
}
|
|
2475
2771
|
|
|
2476
2772
|
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
|
2773
|
+
if structuralDisplayLink != nil {
|
|
2774
|
+
structuralScrollInterrupted = true
|
|
2775
|
+
NotificationCenter.default.post(name: Notification.Name("OneKeyNativeListScrollCommandAccepted"),
|
|
2776
|
+
object: collectionView, userInfo: ["phase": 2])
|
|
2777
|
+
}
|
|
2477
2778
|
scrollViewDidEndScrollingAnimation(scrollView)
|
|
2478
2779
|
minimumDragOffset = 0
|
|
2479
2780
|
refreshEmittedForDrag = false
|
|
@@ -2512,7 +2813,7 @@ extension NativeListView: UICollectionViewDragDelegate, UICollectionViewDropDele
|
|
|
2512
2813
|
itemsForBeginning session: UIDragSession,
|
|
2513
2814
|
at indexPath: IndexPath
|
|
2514
2815
|
) -> [UIDragItem] {
|
|
2515
|
-
guard config?.reorderable == true,
|
|
2816
|
+
guard config?.reorderable == true, structuralDisplayLink == nil,
|
|
2516
2817
|
let item = config?.items[safe: indexPath.item],
|
|
2517
2818
|
item.isReorderable else { return [] }
|
|
2518
2819
|
let dragItem = UIDragItem(itemProvider: NSItemProvider(object: item.key as NSString))
|
|
@@ -2587,6 +2888,7 @@ private final class NativeListCollectionView: UICollectionView {
|
|
|
2587
2888
|
final class NativeListFlowLayout: UICollectionViewFlowLayout {
|
|
2588
2889
|
var stickyItemIndexes: Set<Int> = []
|
|
2589
2890
|
var minimumContainerContentHeight: CGFloat = 0
|
|
2891
|
+
var bodyContentHeight: CGFloat { super.collectionViewContentSize.height }
|
|
2590
2892
|
private var horizontalAttributes: [IndexPath: UICollectionViewLayoutAttributes] = [:]
|
|
2591
2893
|
private var horizontalContentSize: CGSize = .zero
|
|
2592
2894
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
|
2
|
+
<path d="M11 16.387a4.5 4.5 0 0 1 0-8.775V6h2v1.613a4.5 4.5 0 0 1 2.856 2.067l-1.712 1.032a2.5 2.5 0 1 0 0 2.576l1.712 1.032A4.5 4.5 0 0 1 13 16.386V18h-2z"/>
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10m-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
|
2
|
+
<path d="M5 12a7 7 0 0 0 7 7 7.15 7.15 0 0 0 4.955-2h-2.943v-2h6v6h-2v-2.257A9.148 9.148 0 0 1 12 21a9 9 0 0 1-9-9v-1h2v1Zm1-6.754A9.148 9.148 0 0 1 12 3a9 9 0 0 1 9 9v1h-2v-1a7 7 0 0 0-7-7 7.15 7.15 0 0 0-4.955 2H10v2H4V3h2v2.246Z"/>
|
|
3
|
+
</svg>
|