@onekeyfe/react-native-native-list 6.7.0-3 → 6.7.0-30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/README.md +4 -0
  2. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
  3. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +250 -9
  4. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +35 -7
  5. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
  6. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
  7. package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
  8. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
  9. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
  10. package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +47 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
  12. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +152 -33
  13. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
  14. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
  15. package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +1 -1
  16. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
  17. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
  18. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -287
  19. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
  20. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +7 -0
  21. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
  22. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
  23. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
  24. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
  25. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
  26. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
  27. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
  28. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
  29. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
  30. package/docs/ROW_TEMPLATES.md +70 -11
  31. package/docs/SPEC.md +1170 -13
  32. package/docs/STYLE_SPEC.md +11 -0
  33. package/ios/HybridNativeList.swift +21 -2
  34. package/ios/NativeListAccessoryStack.swift +237 -51
  35. package/ios/NativeListActivityDetailsView.swift +30 -11
  36. package/ios/NativeListActivityRenderer.swift +8 -2
  37. package/ios/NativeListButtonGroupRenderer.swift +89 -0
  38. package/ios/NativeListDataRowRenderer.swift +167 -30
  39. package/ios/NativeListDesignAssets.swift +13 -75
  40. package/ios/NativeListGeneratedIcons.swift +55 -0
  41. package/ios/NativeListIconBinding.swift +171 -0
  42. package/ios/NativeListIdentityRenderer.swift +256 -39
  43. package/ios/NativeListLeadingVisual.swift +127 -28
  44. package/ios/NativeListMarketRenderer.swift +120 -31
  45. package/ios/NativeListMediaPreviewSlot.swift +122 -61
  46. package/ios/NativeListMediaTileRenderer.swift +7 -3
  47. package/ios/NativeListMessageRenderer.swift +34 -1
  48. package/ios/NativeListMetricCardRenderer.swift +4 -2
  49. package/ios/NativeListModels.swift +42 -2
  50. package/ios/NativeListRendererRegistry.swift +1 -0
  51. package/ios/NativeListResolvedText.swift +2 -1
  52. package/ios/NativeListRowHost.swift +14 -0
  53. package/ios/NativeListSectionHeaderRenderer.swift +100 -4
  54. package/ios/RNCNativeListView.swift +1052 -58
  55. package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
  56. package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
  57. package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
  58. package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
  59. package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
  60. package/ios/tests/NativeListLifecycleTests.swift +2798 -3
  61. package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
  62. package/ios/tests/NativeListMediaVisibilityTests.swift +26 -1
  63. package/ios/tests/NativeListSharedIconTests.swift +236 -0
  64. package/lib/module/NativeList.js +221 -36
  65. package/lib/module/NativeList.web.js +167 -46
  66. package/lib/module/index.js +1 -1
  67. package/lib/module/models.js +3 -0
  68. package/lib/module/selection.js +1 -1
  69. package/lib/module/validation.js +1246 -48
  70. package/lib/module/web/NativeListGeneratedIcons.js +31 -0
  71. package/lib/module/web/NativeListWebEngine.js +513 -274
  72. package/lib/module/web/templates/ActivityRowRenderer.js +120 -87
  73. package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
  74. package/lib/module/web/templates/DataRowRenderer.js +40 -5
  75. package/lib/module/web/templates/IdentityRowRenderer.js +158 -6
  76. package/lib/module/web/templates/MarketTableRowRenderer.js +37 -19
  77. package/lib/module/web/templates/MediaTileRowRenderer.js +4 -14
  78. package/lib/module/web/templates/MessageRowRenderer.js +18 -2
  79. package/lib/module/web/templates/RowContainerStyle.js +1 -0
  80. package/lib/module/web/templates/RowRendererRegistry.js +3 -0
  81. package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
  82. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  83. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  84. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  85. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  86. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  87. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  88. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  89. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  90. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  91. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  92. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  93. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  94. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  95. package/lib/typescript/src/NativeList.d.ts +3 -3
  96. package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
  97. package/lib/typescript/src/NativeList.types.d.ts +20 -2
  98. package/lib/typescript/src/index.d.ts +2 -2
  99. package/lib/typescript/src/models.d.ts +126 -17
  100. package/lib/typescript/src/validation.d.ts +20 -0
  101. package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
  102. package/lib/typescript/src/web/NativeListWebEngine.d.ts +32 -1
  103. package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
  104. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
  105. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
  106. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  107. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  108. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  109. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  110. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  111. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  112. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  113. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  114. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  115. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  116. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  117. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  118. package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  119. package/package.json +16 -10
  120. package/react-native-native-list.podspec +2 -6
  121. package/scripts/generate-icons.mjs +150 -0
  122. package/scripts/generate-icons.test.mjs +288 -0
  123. package/scripts/native-list-icons.json +260 -0
  124. package/src/NativeList.nitro.ts +2 -0
  125. package/src/NativeList.tsx +416 -89
  126. package/src/NativeList.types.ts +24 -2
  127. package/src/NativeList.web.tsx +295 -89
  128. package/src/index.ts +2 -0
  129. package/src/models.ts +263 -144
  130. package/src/selection.ts +1 -0
  131. package/src/validation.ts +3013 -152
  132. package/src/web/NativeListGeneratedIcons.ts +28 -0
  133. package/src/web/NativeListWebEngine.ts +816 -343
  134. package/src/web/templates/ActivityRowRenderer.ts +178 -141
  135. package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
  136. package/src/web/templates/DataRowRenderer.ts +93 -20
  137. package/src/web/templates/IdentityRowRenderer.ts +231 -6
  138. package/src/web/templates/MarketTableRowRenderer.ts +56 -33
  139. package/src/web/templates/MediaTileRowRenderer.ts +4 -17
  140. package/src/web/templates/MessageRowRenderer.ts +23 -7
  141. package/src/web/templates/RowContainerStyle.ts +2 -0
  142. package/src/web/templates/RowRendererRegistry.ts +11 -1
  143. package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
  144. package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
  145. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
  146. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
  147. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
  148. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
  149. package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
  150. package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
  151. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
  152. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
  153. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
  154. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
  155. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
  156. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
  157. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
  158. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
  159. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
  160. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
  161. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
  162. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
  163. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
  164. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
  165. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
  166. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
  167. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
  168. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
  169. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
  170. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
  171. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
  172. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
  173. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
  174. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
  175. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
  176. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
  177. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
  178. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
  179. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
  180. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
  181. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
  182. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
  183. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
  184. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
  185. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
  186. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
  187. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
  188. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
  189. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
  190. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
  191. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
  192. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
  193. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
  194. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
  195. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
  196. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
  197. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
  198. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
  199. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
  200. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
  201. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
  202. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
  203. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
  204. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
  205. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
  206. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
  207. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
  208. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
  209. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
  210. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
  211. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
  212. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
