@onekeyfe/react-native-native-list 6.7.0-alpha.344 → 6.7.0-alpha.359
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 +128 -16
- package/ios/NativeListDesignAssets.swift +3 -0
- package/ios/NativeListIdentityRenderer.swift +123 -5
- 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 +335 -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 +1283 -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 {
|
|
@@ -273,6 +364,7 @@ final class NativeListView: UIView {
|
|
|
273
364
|
private var sectionIndexHapticsEnabled = true
|
|
274
365
|
private var lastLayoutDirection: UIUserInterfaceLayoutDirection?
|
|
275
366
|
private var lastLayoutSize: CGSize?
|
|
367
|
+
private var lastConfiguredCollectionWidth: CGFloat?
|
|
276
368
|
private var commandAcceptedForPendingScroll = false
|
|
277
369
|
private var performingExplicitScrollCommand = false
|
|
278
370
|
private var animatedExplicitScrollCommand = false
|
|
@@ -539,14 +631,16 @@ final class NativeListView: UIView {
|
|
|
539
631
|
height: requestedTopOverlayHeight)
|
|
540
632
|
updateSectionIndexAttachment()
|
|
541
633
|
let direction = effectiveUserInterfaceLayoutDirection
|
|
542
|
-
|
|
543
|
-
|
|
634
|
+
let sizeChanged = lastLayoutSize != nil && lastLayoutSize != bounds.size
|
|
635
|
+
if sizeChanged || lastLayoutDirection != nil && lastLayoutDirection != direction {
|
|
544
636
|
invalidateActionAnchor(reason: "layout")
|
|
545
637
|
}
|
|
546
638
|
lastLayoutSize = bounds.size
|
|
547
|
-
|
|
639
|
+
let collectionWidthChanged = collectionView.bounds.width > 0
|
|
640
|
+
&& lastConfiguredCollectionWidth != collectionView.bounds.width
|
|
641
|
+
if (lastLayoutDirection != direction || collectionWidthChanged), let config {
|
|
548
642
|
configureLayout(config)
|
|
549
|
-
rebindRowsForLayoutDirection(config)
|
|
643
|
+
if lastLayoutDirection != direction { rebindRowsForLayoutDirection(config) }
|
|
550
644
|
}
|
|
551
645
|
performPendingScrollIfNeeded()
|
|
552
646
|
layoutContainerSlots()
|
|
@@ -581,8 +675,83 @@ final class NativeListView: UIView {
|
|
|
581
675
|
|
|
582
676
|
func applySnapshotJson(_ json: String) {
|
|
583
677
|
guard let next = try? NativeListConfig.parse(json: json) else { return }
|
|
678
|
+
let oldKeys = dataSource.snapshot().itemIdentifiers
|
|
679
|
+
let logicalOldKeys = config?.items.map(\.key) ?? []
|
|
680
|
+
let presentationItems = itemsByKey
|
|
681
|
+
let newKeys = next.items.map(\.key)
|
|
682
|
+
let transition = next.structuralTransition
|
|
683
|
+
let isNewTransition = transition != nil && transition?.id != consumedStructuralTransitionID
|
|
684
|
+
if let transition { consumedStructuralTransitionID = transition.id }
|
|
685
|
+
let animateStructure = config != nil && isNewTransition && logicalOldKeys != newKeys
|
|
686
|
+
&& next.orientation == "vertical" && (next.layout == "linear" || next.layout == "table")
|
|
687
|
+
&& !UIAccessibility.isReduceMotionEnabled
|
|
688
|
+
&& (transition?.duration ?? 0) > 0
|
|
689
|
+
let presentationHeights: [String: CGFloat] = animateStructure ? Dictionary(uniqueKeysWithValues: oldKeys.compactMap { key -> (String, CGFloat)? in
|
|
690
|
+
guard let item = presentationItems[key] else { return nil }
|
|
691
|
+
let height = structuralRemovedHeights[key].map { $0 * (1 - structuralRemovalProgress) }
|
|
692
|
+
?? rowHeight(item)
|
|
693
|
+
return (key, height)
|
|
694
|
+
}) : [:]
|
|
695
|
+
let previousOffset = collectionView.contentOffset.y
|
|
696
|
+
let oldLeftContentHeight = animateStructure ? flowLayout.bodyContentHeight : 0
|
|
697
|
+
let oldSpacerHeight = structuralSpacerHeight
|
|
698
|
+
let oldRowsHeight = animateStructure
|
|
699
|
+
? presentationHeights.values.reduce(CGFloat(0), +)
|
|
700
|
+
+ CGFloat(max(0, oldKeys.count - 1)) * (config?.itemSpacing ?? 0)
|
|
701
|
+
: 0
|
|
702
|
+
let newRowsHeight = animateStructure
|
|
703
|
+
? next.items.reduce(CGFloat(0)) { $0 + rowHeight($1) }
|
|
704
|
+
+ CGFloat(max(0, newKeys.count - 1)) * next.itemSpacing
|
|
705
|
+
: 0
|
|
706
|
+
let survivingKeys = animateStructure ? Set(newKeys) : Set<String>()
|
|
707
|
+
let visibleAnchor = animateStructure
|
|
708
|
+
? collectionView.indexPathsForVisibleItems.sorted().first {
|
|
709
|
+
oldKeys.indices.contains($0.item) && survivingKeys.contains(oldKeys[$0.item])
|
|
710
|
+
}
|
|
711
|
+
: nil
|
|
712
|
+
let anchorKey = visibleAnchor.map { oldKeys[$0.item] }
|
|
713
|
+
let oldPrefix = (animateStructure ? anchorKey : nil).flatMap { key -> CGFloat? in
|
|
714
|
+
guard let index = oldKeys.firstIndex(of: key) else { return nil }
|
|
715
|
+
return oldKeys.prefix(index).reduce(CGFloat(0)) { $0 + (presentationHeights[$1] ?? 0) }
|
|
716
|
+
+ CGFloat(index) * (config?.itemSpacing ?? 0)
|
|
717
|
+
} ?? 0
|
|
718
|
+
let newPrefix = (animateStructure ? anchorKey : nil).flatMap { key -> CGFloat? in
|
|
719
|
+
guard let index = newKeys.firstIndex(of: key) else { return nil }
|
|
720
|
+
return next.items.prefix(index).reduce(CGFloat(0)) { $0 + rowHeight($1) }
|
|
721
|
+
+ CGFloat(index) * next.itemSpacing
|
|
722
|
+
} ?? 0
|
|
723
|
+
if animateStructure {
|
|
724
|
+
stopStructuralAnimation()
|
|
725
|
+
structuralScrollInterrupted = false
|
|
726
|
+
structuralFooterStartY = reactContainerSlots.count > 2
|
|
727
|
+
? reactContainerSlots[2].host.frame.minY : nil
|
|
728
|
+
structuralFooterProgress = 0
|
|
729
|
+
// Keep deletion-only snapshots in their presentation order until their heights
|
|
730
|
+
// reach zero. Replacing these rows with a spacer produces a blank viewport.
|
|
731
|
+
let removedKeys = Set(oldKeys).subtracting(newKeys)
|
|
732
|
+
let retainsOrder = oldKeys.filter { survivingKeys.contains($0) } == newKeys
|
|
733
|
+
structuralRemovedItems = retainsOrder
|
|
734
|
+
? presentationItems.filter { removedKeys.contains($0.key) } : [:]
|
|
735
|
+
structuralRemovedHeights = retainsOrder
|
|
736
|
+
? presentationHeights.filter { removedKeys.contains($0.key) } : [:]
|
|
737
|
+
structuralRemovalProgress = 0
|
|
738
|
+
structuralSpacerHeight = structuralRemovedItems.isEmpty
|
|
739
|
+
? max(0, structuralSpacerHeight + oldRowsHeight - newRowsHeight) : 0
|
|
740
|
+
NotificationCenter.default.post(name: Notification.Name("OneKeyNativeListScrollCommandAccepted"),
|
|
741
|
+
object: collectionView, userInfo: ["phase": 0])
|
|
742
|
+
NotificationCenter.default.post(name: Notification.Name("OneKeyNativeListScrollCommandAccepted"),
|
|
743
|
+
object: collectionView, userInfo: ["phase": 1])
|
|
744
|
+
needsContentShrinkCorrection = false
|
|
745
|
+
} else if logicalOldKeys != newKeys {
|
|
746
|
+
stopStructuralAnimation()
|
|
747
|
+
structuralSpacerHeight = 0
|
|
748
|
+
structuralFooterStartY = nil
|
|
749
|
+
structuralRemovedItems.removeAll()
|
|
750
|
+
structuralRemovedHeights.removeAll()
|
|
751
|
+
}
|
|
584
752
|
invalidateActionAnchor(reason: "snapshot")
|
|
585
|
-
if let current = config,
|
|
753
|
+
if let current = config, structuralRemovedItems.isEmpty,
|
|
754
|
+
isControlledSelectionSnapshotUpdate(from: current, to: next) {
|
|
586
755
|
config = next
|
|
587
756
|
itemsByKey = Dictionary(uniqueKeysWithValues: next.items.map { ($0.key, $0) })
|
|
588
757
|
// OneKey patch: A controlled selection echo is fully handled by the
|
|
@@ -602,17 +771,41 @@ final class NativeListView: UIView {
|
|
|
602
771
|
// rows whose own content is unchanged.
|
|
603
772
|
let themeChanged = !dictionariesEqual(config?.theme, next.theme)
|
|
604
773
|
|| !dictionariesEqual(config?.listStyle, next.listStyle)
|
|
774
|
+
|| config?.layout != next.layout
|
|
605
775
|
if config?.generation != next.generation { endReachedGeneration = nil }
|
|
606
776
|
config = next
|
|
607
777
|
itemsByKey = Dictionary(uniqueKeysWithValues: next.items.map { ($0.key, $0) })
|
|
778
|
+
itemsByKey.merge(structuralRemovedItems) { current, _ in current }
|
|
608
779
|
configureSectionIndex(next)
|
|
609
780
|
configureLayout(next)
|
|
610
781
|
configureRefresh(next)
|
|
611
782
|
configureFooter(next)
|
|
612
783
|
|
|
784
|
+
if animateStructure, let transition {
|
|
785
|
+
let inset = collectionView.adjustedContentInset
|
|
786
|
+
let finalLeftHeight = max(0,
|
|
787
|
+
oldLeftContentHeight + newRowsHeight - oldRowsHeight - oldSpacerHeight)
|
|
788
|
+
let sidecarHeight = sidecarLayout == nil ? 0 :
|
|
789
|
+
next.contentPaddingTop + containerSlotHeights[3] + next.contentPaddingBottom
|
|
790
|
+
let finalHeight = max(finalLeftHeight, sidecarHeight)
|
|
791
|
+
let finalMaximum = max(-inset.top, finalHeight - collectionView.bounds.height + inset.bottom)
|
|
792
|
+
structuralStartSpacer = structuralSpacerHeight
|
|
793
|
+
structuralStartOffset = previousOffset
|
|
794
|
+
var targetOffset = min(max(-inset.top, previousOffset + newPrefix - oldPrefix), finalMaximum)
|
|
795
|
+
if visibleAnchor == nil, let fallbackKey = transition.anchorKey,
|
|
796
|
+
let fallbackIndex = newKeys.firstIndex(of: fallbackKey) {
|
|
797
|
+
let fallbackY = next.contentPaddingTop + containerSlotHeights[0]
|
|
798
|
+
+ next.items.prefix(fallbackIndex).reduce(CGFloat(0)) { $0 + rowHeight($1) }
|
|
799
|
+
+ CGFloat(fallbackIndex) * next.itemSpacing
|
|
800
|
+
targetOffset = min(targetOffset, max(-inset.top, fallbackY - inset.top))
|
|
801
|
+
}
|
|
802
|
+
structuralTargetOffset = targetOffset
|
|
803
|
+
structuralAnimationDuration = transition.duration
|
|
804
|
+
}
|
|
805
|
+
|
|
613
806
|
var snapshot = NSDiffableDataSourceSnapshot<Int, String>()
|
|
614
807
|
snapshot.appendSections([0])
|
|
615
|
-
let keys =
|
|
808
|
+
let keys = structuralRemovedItems.isEmpty ? newKeys : oldKeys
|
|
616
809
|
snapshot.appendItems(keys, toSection: 0)
|
|
617
810
|
var changedKeys = Set(keys.filter { key in
|
|
618
811
|
guard let old = oldItems[key], let new = itemsByKey[key] else { return false }
|
|
@@ -627,7 +820,7 @@ final class NativeListView: UIView {
|
|
|
627
820
|
let replacedKeys = changedRetainedKeys.filter { oldItems[$0]?.rendererKey != itemsByKey[$0]?.rendererKey }
|
|
628
821
|
snapshot.reloadItems(Array(replacedKeys))
|
|
629
822
|
snapshot.reconfigureItems(Array(changedRetainedKeys.subtracting(replacedKeys)))
|
|
630
|
-
dataSource.apply(snapshot, animatingDifferences:
|
|
823
|
+
dataSource.apply(snapshot, animatingDifferences: animateStructure && structuralRemovedItems.isEmpty) { [weak self] in
|
|
631
824
|
guard let self else { return }
|
|
632
825
|
self.collectionView.layoutIfNeeded()
|
|
633
826
|
self.performPendingScrollIfNeeded()
|
|
@@ -635,6 +828,88 @@ final class NativeListView: UIView {
|
|
|
635
828
|
self.checkEndReached()
|
|
636
829
|
self.syncSectionIndexToVisibleRows()
|
|
637
830
|
}
|
|
831
|
+
if animateStructure {
|
|
832
|
+
structuralAnimationStart = CACurrentMediaTime()
|
|
833
|
+
let displayLink = CADisplayLink(target: self, selector: #selector(advanceStructuralAnimation))
|
|
834
|
+
structuralDisplayLink = displayLink
|
|
835
|
+
displayLink.add(to: .main, forMode: .common)
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
private func stopStructuralAnimation() {
|
|
840
|
+
if structuralDisplayLink != nil {
|
|
841
|
+
NotificationCenter.default.post(name: Notification.Name("OneKeyNativeListScrollCommandAccepted"),
|
|
842
|
+
object: collectionView, userInfo: ["phase": 2])
|
|
843
|
+
}
|
|
844
|
+
structuralDisplayLink?.invalidate()
|
|
845
|
+
structuralDisplayLink = nil
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
@objc private func advanceStructuralAnimation() {
|
|
849
|
+
guard let config else { stopStructuralAnimation(); return }
|
|
850
|
+
let elapsed = CACurrentMediaTime() - structuralAnimationStart
|
|
851
|
+
let progress = min(1, max(0, elapsed / max(0.001, structuralAnimationDuration)))
|
|
852
|
+
let eased = progress * progress * (3 - 2 * progress)
|
|
853
|
+
structuralSpacerHeight = structuralStartSpacer * (1 - eased)
|
|
854
|
+
structuralFooterProgress = CGFloat(eased)
|
|
855
|
+
structuralRemovalProgress = CGFloat(eased)
|
|
856
|
+
for case let cell as NativeListRowHost in collectionView.visibleCells {
|
|
857
|
+
guard let indexPath = collectionView.indexPath(for: cell),
|
|
858
|
+
let key = dataSource.itemIdentifier(for: indexPath) else { continue }
|
|
859
|
+
cell.structuralContentHeight = structuralRemovedItems[key].map {
|
|
860
|
+
rowHeight($0, allocatedWidth: cell.bounds.width)
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
var inset = flowLayout.sectionInset
|
|
864
|
+
inset.bottom = config.contentPaddingBottom + containerSlotHeights[2] + structuralSpacerHeight
|
|
865
|
+
flowLayout.sectionInset = inset
|
|
866
|
+
flowLayout.invalidateLayout()
|
|
867
|
+
collectionView.layoutIfNeeded()
|
|
868
|
+
if !structuralScrollInterrupted && !collectionView.isTracking
|
|
869
|
+
&& !collectionView.isDragging && !collectionView.isDecelerating {
|
|
870
|
+
collectionView.contentOffset.y = structuralStartOffset
|
|
871
|
+
+ (structuralTargetOffset - structuralStartOffset) * eased
|
|
872
|
+
// Materialize the new viewport before updating presentation cells.
|
|
873
|
+
collectionView.layoutIfNeeded()
|
|
874
|
+
}
|
|
875
|
+
for cell in collectionView.visibleCells {
|
|
876
|
+
guard let indexPath = collectionView.indexPath(for: cell),
|
|
877
|
+
let key = dataSource.itemIdentifier(for: indexPath) else { continue }
|
|
878
|
+
let retiring = structuralRemovedItems[key] != nil
|
|
879
|
+
if retiring { cell.clipsToBounds = true }
|
|
880
|
+
cell.alpha = retiring ? 1 - structuralRemovalProgress : 1
|
|
881
|
+
cell.isUserInteractionEnabled = !retiring && !(itemsByKey[key]?.data.bool("disabled") ?? false)
|
|
882
|
+
}
|
|
883
|
+
layoutContainerSlots()
|
|
884
|
+
if progress >= 1 {
|
|
885
|
+
if !structuralRemovedItems.isEmpty {
|
|
886
|
+
var snapshot = dataSource.snapshot()
|
|
887
|
+
snapshot.deleteItems(Array(structuralRemovedItems.keys))
|
|
888
|
+
structuralRemovedItems.removeAll()
|
|
889
|
+
structuralRemovedHeights.removeAll()
|
|
890
|
+
dataSource.apply(snapshot, animatingDifferences: false)
|
|
891
|
+
itemsByKey = Dictionary(uniqueKeysWithValues: config.items.map { ($0.key, $0) })
|
|
892
|
+
collectionView.layoutIfNeeded()
|
|
893
|
+
if !structuralScrollInterrupted && !collectionView.isTracking
|
|
894
|
+
&& !collectionView.isDragging && !collectionView.isDecelerating {
|
|
895
|
+
let inset = collectionView.adjustedContentInset
|
|
896
|
+
let maximum = max(-inset.top,
|
|
897
|
+
collectionView.contentSize.height - collectionView.bounds.height + inset.bottom)
|
|
898
|
+
let target = min(max(-inset.top, structuralTargetOffset), maximum)
|
|
899
|
+
// Cancel UIKit's residual content-shrink scroll animation after deleting retired rows.
|
|
900
|
+
collectionView.setContentOffset(
|
|
901
|
+
CGPoint(x: collectionView.contentOffset.x, y: target), animated: false)
|
|
902
|
+
collectionView.layoutIfNeeded()
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
stopStructuralAnimation()
|
|
906
|
+
structuralSpacerHeight = 0
|
|
907
|
+
structuralFooterStartY = nil
|
|
908
|
+
layoutContainerSlots()
|
|
909
|
+
emitVisibleRangeIfNeeded()
|
|
910
|
+
checkEndReached()
|
|
911
|
+
scheduleContentShrinkCorrection()
|
|
912
|
+
}
|
|
638
913
|
}
|
|
639
914
|
|
|
640
915
|
func applyPatchesJson(_ json: String) {
|
|
@@ -696,6 +971,7 @@ final class NativeListView: UIView {
|
|
|
696
971
|
}
|
|
697
972
|
config = current
|
|
698
973
|
itemsByKey = Dictionary(uniqueKeysWithValues: current.items.map { ($0.key, $0) })
|
|
974
|
+
itemsByKey.merge(structuralRemovedItems) { current, _ in current }
|
|
699
975
|
for indexPath in collectionView.indexPathsForVisibleItems {
|
|
700
976
|
guard let item = item(at: indexPath),
|
|
701
977
|
marketQuoteKeys.contains(item.key),
|
|
@@ -959,6 +1235,7 @@ final class NativeListView: UIView {
|
|
|
959
1235
|
guard let self else { return }
|
|
960
1236
|
self.contentShrinkCorrectionScheduled = false
|
|
961
1237
|
guard !self.disposed, self.needsContentShrinkCorrection,
|
|
1238
|
+
self.structuralDisplayLink == nil,
|
|
962
1239
|
!self.collectionView.isTracking, !self.collectionView.isDragging,
|
|
963
1240
|
!self.collectionView.isDecelerating,
|
|
964
1241
|
self.collectionView.refreshControl?.isRefreshing != true,
|
|
@@ -994,15 +1271,21 @@ final class NativeListView: UIView {
|
|
|
994
1271
|
flowLayout.scrollDirection = isHorizontal ? .horizontal : .vertical
|
|
995
1272
|
flowLayout.minimumLineSpacing = config.itemSpacing
|
|
996
1273
|
flowLayout.minimumInteritemSpacing = config.itemSpacing
|
|
1274
|
+
let sidecarInset = sidecarBaseInset(collectionView.bounds.width)
|
|
1275
|
+
let sidecarSpace = sidecarLayout.map { $0.width + $0.gap } ?? 0
|
|
1276
|
+
let horizontalInset = config.contentPaddingHorizontal + sidecarInset
|
|
997
1277
|
flowLayout.sectionInset = UIEdgeInsets(
|
|
998
1278
|
top: config.contentPaddingTop + containerSlotHeights[0],
|
|
999
|
-
left:
|
|
1000
|
-
bottom: config.contentPaddingBottom + containerSlotHeights[2],
|
|
1001
|
-
right:
|
|
1279
|
+
left: horizontalInset + (isRightToLeft ? sidecarSpace + indexGutter : 0),
|
|
1280
|
+
bottom: config.contentPaddingBottom + containerSlotHeights[2] + structuralSpacerHeight,
|
|
1281
|
+
right: horizontalInset + (isRightToLeft ? 0 : sidecarSpace + indexGutter)
|
|
1002
1282
|
)
|
|
1003
|
-
|
|
1004
|
-
? config.contentPaddingTop + config.contentPaddingBottom + containerSlotHeights.reduce(0, +)
|
|
1283
|
+
let emptyMinimum = config.items.isEmpty
|
|
1284
|
+
? config.contentPaddingTop + config.contentPaddingBottom + containerSlotHeights.prefix(3).reduce(0, +)
|
|
1005
1285
|
: 0
|
|
1286
|
+
let sidecarMinimum = sidecarLayout == nil ? 0 :
|
|
1287
|
+
config.contentPaddingTop + containerSlotHeights[3] + config.contentPaddingBottom
|
|
1288
|
+
flowLayout.minimumContainerContentHeight = max(emptyMinimum, sidecarMinimum)
|
|
1006
1289
|
flowLayout.stickyItemIndexes = config.stickyHeaders
|
|
1007
1290
|
? Set(config.items.enumerated().compactMap {
|
|
1008
1291
|
$0.element.type == "sectionHeader" && $0.element.data.bool("sticky", default: true) && $0.element.data.string("variant") != "summary"
|
|
@@ -1016,6 +1299,7 @@ final class NativeListView: UIView {
|
|
|
1016
1299
|
listBodyGestureGuard.isEnabled = !isHorizontal
|
|
1017
1300
|
collectionView.showsVerticalScrollIndicator = sectionIndexEntries.isEmpty
|
|
1018
1301
|
collectionView.dragInteractionEnabled = false
|
|
1302
|
+
lastConfiguredCollectionWidth = collectionView.bounds.width
|
|
1019
1303
|
lastLayoutDirection = effectiveUserInterfaceLayoutDirection
|
|
1020
1304
|
}
|
|
1021
1305
|
|
|
@@ -1696,6 +1980,12 @@ final class NativeListView: UIView {
|
|
|
1696
1980
|
if item.key == interactiveReorderCompactKey {
|
|
1697
1981
|
cell.setWalletGroupReorderCompact(true)
|
|
1698
1982
|
}
|
|
1983
|
+
let retiring = structuralRemovedItems[item.key] != nil
|
|
1984
|
+
cell.structuralContentHeight = retiring
|
|
1985
|
+
? rowHeight(item, allocatedWidth: cell.bounds.width) : nil
|
|
1986
|
+
if retiring { cell.clipsToBounds = true }
|
|
1987
|
+
cell.alpha = retiring ? 1 - structuralRemovalProgress : 1
|
|
1988
|
+
cell.isUserInteractionEnabled = !retiring && !item.data.bool("disabled")
|
|
1699
1989
|
}
|
|
1700
1990
|
|
|
1701
1991
|
private func handleRowPress(_ item: NativeListItem, origin: NativeListActionOrigin?) {
|
|
@@ -1720,8 +2010,8 @@ final class NativeListView: UIView {
|
|
|
1720
2010
|
guard gesture.state == .began else { return }
|
|
1721
2011
|
let point = gesture.location(in: collectionView)
|
|
1722
2012
|
guard let indexPath = collectionView.indexPathForItem(at: point),
|
|
1723
|
-
let item =
|
|
1724
|
-
item.type == "market",
|
|
2013
|
+
let item = item(at: indexPath), structuralRemovedItems[item.key] == nil,
|
|
2014
|
+
(item.type == "market" || item.type == "identity"),
|
|
1725
2015
|
item.isRowPressEnabled else { return }
|
|
1726
2016
|
let actionKey = item.data.string("longPressActionKey")
|
|
1727
2017
|
guard !actionKey.isEmpty else { return }
|
|
@@ -2157,6 +2447,11 @@ final class NativeListView: UIView {
|
|
|
2157
2447
|
dataSource = nil
|
|
2158
2448
|
|
|
2159
2449
|
config = nil
|
|
2450
|
+
pagerStickyHeights.removeAllObjects()
|
|
2451
|
+
for slot in reactContainerSlots { slot.host.layer.mask = nil }
|
|
2452
|
+
stopStructuralAnimation()
|
|
2453
|
+
structuralSpacerHeight = 0
|
|
2454
|
+
structuralFooterStartY = nil
|
|
2160
2455
|
itemsByKey.removeAll()
|
|
2161
2456
|
sectionIndexEntries.removeAll()
|
|
2162
2457
|
if let pagerCommandCancelObserver {
|
|
@@ -2272,7 +2567,8 @@ final class NativeListView: UIView {
|
|
|
2272
2567
|
DispatchQueue.main.async { [weak self] in
|
|
2273
2568
|
guard let self else { return }
|
|
2274
2569
|
self.visibleEventScheduled = false
|
|
2275
|
-
guard
|
|
2570
|
+
guard self.structuralRemovedItems.isEmpty,
|
|
2571
|
+
let onVisibleRangeChanged = self.onVisibleRangeChanged else { return }
|
|
2276
2572
|
let indexes = self.collectionView.indexPathsForVisibleItems.map(\.item).sorted()
|
|
2277
2573
|
let first = indexes.first ?? -1
|
|
2278
2574
|
let last = indexes.last ?? -1
|
|
@@ -2291,7 +2587,7 @@ final class NativeListView: UIView {
|
|
|
2291
2587
|
}
|
|
2292
2588
|
|
|
2293
2589
|
private func checkEndReached() {
|
|
2294
|
-
guard let config,
|
|
2590
|
+
guard let config, structuralRemovedItems.isEmpty,
|
|
2295
2591
|
config.loadMore,
|
|
2296
2592
|
endReachedGeneration != config.generation,
|
|
2297
2593
|
!config.items.isEmpty else { return }
|
|
@@ -2316,7 +2612,8 @@ final class NativeListView: UIView {
|
|
|
2316
2612
|
if gestureRecognizer === reorderLongPress {
|
|
2317
2613
|
return config?.reorderable == true && item.isReorderable
|
|
2318
2614
|
}
|
|
2319
|
-
return item.type == "market"
|
|
2615
|
+
return (item.type == "market" || item.type == "identity")
|
|
2616
|
+
&& item.isRowPressEnabled && !item.data.string("longPressActionKey").isEmpty
|
|
2320
2617
|
}
|
|
2321
2618
|
guard gestureRecognizer === listBodyGestureGuard,
|
|
2322
2619
|
let pan = gestureRecognizer as? UIPanGestureRecognizer else { return true }
|
|
@@ -2427,14 +2724,16 @@ extension NativeListView: UICollectionViewDelegateFlowLayout {
|
|
|
2427
2724
|
return CGSize(width: width, height: height)
|
|
2428
2725
|
}
|
|
2429
2726
|
let available = max(0, collectionView.bounds.width - insets.left - insets.right)
|
|
2430
|
-
let structural = item.type == "sectionHeader" || item.type == "system" || item.type == "action"
|
|
2727
|
+
let structural = item.type == "sectionHeader" || item.type == "system" || item.type == "action" || item.type == "buttonGroup"
|
|
2431
2728
|
if config.layout == "grid", !structural {
|
|
2432
2729
|
let spacing = CGFloat(config.gridColumns - 1) * config.itemSpacing
|
|
2433
2730
|
let width = floor((available - spacing) / CGFloat(config.gridColumns))
|
|
2434
2731
|
let height = item.styledHeight ?? (item.type == "mediaTile" && item.data["height"] == nil ? width + 48 : rowHeight(item, allocatedWidth: width))
|
|
2435
2732
|
return CGSize(width: width, height: height)
|
|
2436
2733
|
}
|
|
2437
|
-
|
|
2734
|
+
let height = structuralRemovedHeights[item.key].map { $0 * (1 - structuralRemovalProgress) }
|
|
2735
|
+
?? rowHeight(item, allocatedWidth: available)
|
|
2736
|
+
return CGSize(width: available, height: max(0.01, height))
|
|
2438
2737
|
}
|
|
2439
2738
|
|
|
2440
2739
|
private func railWidth(_ item: NativeListItem) -> CGFloat {
|
|
@@ -2442,19 +2741,20 @@ extension NativeListView: UICollectionViewDelegateFlowLayout {
|
|
|
2442
2741
|
}
|
|
2443
2742
|
|
|
2444
2743
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
2445
|
-
guard let item =
|
|
2744
|
+
guard let item = item(at: indexPath), structuralRemovedItems[item.key] == nil else { return }
|
|
2446
2745
|
if item.type == "walletGroup" { return }
|
|
2447
2746
|
let origin = (collectionView.cellForItem(at: indexPath) as? NativeListRowHost)?.rowActionOrigin()
|
|
2448
2747
|
handleRowPress(item, origin: origin)
|
|
2449
2748
|
}
|
|
2450
2749
|
|
|
2451
2750
|
func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool {
|
|
2452
|
-
guard let item =
|
|
2751
|
+
guard let item = item(at: indexPath), structuralRemovedItems[item.key] == nil else { return false }
|
|
2453
2752
|
return item.isRowPressEnabled
|
|
2454
2753
|
}
|
|
2455
2754
|
|
|
2456
2755
|
func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath) {
|
|
2457
|
-
guard let item =
|
|
2756
|
+
guard let item = item(at: indexPath), structuralRemovedItems[item.key] == nil,
|
|
2757
|
+
item.type == "market" else { return }
|
|
2458
2758
|
let actionKey = item.data.string("pressInActionKey")
|
|
2459
2759
|
guard !actionKey.isEmpty else { return }
|
|
2460
2760
|
let origin = (collectionView.cellForItem(at: indexPath) as? NativeListRowHost)?.rowActionOrigin()
|
|
@@ -2462,7 +2762,7 @@ extension NativeListView: UICollectionViewDelegateFlowLayout {
|
|
|
2462
2762
|
}
|
|
2463
2763
|
|
|
2464
2764
|
func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
|
|
2465
|
-
guard let item =
|
|
2765
|
+
guard let item = item(at: indexPath), structuralRemovedItems[item.key] == nil else { return false }
|
|
2466
2766
|
return item.isRowPressEnabled
|
|
2467
2767
|
}
|
|
2468
2768
|
|
|
@@ -2474,6 +2774,11 @@ extension NativeListView: UICollectionViewDelegateFlowLayout {
|
|
|
2474
2774
|
}
|
|
2475
2775
|
|
|
2476
2776
|
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
|
2777
|
+
if structuralDisplayLink != nil {
|
|
2778
|
+
structuralScrollInterrupted = true
|
|
2779
|
+
NotificationCenter.default.post(name: Notification.Name("OneKeyNativeListScrollCommandAccepted"),
|
|
2780
|
+
object: collectionView, userInfo: ["phase": 2])
|
|
2781
|
+
}
|
|
2477
2782
|
scrollViewDidEndScrollingAnimation(scrollView)
|
|
2478
2783
|
minimumDragOffset = 0
|
|
2479
2784
|
refreshEmittedForDrag = false
|
|
@@ -2512,7 +2817,7 @@ extension NativeListView: UICollectionViewDragDelegate, UICollectionViewDropDele
|
|
|
2512
2817
|
itemsForBeginning session: UIDragSession,
|
|
2513
2818
|
at indexPath: IndexPath
|
|
2514
2819
|
) -> [UIDragItem] {
|
|
2515
|
-
guard config?.reorderable == true,
|
|
2820
|
+
guard config?.reorderable == true, structuralDisplayLink == nil,
|
|
2516
2821
|
let item = config?.items[safe: indexPath.item],
|
|
2517
2822
|
item.isReorderable else { return [] }
|
|
2518
2823
|
let dragItem = UIDragItem(itemProvider: NSItemProvider(object: item.key as NSString))
|
|
@@ -2587,6 +2892,7 @@ private final class NativeListCollectionView: UICollectionView {
|
|
|
2587
2892
|
final class NativeListFlowLayout: UICollectionViewFlowLayout {
|
|
2588
2893
|
var stickyItemIndexes: Set<Int> = []
|
|
2589
2894
|
var minimumContainerContentHeight: CGFloat = 0
|
|
2895
|
+
var bodyContentHeight: CGFloat { super.collectionViewContentSize.height }
|
|
2590
2896
|
private var horizontalAttributes: [IndexPath: UICollectionViewLayoutAttributes] = [:]
|
|
2591
2897
|
private var horizontalContentSize: CGSize = .zero
|
|
2592
2898
|
|
|
@@ -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>
|