@@ -1,4 +1,5 @@
1
1
  import AVFoundation
2
+ import OneKeyImage
2
3
  import UIKit
3
4
 
4
5
  private final class NativeListPausedVideoView: UIView {
@@ -17,6 +18,18 @@ final class NativeListMediaPreviewSlot {
17
18
  private let image = NativeListImageSlot()
18
19
  private let video = NativeListPausedVideoView()
19
20
  private let frameView = UIImageView()
21
+ private final class PendingFrame {
22
+ private let lock = NSLock()
23
+ private var buffer: CVPixelBuffer?
24
+ init(_ buffer: CVPixelBuffer) { self.buffer = buffer }
25
+ func take() -> CVPixelBuffer? { lock.lock(); defer { lock.unlock() }; let value = buffer; buffer = nil; return value }
26
+ func cancel() { lock.lock(); buffer = nil; lock.unlock() }
27
+ }
28
+ private var pendingFrame: PendingFrame?
29
+ private var requestedEdge: Int?
30
+ private var subscription: OneKeyMediaPreviewCache.Subscription?
31
+ private var extractionLease: UUID?
32
+ private static let frameWorker = DispatchQueue(label: "onekey.native-list.frame", qos: .userInitiated)
20
33
  private var videoOutput: AVPlayerItemVideoOutput?
21
34
  private static let frameContext = CIContext(options: [.cacheIntermediates: false])
22
35
  private static let frameCaptureAttempts = 6
@@ -26,6 +39,7 @@ final class NativeListMediaPreviewSlot {
26
39
  private var playerGeneration = 0
27
40
  private var result: Bool?
28
41
  private var completion: ((Bool) -> Void)?
42
+ private(set) var createdPlayerCount = 0
29
43
  private var player: AVPlayer?
30
44
  private var itemObservation: NSKeyValueObservation?
31
45
  private var readyObservation: NSKeyValueObservation?
@@ -49,7 +63,7 @@ final class NativeListMediaPreviewSlot {
49
63
  video.onWindowChanged = { [weak self] in self?.observeViewport(); self?.updateVisibility() }
50
64
  video.onLayoutChanged = { [weak self] in self?.updateVisibility() }
51
65
  lifecycleObservers = [
52
- NotificationCenter.default.addObserver(forName: UIApplication.willResignActiveNotification, object: nil, queue: .main) { [weak self] _ in self?.releasePlayer() },
66
+ NotificationCenter.default.addObserver(forName: UIApplication.willResignActiveNotification, object: nil, queue: .main) { [weak self] _ in self?.cancelPreview() },
53
67
  NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: .main) { [weak self] _ in self?.updateVisibility() },
54
68
  ]
55
69
  }
@@ -87,7 +101,7 @@ final class NativeListMediaPreviewSlot {
87
101
  let candidate = candidateGeneration
88
102
  resumeVideo = nil
89
103
  viewportObservations.removeAll()
90
- releasePlayer()
104
+ cancelPreview()
91
105
  guard attempt < order.count else {
92
106
  result = false
93
107
  completion?(false)
@@ -113,81 +127,108 @@ final class NativeListMediaPreviewSlot {
113
127
  image.view.isHidden = true
114
128
  video.isHidden = false
115
129
  guard let url = URL(string: source.string("uri")), !source.string("uri").isEmpty else { finished(false); return }
130
+ let headers = (source.dictionary("headers") ?? [:]).compactMapValues { $0 as? String }
131
+ let fitKey = coverFit(fit ?? source.string("contentFit"))
116
132
  resumeVideo = { [weak self] in
117
- guard let self, self.epoch == token, self.candidateGeneration == candidate, self.player == nil else { return }
118
- self.playerGeneration &+= 1
119
- let generation = self.playerGeneration
120
- let asset = AVURLAsset(url: url, options: ["AVURLAssetHTTPHeaderFieldsKey": source.dictionary("headers") ?? [:]])
121
- let item = AVPlayerItem(asset: asset)
122
- item.preferredForwardBufferDuration = 1
123
- let output = AVPlayerItemVideoOutput(pixelBufferAttributes: [
124
- kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_32BGRA,
125
- ])
126
- item.add(output)
127
- self.videoOutput = output
128
- let player = AVPlayer(playerItem: item)
129
- player.isMuted = true
130
- player.pause()
131
- self.player = player
132
- self.video.playerLayer.player = player
133
- self.itemObservation = item.observe(\.status, options: [.initial, .new]) { [weak self] item, _ in
134
- DispatchQueue.main.async {
135
- guard let self, self.playerGeneration == generation else { return }
136
- if item.status == .failed { finished(false) }
137
- }
138
- }
139
- self.readyObservation = self.video.playerLayer.observe(\.isReadyForDisplay, options: [.initial, .new]) { [weak self] layer, _ in
140
- DispatchQueue.main.async {
141
- guard let self, self.playerGeneration == generation else { return }
142
- guard layer.isReadyForDisplay else { return }
133
+ guard let self, self.epoch == token, self.candidateGeneration == candidate,
134
+ self.subscription == nil, self.frameView.image == nil, !self.video.bounds.isEmpty else { return }
135
+ let edge = OneKeyMediaPreviewCache.targetEdge(max(self.video.bounds.width, self.video.bounds.height) * (self.video.window?.screen.scale ?? 1))
136
+ self.requestedEdge = edge
137
+ self.subscription = OneKeyMediaPreviewCache.shared.request(uri: url.absoluteString, headers: headers,
138
+ edge: edge, fit: fitKey, policy: source.string("cachePolicy", default: "memory-disk"),
139
+ onImage: { [weak self] still in
140
+ guard let self, self.epoch == token, self.candidateGeneration == candidate else { return }
141
+ self.subscription = nil
142
+ self.frameView.image = still; self.frameView.isHidden = false
143
+ self.viewportObservations.removeAll()
143
144
  finished(true)
144
- self.captureFirstFrame(generation: generation, attemptsLeft: Self.frameCaptureAttempts)
145
- }
146
- }
145
+ }, onExtract: { [weak self] lease in
146
+ guard let self, self.epoch == token, self.candidateGeneration == candidate else { return }
147
+ self.extractionLease = lease
148
+ self.updateVisibility()
149
+ guard self.extractionLease == lease, self.requestedEdge == edge else { return }
150
+ self.startPlayer(url: url, headers: headers, edge: edge, lease: lease)
151
+ }, onRevoked: { [weak self] in
152
+ self?.extractionLease = nil; self?.pendingFrame?.cancel(); self?.pendingFrame = nil; self?.releasePlayer()
153
+ },
154
+ onFailure: { [weak self] in
155
+ guard let self, self.epoch == token, self.candidateGeneration == candidate else { return }
156
+ self.subscription = nil; finished(false)
157
+ })
147
158
  }
148
159
  observeViewport()
149
160
  updateVisibility()
150
161
  }
151
162
 
152
- /// A paused item may not have handed its preroll frame to the output yet, so copying retries
153
- /// on later runloop turns. If no frame arrives the paused player stays attached.
154
- private func captureFirstFrame(generation: Int, attemptsLeft: Int) {
163
+ private func coverFit(_ fit: String) -> String { fit == "cover" ? "cover" : "contain" }
164
+
165
+ private func startPlayer(url: URL, headers: [String: String], edge: Int, lease: UUID) {
166
+ createdPlayerCount += 1
167
+ self.playerGeneration &+= 1
168
+ let generation = self.playerGeneration
169
+ let asset = AVURLAsset(url: url, options: ["AVURLAssetHTTPHeaderFieldsKey": headers])
170
+ let item = AVPlayerItem(asset: asset)
171
+ item.preferredForwardBufferDuration = 1
172
+ let output = AVPlayerItemVideoOutput(pixelBufferAttributes: [
173
+ kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_32BGRA,
174
+ ])
175
+ item.add(output)
176
+ self.videoOutput = output
177
+ let player = AVPlayer(playerItem: item)
178
+ player.isMuted = true
179
+ player.pause()
180
+ self.player = player
181
+ self.video.playerLayer.player = player
182
+ self.itemObservation = item.observe(\.status, options: [.initial, .new]) { [weak self] item, _ in
183
+ DispatchQueue.main.async {
184
+ guard let self, self.playerGeneration == generation else { return }
185
+ if item.status == .failed { OneKeyMediaPreviewCache.shared.fail(lease) }
186
+ }
187
+ }
188
+ self.readyObservation = self.video.playerLayer.observe(\.isReadyForDisplay, options: [.initial, .new]) { [weak self] layer, _ in
189
+ DispatchQueue.main.async {
190
+ guard let self, self.playerGeneration == generation, layer.isReadyForDisplay else { return }
191
+ self.readyObservation = nil
192
+ self.captureFirstFrame(generation: generation, attemptsLeft: Self.frameCaptureAttempts, edge: edge, lease: lease)
193
+ }
194
+ }
195
+ }
196
+
197
+ /// Capture only the buffer on UI; CI normalizes orientation and size on a worker.
198
+ private func captureFirstFrame(generation: Int, attemptsLeft: Int, edge: Int, lease: UUID) {
155
199
  guard playerGeneration == generation, let player, let item = player.currentItem, let output = videoOutput else { return }
156
200
  let time = item.currentTime()
157
- if let buffer = output.copyPixelBuffer(forItemTime: time, itemTimeForDisplay: nil),
158
- let still = Self.frameContext.createCGImage(CIImage(cvPixelBuffer: buffer), from: CGRect(
159
- x: 0, y: 0, width: CVPixelBufferGetWidth(buffer), height: CVPixelBufferGetHeight(buffer))) {
160
- let transform = item.tracks.lazy.compactMap(\.assetTrack).first { $0.mediaType == .video }?.preferredTransform
161
- frameView.image = UIImage(cgImage: still, scale: 1, orientation: Self.orientation(transform))
162
- frameView.isHidden = false
163
- resumeVideo = nil
164
- viewportObservations.removeAll()
201
+ if let buffer = output.copyPixelBuffer(forItemTime: time, itemTimeForDisplay: nil) {
202
+ let transform = item.tracks.lazy.compactMap(\.assetTrack).first { $0.mediaType == .video }?.preferredTransform ?? .identity
165
203
  releasePlayer()
204
+ let pending = PendingFrame(buffer)
205
+ pendingFrame = pending
206
+ Self.frameWorker.async { [weak self] in
207
+ guard let buffer = pending.take() else { return }
208
+ var image = CIImage(cvPixelBuffer: buffer).transformed(by: transform)
209
+ let origin = image.extent.origin
210
+ image = image.transformed(by: CGAffineTransform(translationX: -origin.x, y: -origin.y))
211
+ let scale = min(1, CGFloat(edge) / max(image.extent.width, image.extent.height))
212
+ image = image.transformed(by: CGAffineTransform(scaleX: scale, y: scale))
213
+ let still = Self.frameContext.createCGImage(image, from: image.extent).map { UIImage(cgImage: $0) }
214
+ DispatchQueue.main.async {
215
+ guard let self, self.extractionLease == lease else { return }
216
+ if let still { OneKeyMediaPreviewCache.shared.complete(lease, image: still) }
217
+ else { OneKeyMediaPreviewCache.shared.fail(lease) }
218
+ }
219
+ }
166
220
  return
167
221
  }
168
- guard attemptsLeft > 1 else { return }
169
- // An exact seek re-delivers the paused preroll frame to newly attached outputs.
170
- if attemptsLeft == Self.frameCaptureAttempts {
171
- player.seek(to: time, toleranceBefore: .zero, toleranceAfter: .zero)
172
- }
222
+ guard attemptsLeft > 1 else { OneKeyMediaPreviewCache.shared.fail(lease); return }
223
+ if attemptsLeft == Self.frameCaptureAttempts { player.seek(to: time, toleranceBefore: .zero, toleranceAfter: .zero) }
173
224
  DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [weak self] in
174
- self?.captureFirstFrame(generation: generation, attemptsLeft: attemptsLeft - 1)
175
- }
176
- }
177
-
178
- private static func orientation(_ transform: CGAffineTransform?) -> UIImage.Orientation {
179
- guard let transform else { return .up }
180
- switch (transform.a, transform.b, transform.c, transform.d) {
181
- case (0, 1, -1, 0): return .right
182
- case (0, -1, 1, 0): return .left
183
- case (-1, 0, 0, -1): return .down
184
- default: return .up
225
+ self?.captureFirstFrame(generation: generation, attemptsLeft: attemptsLeft - 1, edge: edge, lease: lease)
185
226
  }
186
227
  }
187
228
 
188
229
  private func observeViewport() {
189
230
  viewportObservations.removeAll()
190
- guard resumeVideo != nil, video.window != nil else { return }
231
+ guard resumeVideo != nil, frameView.image == nil, video.window != nil else { return }
191
232
  var ancestor = video.superview
192
233
  while let current = ancestor {
193
234
  if let scrollView = current as? UIScrollView {
@@ -223,8 +264,24 @@ final class NativeListMediaPreviewSlot {
223
264
  }
224
265
 
225
266
  private func updateVisibility() {
267
+ if let requestedEdge, let window = video.window, !video.bounds.isEmpty {
268
+ let edge = OneKeyMediaPreviewCache.targetEdge(max(video.bounds.width, video.bounds.height) * window.screen.scale)
269
+ if edge != requestedEdge {
270
+ cancelPreview(); self.requestedEdge = nil
271
+ frameView.image = nil; frameView.isHidden = true; result = nil
272
+ observeViewport()
273
+ }
274
+ }
226
275
  if Self.intersectsViewport(video) && UIApplication.shared.applicationState == .active { resumeVideo?() }
227
- else { releasePlayer() }
276
+ else { cancelPreview() }
277
+ }
278
+ private func cancelPreview() {
279
+ let previous = subscription
280
+ subscription = nil
281
+ OneKeyMediaPreviewCache.shared.cancel(previous)
282
+ extractionLease = nil
283
+ pendingFrame?.cancel(); pendingFrame = nil
284
+ releasePlayer()
228
285
  }
229
286
  private func releasePlayer() {
230
287
  playerGeneration &+= 1
@@ -241,10 +298,11 @@ final class NativeListMediaPreviewSlot {
241
298
  candidateGeneration &+= 1
242
299
  resumeVideo = nil
243
300
  viewportObservations.removeAll()
244
- releasePlayer()
301
+ cancelPreview()
245
302
  image.recycle()
246
303
  image.view.isHidden = false
247
304
  video.isHidden = true
305
+ requestedEdge = nil
248
306
  frameView.image = nil
249
307
  frameView.isHidden = true
250
308
  identity = nil
@@ -252,6 +310,9 @@ final class NativeListMediaPreviewSlot {
252
310
  completion = nil
253
311
  }
254
312
  deinit {
313
+ pendingFrame?.cancel()
314
+ let pending = subscription
315
+ DispatchQueue.main.async { OneKeyMediaPreviewCache.shared.cancel(pending) }
255
316
  lifecycleObservers.forEach(NotificationCenter.default.removeObserver)
256
317
  player?.pause()
257
318
  player?.replaceCurrentItem(with: nil)
@@ -11,7 +11,7 @@ final class NativeListMediaTileCell: NativeListRendererCell {
11
11
  private let picture = UIView()
12
12
  private let image = NativeListMediaPreviewSlot()
13
13
  private let network = NativeListImageSlot()
14
- private let errorIcon = UIImageView()
14
+ private let errorIcon = NativeListIconImageView()
15
15
  private let title = NativeListTextLabel()
16
16
  private let subtitle = NativeListTextLabel()
17
17
  private let badge = NativeListTextLabel()
@@ -87,6 +87,9 @@ final class NativeListMediaTileCell: NativeListRendererCell {
87
87
  _ item: NativeListItem, theme: [String: Any]?, layout: String,
88
88
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
89
89
  ) {
90
+ let iconUpdate = NativeListIconUpdate(self)
91
+ defer { iconUpdate.finish() }
92
+
90
93
  let style = item.data.dictionary("style") ?? [:]
91
94
  imageStyle = style.dictionary("image") ?? [:]
92
95
  let hp = CGFloat(style.double("horizontalPadding", default: 10))
@@ -122,8 +125,8 @@ final class NativeListMediaTileCell: NativeListRendererCell {
122
125
  let state = item.data.string("imageState")
123
126
  let placeholder = theme?.string("strongBackground", default: "#0000000F") ?? "#0000000F"
124
127
  errorIcon.isHidden = state != "error"
125
- errorIcon.image = nativeListIcon(named: "ImageSquareWavesOutline")
126
- errorIcon.tintColor = UIColor(nativeListHex: "#00000044", fallback: .lightGray)
128
+ errorIcon.bindIcon("ImageSquareWavesOutline")
129
+ errorIcon.tintColor = nativeListColor(theme, "disabledText", "#8C8C8C")
127
130
  let media = item.data.dictionary("media")
128
131
  if state != "empty", state != "error", let source = media?.dictionary("source") ?? item.data.dictionary("image") {
129
132
  // Legacy source-backed media had a transparent container. Clear only a fill this
@@ -164,6 +167,7 @@ final class NativeListMediaTileCell: NativeListRendererCell {
164
167
  close.setTitle("×", for: .normal)
165
168
  close.titleLabel?.font = nativeListFont(ofSize: 16, weight: .medium, fonts: fonts)
166
169
  close.setTitleColor(nativeListColor(theme, "primaryText", "#202020"), for: .normal)
170
+
167
171
  }
168
172
  override func layoutSubviews() {
169
173
  let width = CGFloat(
@@ -29,7 +29,9 @@ enum NativeListMessageRenderer {
29
29
  body = NativeListResolvedText(
30
30
  item.data.string("body"), style: style.dictionary("body"), size: 14,
31
31
  color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 20,
32
- lines: item.data.int("bodyLines", default: 3), fonts: fonts)
32
+ lines: item.data.int("bodyLines", default: 3),
33
+ breakMode: item.data.int("bodyLines", default: 3) == 0 ? .byWordWrapping : .byTruncatingTail,
34
+ fonts: fonts)
33
35
  time = NativeListResolvedText(
34
36
  item.data.string("time"), style: style.dictionary("time"), size: 12,
35
37
  color: nativeListColor(theme, "disabledText", "#8D8D8D"), lineHeight: 16, lines: 1,
@@ -150,6 +152,11 @@ enum NativeListMessageRenderer {
150
152
  }
151
153
 
152
154
  final class NativeListMessageCell: NativeListRendererCell {
155
+ private let topWarningBorder = CALayer()
156
+ private let bottomWarningBorder = CALayer()
157
+ private var warningBorderWidth: CGFloat = 0
158
+ private var warningBorderColor = UIColor.clear
159
+ private var isInlineWarning = false
153
160
  override class func measure(
154
161
  _ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String,
155
162
  fonts: NativeListFontFamilies
@@ -167,6 +174,10 @@ final class NativeListMessageCell: NativeListRendererCell {
167
174
  _ item: NativeListItem, theme: [String: Any]?, layout: String,
168
175
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
169
176
  ) {
177
+ let container = item.data.dictionary("style")?.dictionary("container") ?? [:]
178
+ isInlineWarning = item.data.string("presentation") == "inlineWarning"
179
+ warningBorderWidth = isInlineWarning ? CGFloat(container.double("borderWidth")) : 0
180
+ warningBorderColor = UIColor(nativeListHex: container.string("borderColor"), fallback: .clear)
170
181
  let resolved = NativeListMessageRenderer.Resolved(
171
182
  item, theme: theme, layout: layout, fonts: fonts)
172
183
  views.bind(resolved, item: item, theme: theme, fonts: fonts)
@@ -174,5 +185,27 @@ final class NativeListMessageCell: NativeListRendererCell {
174
185
  top: resolved.verticalPadding, left: resolved.horizontalPadding,
175
186
  bottom: resolved.verticalPadding, right: resolved.horizontalPadding)
176
187
  }
188
+ override func applyAppearance() {
189
+ super.applyAppearance()
190
+ if isInlineWarning {
191
+ layer.cornerRadius = 0
192
+ contentView.layer.cornerRadius = 0
193
+ contentView.layer.borderWidth = 0
194
+ topWarningBorder.backgroundColor = warningBorderColor.cgColor
195
+ bottomWarningBorder.backgroundColor = warningBorderColor.cgColor
196
+ if topWarningBorder.superlayer == nil { contentView.layer.addSublayer(topWarningBorder) }
197
+ if bottomWarningBorder.superlayer == nil { contentView.layer.addSublayer(bottomWarningBorder) }
198
+ } else {
199
+ topWarningBorder.removeFromSuperlayer()
200
+ bottomWarningBorder.removeFromSuperlayer()
201
+ }
202
+ }
203
+ override func layoutSubviews() {
204
+ super.layoutSubviews()
205
+ let height = max(0, warningBorderWidth)
206
+ topWarningBorder.frame = CGRect(x: 0, y: 0, width: contentView.bounds.width, height: height)
207
+ bottomWarningBorder.frame = CGRect(
208
+ x: 0, y: contentView.bounds.height - height, width: contentView.bounds.width, height: height)
209
+ }
177
210
  override func recycleContent() { views.recycle() }
178
211
  }
@@ -374,7 +374,7 @@ final class NativeListMetricCardCell: NativeListRendererCell {
374
374
  }
375
375
 
376
376
  private final class NativeListMetricVisual: UIView {
377
- private let icon = UIImageView()
377
+ private let icon = NativeListIconImageView()
378
378
  private let image = NativeListImageSlot()
379
379
  init() {
380
380
  super.init(frame: .zero)
@@ -389,6 +389,8 @@ private final class NativeListMetricVisual: UIView {
389
389
  }
390
390
  required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
391
391
  func bind(_ visual: [String: Any], key: String, placeholder: String) {
392
+ let iconUpdate = NativeListIconUpdate(self)
393
+ defer { iconUpdate.finish() }
392
394
  backgroundColor = UIColor(
393
395
  nativeListHex: visual.string("backgroundColor", default: "#0000000F"), fallback: .lightGray)
394
396
  layer.cornerRadius = visual.string("shape") == "square" ? 0 : 8
@@ -397,7 +399,7 @@ private final class NativeListMetricVisual: UIView {
397
399
  image.view.isHidden = true
398
400
  if kind == "icon" {
399
401
  image.recycle()
400
- icon.image = nativeListIcon(named: visual.string("name"))
402
+ icon.bindIcon(visual.string("name"))
401
403
  icon.tintColor = UIColor(
402
404
  nativeListHex: visual.string("tintColor", default: "#00000072"), fallback: .darkGray)
403
405
  } else if let source = kind == "stackedImages"
@@ -1,9 +1,10 @@
1
1
  import Foundation
2
+ import CoreFoundation
2
3
  import UIKit
3
4
 
4
5
  // Template type alone partitions reuse; data keys and styles never select a renderer.
5
6
  enum NativeListRendererKey: String, CaseIterable {
6
- case message, rail, mediaTile, action, system, activity, dataRow, metricCard, market, identity, sectionHeader, walletGroup
7
+ case message, rail, mediaTile, action, buttonGroup, system, activity, dataRow, metricCard, market, identity, sectionHeader, walletGroup
7
8
  /// Not a template: legacy accepted any non-empty type and drew an empty row with the
8
9
  /// shared chrome. Unknown types keep that placeholder instead of failing the snapshot.
9
10
  case unsupported = "__nativeListUnsupported"
@@ -35,7 +36,7 @@ struct NativeListItem {
35
36
  }
36
37
 
37
38
  var isRowPressEnabled: Bool {
38
- !data.bool("disabled") &&
39
+ type != "buttonGroup" && !data.bool("disabled") &&
39
40
  !data.bool("pressDisabled") &&
40
41
  (type != "system" || data.string("variant") == "retry")
41
42
  }
@@ -78,7 +79,18 @@ struct NativeListItem {
78
79
  }
79
80
 
80
81
  struct NativeListConfig {
82
+ struct StructuralTransition {
83
+ let id: String
84
+ let duration: TimeInterval
85
+ let anchorKey: String?
86
+ }
87
+ struct Disclosure {
88
+ let expanded: Bool
89
+ let expandedTrailingInset: CGFloat
90
+ }
81
91
  let generation: Int
92
+ let structuralTransition: StructuralTransition?
93
+ let disclosure: Disclosure?
82
94
  let layout: String
83
95
  let orientation: String
84
96
  let gridColumns: Int
@@ -129,6 +141,32 @@ struct NativeListConfig {
129
141
  let capabilities = root["capabilities"] as? [String: Any]
130
142
  let sectionIndex = capabilities?["sectionIndex"] as? [String: Any]
131
143
  let footer = try (root["fixedFooter"] as? [String: Any]).map(NativeListItem.init)
144
+ let transition = root["structuralTransition"] as? [String: Any]
145
+ let structuralTransition = (transition?["id"] as? String).map { id in
146
+ StructuralTransition(
147
+ id: id,
148
+ duration: min(2, max(0, (transition?["durationMs"] as? Double ?? 220) / 1000)),
149
+ anchorKey: transition?["anchorKey"] as? String)
150
+ }
151
+ let disclosure: Disclosure?
152
+ if let value = root["disclosure"] {
153
+ guard let data = value as? [String: Any],
154
+ let expandedNumber = data["expanded"] as? NSNumber,
155
+ CFGetTypeID(expandedNumber) == CFBooleanGetTypeID() else {
156
+ throw NativeListModelError.invalidSnapshot
157
+ }
158
+ let insetNumber = data["expandedTrailingInset"] as? NSNumber
159
+ guard data["expandedTrailingInset"] == nil || insetNumber != nil,
160
+ insetNumber.map({ CFGetTypeID($0) != CFBooleanGetTypeID() }) ?? true else {
161
+ throw NativeListModelError.invalidSnapshot
162
+ }
163
+ let inset = insetNumber?.doubleValue ?? 0
164
+ guard inset.isFinite, inset >= 0 else { throw NativeListModelError.invalidSnapshot }
165
+ disclosure = Disclosure(expanded: expandedNumber.boolValue,
166
+ expandedTrailingInset: CGFloat(inset))
167
+ } else {
168
+ disclosure = nil
169
+ }
132
170
 
133
171
  let contentPadding = max(0, CGFloat(layoutData.double("contentPadding")))
134
172
  let contentPaddingHorizontal = layoutData["contentPaddingHorizontal"] == nil
@@ -143,6 +181,8 @@ struct NativeListConfig {
143
181
 
144
182
  return NativeListConfig(
145
183
  generation: generation,
184
+ structuralTransition: structuralTransition,
185
+ disclosure: disclosure,
146
186
  layout: layout,
147
187
  orientation: layoutData["orientation"] as? String ?? "vertical",
148
188
  gridColumns: min(7, max(1, layoutData["gridColumns"] as? Int ?? 1)),
@@ -18,6 +18,7 @@ enum NativeListRendererRegistry {
18
18
  .activity: (NativeListActivityCell.self, { NativeListActivityCell(frame: .zero) }),
19
19
  .system: (NativeListSystemCell.self, { NativeListSystemCell(frame: .zero) }),
20
20
  .action: (NativeListActionCell.self, { NativeListActionCell(frame: .zero) }),
21
+ .buttonGroup: (NativeListButtonGroupCell.self, { NativeListButtonGroupCell(frame: .zero) }),
21
22
  .unsupported: (
22
23
  NativeListUnsupportedCell.self, { NativeListUnsupportedCell(frame: .zero) }
23
24
  ),
@@ -26,7 +26,8 @@ struct NativeListResolvedText {
26
26
  let style = style ?? [:]
27
27
  self.tabular = tabular
28
28
  self.preservesBreakMode = preservesBreakMode
29
- self.lines = min(3, max(1, style.int("lines", default: lines)))
29
+ let requestedLines = style.int("lines", default: lines)
30
+ self.lines = requestedLines == 0 ? 0 : min(3, max(1, requestedLines))
30
31
  explicitTruncation = style["lines"] != nil || style["truncate"] != nil
31
32
  text =
32
33
  self.lines == 1 && explicitTruncation
@@ -42,6 +42,20 @@ class NativeListRowHost: UICollectionViewCell {
42
42
  var listStyle: [String: Any]?
43
43
  var onAction: ((NativeListItem, String, NativeSelectionTarget?, NativeListActionOrigin?) -> Void)?
44
44
  var onBindingInvalidated: ((NativeListRowHost, Int) -> Void)?
45
+ var structuralContentHeight: CGFloat?
46
+
47
+ override func layoutSubviews() {
48
+ super.layoutSubviews()
49
+ // UIKit relays out cells again when the collection's offset changes.
50
+ if let structuralContentHeight {
51
+ contentView.frame = CGRect(x: 0, y: 0, width: bounds.width, height: structuralContentHeight)
52
+ }
53
+ }
54
+
55
+ override func prepareForReuse() {
56
+ super.prepareForReuse()
57
+ structuralContentHeight = nil
58
+ }
45
59
 
46
60
  func bind(
47
61
  item: NativeListItem, theme: [String: Any]?, layout: String, itemIndex: Int? = nil,