@onekeyfe/react-native-native-list 3.0.158 → 3.0.159

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 (199) hide show
  1. package/README.md +21 -5
  2. package/android/build.gradle +7 -0
  3. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +20 -0
  4. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +711 -0
  5. package/android/src/main/java/com/onekey/nativelist/NativeListActionRenderer.kt +169 -0
  6. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +179 -0
  7. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +264 -0
  8. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +20 -6
  9. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +53 -0
  10. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +487 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListEndAlignment.kt +5 -0
  12. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +820 -0
  13. package/android/src/main/java/com/onekey/nativelist/NativeListImageSlot.kt +147 -0
  14. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +453 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +997 -0
  16. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +268 -0
  17. package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +243 -0
  18. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +232 -0
  19. package/android/src/main/java/com/onekey/nativelist/NativeListMetricCardRenderer.kt +551 -0
  20. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +27 -1
  21. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +475 -0
  22. package/android/src/main/java/com/onekey/nativelist/NativeListRailRenderer.kt +143 -0
  23. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +42 -0
  24. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +415 -0
  25. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +163 -0
  26. package/android/src/main/java/com/onekey/nativelist/NativeListRowHost.kt +70 -0
  27. package/android/src/main/java/com/onekey/nativelist/NativeListScrollPositionTracker.kt +59 -0
  28. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +763 -0
  29. package/android/src/main/java/com/onekey/nativelist/NativeListSystemRenderer.kt +464 -0
  30. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +25 -0
  31. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +432 -124
  32. package/android/src/main/java/com/onekey/nativelist/NativeListWalletGroupRenderer.kt +407 -0
  33. package/android/src/main/res/values/native_scroll_coordinator_ids.xml +5 -0
  34. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListEndAlignmentTest.kt +34 -0
  35. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListScrollPositionTrackerTest.kt +44 -0
  36. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListSelectorBackgroundColorTest.kt +34 -0
  37. package/docs/DESIGN.md +520 -9
  38. package/docs/MIGRATION_BASELINE.md +117 -0
  39. package/docs/ROW_TEMPLATES.md +404 -0
  40. package/docs/SPEC.md +621 -0
  41. package/docs/STYLE_SPEC.md +988 -0
  42. package/docs/images/list-capabilities.svg +39 -0
  43. package/docs/images/row-action.svg +17 -0
  44. package/docs/images/row-activity.svg +24 -0
  45. package/docs/images/row-data.svg +24 -0
  46. package/docs/images/row-identity.svg +25 -0
  47. package/docs/images/row-market.svg +23 -0
  48. package/docs/images/row-media-tile.svg +26 -0
  49. package/docs/images/row-message.svg +20 -0
  50. package/docs/images/row-metric-card.svg +33 -0
  51. package/docs/images/row-rail.svg +18 -0
  52. package/docs/images/row-section-header.svg +19 -0
  53. package/docs/images/row-style-regions.svg +30 -0
  54. package/docs/images/row-system.svg +30 -0
  55. package/docs/images/row-wallet-group.svg +26 -0
  56. package/ios/HybridNativeList.swift +30 -0
  57. package/ios/NativeListAccessoryStack.swift +680 -0
  58. package/ios/NativeListActionRenderer.swift +108 -0
  59. package/ios/NativeListActivityDetailsView.swift +291 -0
  60. package/ios/NativeListActivityRenderer.swift +201 -0
  61. package/ios/NativeListDataRowRenderer.swift +444 -0
  62. package/ios/NativeListIdentityRenderer.swift +685 -0
  63. package/ios/NativeListImageSlot.swift +140 -0
  64. package/ios/NativeListLeadingVisual.swift +372 -0
  65. package/ios/NativeListMarketRenderer.swift +698 -0
  66. package/ios/NativeListMediaPreviewSlot.swift +259 -0
  67. package/ios/NativeListMediaTileRenderer.swift +190 -0
  68. package/ios/NativeListMessageRenderer.swift +168 -0
  69. package/ios/NativeListMetricCardRenderer.swift +420 -0
  70. package/ios/NativeListModels.swift +36 -1
  71. package/ios/NativeListRailRenderer.swift +152 -0
  72. package/ios/NativeListRendererCell.swift +311 -0
  73. package/ios/NativeListRendererRegistry.swift +50 -0
  74. package/ios/NativeListResolvedText.swift +130 -0
  75. package/ios/NativeListRowHost.swift +63 -0
  76. package/ios/NativeListScrollPositionTracker.swift +30 -0
  77. package/ios/NativeListSectionHeaderRenderer.swift +734 -0
  78. package/ios/NativeListSystemRenderer.swift +568 -0
  79. package/ios/NativeListTextLabel.swift +42 -0
  80. package/ios/NativeListTextStyles.swift +236 -0
  81. package/ios/NativeListWalletGroupRenderer.swift +255 -0
  82. package/ios/RNCNativeListView.swift +282 -184
  83. package/ios/tests/NativeListActivityPresentationTests.swift +97 -0
  84. package/ios/tests/NativeListLifecycleTests.swift +241 -0
  85. package/ios/tests/NativeListMediaVisibilityTests.swift +109 -0
  86. package/ios/tests/NativeListScrollPositionTrackerTests.swift +25 -0
  87. package/lib/module/NativeList.js +56 -3
  88. package/lib/module/NativeList.web.js +5 -0
  89. package/lib/module/models.js +54 -0
  90. package/lib/module/validation.js +386 -28
  91. package/lib/module/web/NativeListWebEngine.js +148 -936
  92. package/lib/module/web/templates/ActionRowRenderer.js +97 -0
  93. package/lib/module/web/templates/ActivityRowRenderer.js +95 -0
  94. package/lib/module/web/templates/DataRowRenderer.js +145 -0
  95. package/lib/module/web/templates/IdentityRowRenderer.js +289 -0
  96. package/lib/module/web/templates/MarketRowRenderer.js +310 -0
  97. package/lib/module/web/templates/MediaTileRowRenderer.js +132 -0
  98. package/lib/module/web/templates/MessageRowRenderer.js +165 -0
  99. package/lib/module/web/templates/MetricCardRowRenderer.js +172 -0
  100. package/lib/module/web/templates/RailRowRenderer.js +98 -0
  101. package/lib/module/web/templates/RowContainerStyle.js +100 -0
  102. package/lib/module/web/templates/RowElements.js +93 -0
  103. package/lib/module/web/templates/RowRendererRegistry.js +70 -0
  104. package/lib/module/web/templates/RowText.js +121 -0
  105. package/lib/module/web/templates/RowVisual.js +43 -0
  106. package/lib/module/web/templates/SectionHeaderRowRenderer.js +146 -0
  107. package/lib/module/web/templates/SystemRowRenderer.js +161 -0
  108. package/lib/module/web/templates/WalletGroupRowRenderer.js +96 -0
  109. package/lib/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
  110. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +39 -3
  111. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +6 -0
  112. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +15 -0
  113. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_bool.kt +78 -0
  114. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +26 -0
  115. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +24 -9
  116. package/lib/nitrogen/generated/android/nativelistOnLoad.cpp +2 -0
  117. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +8 -0
  118. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +37 -0
  119. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +23 -2
  120. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +32 -0
  121. package/lib/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  122. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +3 -0
  123. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +54 -0
  124. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +6 -0
  125. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +8 -2
  126. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +6 -0
  127. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +11 -2
  128. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +3 -0
  129. package/lib/typescript/src/NativeList.nitro.d.ts +3 -0
  130. package/lib/typescript/src/NativeList.types.d.ts +14 -1
  131. package/lib/typescript/src/models.d.ts +199 -18
  132. package/lib/typescript/src/web/NativeListWebEngine.d.ts +18 -16
  133. package/lib/typescript/src/web/templates/ActionRowRenderer.d.ts +15 -0
  134. package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +15 -0
  135. package/lib/typescript/src/web/templates/DataRowRenderer.d.ts +15 -0
  136. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +16 -0
  137. package/lib/typescript/src/web/templates/MarketRowRenderer.d.ts +30 -0
  138. package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +15 -0
  139. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +44 -0
  140. package/lib/typescript/src/web/templates/MetricCardRowRenderer.d.ts +15 -0
  141. package/lib/typescript/src/web/templates/RailRowRenderer.d.ts +28 -0
  142. package/lib/typescript/src/web/templates/RowContainerStyle.d.ts +9 -0
  143. package/lib/typescript/src/web/templates/RowElements.d.ts +38 -0
  144. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +83 -0
  145. package/lib/typescript/src/web/templates/RowText.d.ts +9 -0
  146. package/lib/typescript/src/web/templates/RowVisual.d.ts +20 -0
  147. package/lib/typescript/src/web/templates/SectionHeaderRowRenderer.d.ts +15 -0
  148. package/lib/typescript/src/web/templates/SystemRowRenderer.d.ts +16 -0
  149. package/lib/typescript/src/web/templates/WalletGroupRowRenderer.d.ts +20 -0
  150. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
  151. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +39 -3
  152. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +6 -0
  153. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +15 -0
  154. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_bool.kt +78 -0
  155. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +26 -0
  156. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +24 -9
  157. package/nitrogen/generated/android/nativelistOnLoad.cpp +2 -0
  158. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +8 -0
  159. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +37 -0
  160. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +23 -2
  161. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +32 -0
  162. package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  163. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +3 -0
  164. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +54 -0
  165. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +6 -0
  166. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +8 -2
  167. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +6 -0
  168. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +11 -2
  169. package/nitrogen/generated/shared/json/NativeListConfig.json +3 -0
  170. package/package.json +7 -6
  171. package/react-native-native-list.podspec +6 -0
  172. package/scripts/enable-container-slots.mjs +58 -0
  173. package/scripts/enable-container-slots.test.mjs +58 -0
  174. package/src/NativeList.nitro.ts +3 -0
  175. package/src/NativeList.tsx +84 -2
  176. package/src/NativeList.types.ts +14 -1
  177. package/src/NativeList.web.tsx +5 -0
  178. package/src/models.ts +320 -20
  179. package/src/validation.ts +641 -49
  180. package/src/web/NativeListWebEngine.ts +361 -1932
  181. package/src/web/templates/ActionRowRenderer.ts +123 -0
  182. package/src/web/templates/ActivityRowRenderer.ts +159 -0
  183. package/src/web/templates/DataRowRenderer.ts +212 -0
  184. package/src/web/templates/IdentityRowRenderer.ts +527 -0
  185. package/src/web/templates/MarketRowRenderer.ts +467 -0
  186. package/src/web/templates/MediaTileRowRenderer.ts +182 -0
  187. package/src/web/templates/MessageRowRenderer.ts +306 -0
  188. package/src/web/templates/MetricCardRowRenderer.ts +337 -0
  189. package/src/web/templates/RailRowRenderer.ts +136 -0
  190. package/src/web/templates/RowContainerStyle.ts +131 -0
  191. package/src/web/templates/RowElements.ts +160 -0
  192. package/src/web/templates/RowRendererRegistry.ts +111 -0
  193. package/src/web/templates/RowText.ts +181 -0
  194. package/src/web/templates/RowVisual.ts +115 -0
  195. package/src/web/templates/SectionHeaderRowRenderer.ts +243 -0
  196. package/src/web/templates/SystemRowRenderer.ts +282 -0
  197. package/src/web/templates/WalletGroupRowRenderer.ts +131 -0
  198. package/android/src/main/java/com/onekey/nativelist/NativeListRowView.kt +0 -4538
  199. package/ios/NativeListCell.swift +0 -4300
@@ -0,0 +1,108 @@
1
+ import UIKit
2
+
3
+ final class NativeListActionCell: NativeListRendererCell {
4
+ override class func measure(
5
+ _ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
6
+ ) -> CGFloat? {
7
+ return item.data.string("presentation") == "accountSelector"
8
+ ? 48 : item.data.dictionary("icon") == nil ? 44 : 60
9
+ }
10
+
11
+ private let visual = NativeListLeadingVisual(frame: .zero)
12
+ private let title = NativeListTextLabel()
13
+ private let accessories = NativeListAccessoryStack(frame: .zero)
14
+ private var visualWidth: NSLayoutConstraint!
15
+ private var visualHeight: NSLayoutConstraint!
16
+ override var assetFields: [String] { ["icon"] }
17
+
18
+ override init(frame: CGRect) {
19
+ super.init(frame: frame)
20
+ visual.glyphSize = 24
21
+ root.axis = .horizontal
22
+ root.alignment = .center
23
+ [visual, title, accessories].forEach(root.addArrangedSubview)
24
+ visual.translatesAutoresizingMaskIntoConstraints = false
25
+ visualWidth = visual.widthAnchor.constraint(equalToConstant: 40)
26
+ visualHeight = visual.heightAnchor.constraint(equalToConstant: 40)
27
+ NSLayoutConstraint.activate([visualWidth, visualHeight])
28
+ title.setContentHuggingPriority(UILayoutPriority(1), for: .horizontal)
29
+ title.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
30
+ accessories.onAction = { [weak self] key, view, slot, target in
31
+ self?.emitAction(
32
+ key, from: view, source: "trailingAccessory", slot: slot, target: target,
33
+ anchorInset: self?.accessories.anchorInset(for: view) ?? 0)
34
+ }
35
+ }
36
+ required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
37
+ override func bindContent(
38
+ _ item: NativeListItem, theme: [String: Any]?, layout: String,
39
+ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
40
+ ) {
41
+ let style = item.data.dictionary("style") ?? [:]
42
+ root.alignment =
43
+ style.dictionary("container")?.string("contentVerticalAlignment") == "top"
44
+ ? .top
45
+ : style.dictionary("container")?.string("contentVerticalAlignment") == "bottom"
46
+ ? .bottom : .center
47
+ let selector = item.data.string("presentation") == "accountSelector"
48
+ let icon = item.data.dictionary("icon")
49
+ let descriptors =
50
+ item.data.dictionary("checkbox").map { checkbox -> [[String: Any]] in
51
+ var checkbox = checkbox
52
+ if checkbox["kind"] == nil { checkbox["kind"] = "checkbox" }
53
+ return [checkbox]
54
+ } ?? item.data.dictionaries("trailing")
55
+ accessories.bind(
56
+ item, descriptors: descriptors, theme: theme, style: style, checkboxState: checkboxState)
57
+ let hp = CGFloat(style.double("horizontalPadding", default: layout == "table" ? 16 : 12))
58
+ let vp = CGFloat(style.double("verticalPadding", default: 8))
59
+ let end =
60
+ descriptors.count == 1 && descriptors[0].string("kind") == "chevron"
61
+ ? 6 : accessories.endInset ?? hp
62
+ contentInsets = UIEdgeInsets(
63
+ top: vp, left: hp, bottom: vp, right: style["horizontalPadding"] == nil ? end : hp)
64
+ root.spacing = 12
65
+ root.setCustomSpacing(CGFloat(style.double("leadingGap", default: 12)), after: visual)
66
+ root.setCustomSpacing(accessories.contentGap ?? 12, after: title)
67
+ let tone = item.data.string("tone")
68
+ let color =
69
+ selector
70
+ ? nativeListColor(
71
+ theme, tone == "primary" ? "primaryText" : "secondaryText",
72
+ tone == "primary" ? "#202020" : "#646464")
73
+ : nativeListColor(
74
+ theme, tone == "danger" ? "negative" : "primaryText",
75
+ tone == "danger" ? "#CE2C31" : "#202020")
76
+ NativeListResolvedText(
77
+ item.data.string("title"), style: style.dictionary("title"), size: 16,
78
+ weight: selector && icon == nil ? .regular : .medium, color: color, lineHeight: 24, lines: 1
79
+ ).bind(title)
80
+ visual.isHidden = icon == nil
81
+ if var icon {
82
+ // Legacy kept the icon hairline border unless the selector or a transparent default
83
+ // background (no explicit backgroundColor) removed it.
84
+ let keepsBorder = !selector && icon["backgroundColor"] != nil
85
+ if icon["backgroundColor"] == nil { icon["backgroundColor"] = "#00000000" }
86
+ var image = style.dictionary("image") ?? [:]
87
+ if selector && image["cornerRadius"] == nil && image["shape"] == nil {
88
+ image["cornerRadius"] = 8
89
+ }
90
+ visualWidth.constant = CGFloat(image.double("width", default: selector ? 32 : 40))
91
+ visualHeight.constant = CGFloat(image.double("height", default: selector ? 32 : 40))
92
+ visual.bind(icon, style: image, key: item.key, theme: theme, isUnread: false)
93
+ if !keepsBorder { visual.layer.borderWidth = 0 }
94
+ } else {
95
+ visual.recycle()
96
+ }
97
+ }
98
+ override func bindSelectionContent(
99
+ _ item: NativeListItem,
100
+ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
101
+ ) {
102
+ accessories.updateSelection(item, checkboxState: checkboxState)
103
+ }
104
+ override func recycleContent() {
105
+ visual.recycle()
106
+ accessories.reset()
107
+ }
108
+ }
@@ -0,0 +1,291 @@
1
+ import UIKit
2
+
3
+ /// The activity template's bounded rich presentation; all values are caller-formatted.
4
+ final class NativeListActivityDetailsView: UIStackView {
5
+ var onAction: ((String, UIView, String, Int) -> Void)?
6
+ private let main = UIStackView()
7
+ private let visual = NativeListLeadingVisual()
8
+ private let identity = UIStackView()
9
+ private let titleLine = UIStackView()
10
+ private let title = NativeListTextLabel()
11
+ private let descriptionLabel = NativeListTextLabel()
12
+ private let status = NativeListTextLabel()
13
+ private let amounts = UIStackView()
14
+ private let fee = UIStackView()
15
+ private let feeLabel = NativeListTextLabel()
16
+ private let feeLine = UIStackView()
17
+ private let feePrimary = NativeListTextLabel()
18
+ private let feeSecondary = NativeListTextLabel()
19
+ private let actions = UIStackView()
20
+ private var amountViews: [NativeListActivityAmountView] = []
21
+ private var badgeViews: [NativeListTextLabel] = []
22
+ private var buttons: [UIButton] = []
23
+ private var actionKeys: [String] = []
24
+ private var descriptionKey = ""
25
+ private var dimensions: [NSLayoutConstraint] = []
26
+
27
+ override init(frame: CGRect) {
28
+ super.init(frame: frame)
29
+ axis = .vertical; alignment = .fill; spacing = 8
30
+ main.axis = .horizontal; main.alignment = .center; main.spacing = 12
31
+ identity.axis = .vertical; identity.alignment = .fill
32
+ titleLine.axis = .horizontal; titleLine.alignment = .center; titleLine.spacing = 4
33
+ titleLine.addArrangedSubview(title)
34
+ [titleLine, descriptionLabel, status].forEach(identity.addArrangedSubview)
35
+ amounts.axis = .vertical; amounts.alignment = .fill; amounts.spacing = 2
36
+ fee.axis = .vertical; fee.alignment = .trailing
37
+ feeLine.axis = .horizontal; feeLine.spacing = 4
38
+ [feePrimary, feeSecondary].forEach(feeLine.addArrangedSubview)
39
+ [feeLabel, feeLine].forEach(fee.addArrangedSubview)
40
+ [visual, identity, amounts, fee].forEach(main.addArrangedSubview)
41
+ [main, actions].forEach(addArrangedSubview)
42
+ actions.axis = .horizontal; actions.alignment = .leading; actions.spacing = 8
43
+ actions.isLayoutMarginsRelativeArrangement = true
44
+ descriptionLabel.isUserInteractionEnabled = true
45
+ descriptionLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(descriptionPressed)))
46
+ title.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
47
+ identity.setContentHuggingPriority(.defaultLow, for: .horizontal)
48
+ amounts.setContentHuggingPriority(.defaultHigh, for: .horizontal)
49
+ }
50
+ required init(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
51
+
52
+ private static let sizingButton: UIButton = {
53
+ let button = UIButton(type: .system)
54
+ button.titleLabel?.font = nativeListFont(ofSize: 14, weight: .medium)
55
+ button.contentEdgeInsets = UIEdgeInsets(top: 4, left: 8, bottom: 4, right: 8)
56
+ return button
57
+ }()
58
+
59
+ /// Mirrors bind(): the same resolved texts, stack spacings and column widths, so the
60
+ /// automatic height matches the rendered stacks.
61
+ static func measure(_ data: [String: Any], width: CGFloat) -> CGFloat {
62
+ let style = data.dictionary("style") ?? [:]
63
+ let table = data.string("presentation") == "table"
64
+ let image = style.dictionary("image") ?? [:]
65
+ let horizontalPadding = CGFloat(style.double("horizontalPadding", default: table ? 16 : 12))
66
+ let verticalPadding = CGFloat(style.double("verticalPadding", default: 8))
67
+ let lineGap = CGFloat(style.double("lineGap"))
68
+ let gap = CGFloat(style.double("leadingGap", default: 12))
69
+ let imageWidth = CGFloat(image.double("width", default: 40))
70
+ let imageHeight = CGFloat(image.double("height", default: 40))
71
+ let mainWidth = max(0, width - horizontalPadding * 2)
72
+
73
+ let amounts = data.dictionaries("amounts").map { amount -> (width: CGFloat, height: CGFloat) in
74
+ let primary = NativeListResolvedText(amount.string("text"), style: style.dictionary("primaryAmount"),
75
+ size: 16, weight: .medium, color: .label, lineHeight: 24, lines: 1, tabular: true)
76
+ let secondary = NativeListResolvedText(amount.string("secondaryText"), style: style.dictionary("secondaryAmount"),
77
+ size: 14, color: .label, lineHeight: 20, lines: 1)
78
+ let visual: CGFloat = amount.dictionary("leading") == nil ? 0 : 20
79
+ return (
80
+ (visual > 0 ? visual + 6 : 0) + max(primary.measureWidth(), secondary.measureWidth()),
81
+ max(visual, primary.measure(width: .greatestFiniteMagnitude) + secondary.measure(width: .greatestFiniteMagnitude))
82
+ )
83
+ }
84
+ let amountsGap = CGFloat(style.double("trailingGap", default: 2))
85
+ let amountsHeight = amounts.reduce(CGFloat(0)) { $0 + $1.height } + CGFloat(max(0, amounts.count - 1)) * amountsGap
86
+ let amountsWidth = amounts.map(\.width).max() ?? 0
87
+
88
+ var feeWidth: CGFloat = 0
89
+ var feeHeight: CGFloat = 0
90
+ if let feeData = data.dictionary("fee") {
91
+ let secondaryStyle = style.dictionary("secondaryAmount")
92
+ let label = NativeListResolvedText(feeData.string("label"), style: secondaryStyle, size: 12, color: .label, lineHeight: 16, lines: 1)
93
+ let primary = NativeListResolvedText(feeData.string("primary"), style: secondaryStyle, size: 14, color: .label, lineHeight: 20, lines: 1)
94
+ let secondary = NativeListResolvedText(feeData.string("secondary"), style: secondaryStyle, size: 12, color: .label, lineHeight: 16, lines: 1)
95
+ let lineWidth = primary.measureWidth() + secondary.measureWidth() +
96
+ (primary.text.isEmpty || secondary.text.isEmpty ? 0 : 4)
97
+ feeWidth = max(label.measureWidth(), lineWidth)
98
+ feeHeight = label.measure(width: .greatestFiniteMagnitude) +
99
+ max(primary.measure(width: .greatestFiniteMagnitude), secondary.measure(width: .greatestFiniteMagnitude))
100
+ }
101
+ let feeColumn = data.dictionary("fee") == nil ? 0 : gap + feeWidth
102
+ let identityWidth: CGFloat
103
+ if table {
104
+ let shared = (mainWidth - imageWidth - gap * 2 - feeColumn) / 2
105
+ identityWidth = min(mainWidth * 0.42, shared)
106
+ } else {
107
+ identityWidth = mainWidth - imageWidth - gap * 2 - feeColumn - min(amountsWidth, mainWidth * 0.5)
108
+ }
109
+
110
+ let title = NativeListResolvedText(data.string("title"), style: style.dictionary("title"), size: 16,
111
+ weight: .medium, color: .label, lineHeight: 24, lines: 1)
112
+ let titleHeight = max(
113
+ title.measure(width: .greatestFiniteMagnitude),
114
+ data.dictionaries("badges").isEmpty ? 0 : 16)
115
+ let description = NativeListResolvedText(data.string("description"), style: style.dictionary("description"),
116
+ size: 14, color: .label, lineHeight: 20, lines: 2)
117
+ let status = NativeListResolvedText(data.string("status"), style: style.dictionary("status"),
118
+ size: 12, color: .label, lineHeight: 16, lines: 1)
119
+ var identityHeight = titleHeight
120
+ for text in [description, status] where !text.text.isEmpty {
121
+ identityHeight += lineGap + text.measure(width: max(1, identityWidth))
122
+ }
123
+
124
+ var actionsHeight: CGFloat = 0
125
+ let actions = data.dictionaries("footerActions")
126
+ if !actions.isEmpty {
127
+ actionsHeight = actions.reduce(CGFloat(0)) { height, action in
128
+ sizingButton.setTitle(action.string("label"), for: .normal)
129
+ return max(height, ceil(sizingButton.intrinsicContentSize.height))
130
+ } + 8
131
+ }
132
+ return max(imageHeight, identityHeight, amountsHeight, feeHeight) + actionsHeight + verticalPadding * 2
133
+ }
134
+
135
+ func bind(_ item: NativeListItem, theme: [String: Any]?) {
136
+ let data = item.data
137
+ let style = data.dictionary("style") ?? [:]
138
+ let image = style.dictionary("image") ?? [:]
139
+ let table = data.string("presentation") == "table"
140
+ let gap = CGFloat(style.double("leadingGap", default: 12))
141
+ main.spacing = gap
142
+ identity.spacing = CGFloat(style.double("lineGap"))
143
+ amounts.spacing = CGFloat(style.double("trailingGap", default: 2))
144
+ titleLine.spacing = CGFloat(style.double("titleBadgeGap", default: 4))
145
+ NSLayoutConstraint.deactivate(dimensions)
146
+ dimensions = [
147
+ visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40))),
148
+ visual.heightAnchor.constraint(equalToConstant: CGFloat(image.double("height", default: 40))),
149
+ amounts.widthAnchor.constraint(lessThanOrEqualTo: main.widthAnchor, multiplier: table ? 0.42 : 0.5),
150
+ ]
151
+ if table { dimensions.append(amounts.widthAnchor.constraint(equalTo: identity.widthAnchor)) }
152
+ NSLayoutConstraint.activate(dimensions)
153
+ visual.bind(data.dictionary("leading") ?? [:], style: image, key: item.key, theme: theme,
154
+ isUnread: false, secondaryVisual: data.dictionary("secondaryLeading"))
155
+ NativeListResolvedText(data.string("title"), style: style.dictionary("title"), size: 16,
156
+ weight: .medium, color: nativeListColor(theme, "primaryText", "#202020"), lineHeight: 24, lines: 1).bind(title)
157
+ NativeListResolvedText(data.string("description"), style: style.dictionary("description"), size: 14,
158
+ color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 20, lines: 2).bind(descriptionLabel)
159
+ NativeListResolvedText(data.string("status"), style: style.dictionary("status"), size: 12,
160
+ color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 16, lines: 1).bind(status)
161
+ descriptionKey = data.string("descriptionActionKey")
162
+ descriptionLabel.isUserInteractionEnabled = !descriptionKey.isEmpty
163
+ descriptionLabel.accessibilityTraits = descriptionKey.isEmpty ? .staticText : .button
164
+ for badge in badgeViews { titleLine.removeArrangedSubview(badge); badge.removeFromSuperview() }
165
+ badgeViews = data.dictionaries("badges").map { descriptor in
166
+ let label = NativeListTextLabel()
167
+ let tone = descriptor.string("tone")
168
+ let tint = nativeListActivityTone(tone, theme: theme)
169
+ NativeListResolvedText(" \(descriptor.string("text")) ", style: nil, size: 12,
170
+ weight: .medium, color: tint, lineHeight: 16, lines: 1).bind(label)
171
+ label.backgroundColor = tint.withAlphaComponent(0.1)
172
+ label.layer.cornerRadius = 4; label.clipsToBounds = true
173
+ label.setContentCompressionResistancePriority(.required, for: .horizontal)
174
+ titleLine.addArrangedSubview(label)
175
+ return label
176
+ }
177
+ let descriptors = data.dictionaries("amounts")
178
+ while amountViews.count > descriptors.count {
179
+ let view = amountViews.removeLast(); view.recycle(); amounts.removeArrangedSubview(view); view.removeFromSuperview()
180
+ }
181
+ while amountViews.count < descriptors.count {
182
+ let view = NativeListActivityAmountView(); amountViews.append(view); amounts.addArrangedSubview(view)
183
+ }
184
+ for (index, descriptor) in descriptors.enumerated() {
185
+ amountViews[index].bind(descriptor, key: "\(item.key):\(descriptor.string("key"))", style: style, theme: theme, table: table)
186
+ }
187
+ let feeData = data.dictionary("fee")
188
+ fee.isHidden = feeData == nil
189
+ fee.alpha = feeData?.bool("hidden") == true ? 0 : 1
190
+ NativeListResolvedText(feeData?.string("label") ?? "", style: style.dictionary("secondaryAmount"),
191
+ size: 12, color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 16, lines: 1).bind(feeLabel)
192
+ NativeListResolvedText(feeData?.string("primary") ?? "", style: style.dictionary("secondaryAmount"),
193
+ size: 14, color: nativeListColor(theme, "primaryText", "#202020"), lineHeight: 20, lines: 1).bind(feePrimary)
194
+ NativeListResolvedText(feeData?.string("secondary") ?? "", style: style.dictionary("secondaryAmount"),
195
+ size: 12, color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 16, lines: 1).bind(feeSecondary)
196
+ for button in buttons { actions.removeArrangedSubview(button); button.removeFromSuperview() }
197
+ buttons = []
198
+ nativeListActivitySegments(feePrimary, feeData?.dictionaries("primaryTextSegments") ?? [])
199
+ nativeListActivitySegments(feeSecondary, feeData?.dictionaries("secondaryTextSegments") ?? [])
200
+ let actionData = data.dictionaries("footerActions")
201
+ actionKeys = actionData.map { $0.string("key") }
202
+ actions.isHidden = actionData.isEmpty
203
+ actions.directionalLayoutMargins = NSDirectionalEdgeInsets(top: 0, leading: CGFloat(image.double("width", default: 40)) + gap, bottom: 0, trailing: 0)
204
+ for (index, descriptor) in actionData.enumerated() {
205
+ let button = UIButton(type: .system); button.tag = index
206
+ button.setTitle(descriptor.string("label"), for: .normal)
207
+ button.titleLabel?.font = nativeListFont(ofSize: 14, weight: .medium)
208
+ button.setTitleColor(nativeListActivityTone(descriptor.string("tone"), theme: theme), for: .normal)
209
+ button.backgroundColor = nativeListColor(theme, "strongBackground", "#F0F0F0")
210
+ button.layer.cornerRadius = 8
211
+ button.contentEdgeInsets = UIEdgeInsets(top: 4, left: 8, bottom: 4, right: 8)
212
+ button.isEnabled = !data.bool("disabled") && !descriptor.bool("disabled")
213
+ button.addTarget(self, action: #selector(actionPressed(_:)), for: .touchUpInside)
214
+ buttons.append(button); actions.addArrangedSubview(button)
215
+ }
216
+ let spacer = UIView(); spacer.setContentHuggingPriority(.defaultLow, for: .horizontal)
217
+ // The last flexible spacer is separate from the fixed action buttons.
218
+ actions.arrangedSubviews.filter { !($0 is UIButton) }.forEach { actions.removeArrangedSubview($0); $0.removeFromSuperview() }
219
+ actions.addArrangedSubview(spacer)
220
+ }
221
+ @objc private func descriptionPressed() { onAction?(descriptionKey, descriptionLabel, "description", 0) }
222
+ @objc private func actionPressed(_ button: UIButton) {
223
+ guard button.tag < actionKeys.count else { return }
224
+ onAction?(actionKeys[button.tag], button, "footerAction", button.tag)
225
+ }
226
+ func recycle() {
227
+ visual.recycle(); amountViews.forEach { $0.recycle() }; actionKeys = []; descriptionKey = ""
228
+ }
229
+ }
230
+
231
+ private func nativeListActivityTone(_ tone: String, theme: [String: Any]?) -> UIColor {
232
+ switch tone {
233
+ case "positive", "success": return nativeListColor(theme, "positive", "#218358")
234
+ case "negative", "danger": return nativeListColor(theme, "negative", "#CE2C31")
235
+ case "secondary": return nativeListColor(theme, "secondaryText", "#646464")
236
+ case "warning": return nativeListColor(theme, "warning", "#AB6400")
237
+ case "info": return nativeListColor(theme, "info", "#007BEF")
238
+ default: return nativeListColor(theme, "primaryText", "#202020")
239
+ }
240
+ }
241
+
242
+ private final class NativeListActivityAmountView: UIStackView {
243
+ private let visual = NativeListLeadingVisual()
244
+ private let labels = UIStackView()
245
+ private let primary = NativeListTextLabel()
246
+ private let secondary = NativeListTextLabel()
247
+ override init(frame: CGRect) {
248
+ super.init(frame: frame)
249
+ axis = .horizontal; alignment = .center; spacing = 6
250
+ labels.axis = .vertical; labels.alignment = .fill
251
+ [primary, secondary].forEach(labels.addArrangedSubview)
252
+ [visual, labels].forEach(addArrangedSubview)
253
+ NSLayoutConstraint.activate([visual.widthAnchor.constraint(equalToConstant: 20), visual.heightAnchor.constraint(equalToConstant: 20)])
254
+ }
255
+ required init(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
256
+ func bind(_ data: [String: Any], key: String, style: [String: Any], theme: [String: Any]?, table: Bool) {
257
+ let leading = data.dictionary("leading")
258
+ visual.isHidden = leading == nil
259
+ if let leading { visual.bind(leading, style: ["width": 20, "height": 20], key: key, theme: theme, isUnread: false) } else { visual.recycle() }
260
+ var primaryStyle = style.dictionary("primaryAmount") ?? [:]
261
+ if primaryStyle["alignment"] == nil { primaryStyle["alignment"] = table ? "start" : "end" }
262
+ let resolved = NativeListResolvedText(data.string("text"), style: primaryStyle, size: 16,
263
+ weight: .medium, color: nativeListActivityTone(data.string("tone"), theme: theme), lineHeight: 24, lines: 1, tabular: true)
264
+ resolved.bind(primary)
265
+ nativeListActivitySegments(primary, data.dictionaries("textSegments"))
266
+ var secondaryStyle = style.dictionary("secondaryAmount") ?? [:]
267
+ if secondaryStyle["alignment"] == nil { secondaryStyle["alignment"] = table ? "start" : "end" }
268
+ NativeListResolvedText(data.string("secondaryText"), style: secondaryStyle, size: 14,
269
+ color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 20, lines: 1).bind(secondary)
270
+ nativeListActivitySegments(secondary, data.dictionaries("secondaryTextSegments"))
271
+ }
272
+ func recycle() { visual.recycle() }
273
+ }
274
+
275
+ private func nativeListActivitySegments(_ label: NativeListTextLabel, _ segments: [[String: Any]]) {
276
+ guard !segments.isEmpty else { return }
277
+ let text = segments.map { $0.string("text") }.joined()
278
+ let attributes = (label.attributedText?.length ?? 0) > 0
279
+ ? label.attributedText!.attributes(at: 0, effectiveRange: nil)
280
+ : [.font: label.font as Any, .foregroundColor: label.textColor as Any]
281
+ let value = NSMutableAttributedString(string: text, attributes: attributes)
282
+ var offset = 0
283
+ for segment in segments {
284
+ let length = (segment.string("text") as NSString).length
285
+ if segment.string("style") == "subscript" {
286
+ value.addAttributes([.font: label.font.withSize(ceil(label.font.pointSize * 0.6))], range: NSRange(location: offset, length: length))
287
+ }
288
+ offset += length
289
+ }
290
+ label.attributedText = value
291
+ }
@@ -0,0 +1,201 @@
1
+ import UIKit
2
+
3
+ final class NativeListActivityCell: NativeListRendererCell {
4
+ override class func measure(
5
+ _ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
6
+ ) -> CGFloat? {
7
+ if item.data["amounts"] != nil { return NativeListActivityDetailsView.measure(item.data, width: width) }
8
+ return item.data.dictionaries("footerActions").isEmpty ? 60 : 100
9
+ }
10
+
11
+ private let details = NativeListActivityDetailsView()
12
+ private let visual = NativeListLeadingVisual()
13
+ private let column = UIStackView()
14
+ private let titleLine = UIStackView()
15
+ private let title = NativeListTextLabel()
16
+ private let descriptionLabel = NativeListTextLabel()
17
+ private let status = NativeListTextLabel()
18
+ private let failure = NativeListTextLabel()
19
+ private let amounts = UIStackView()
20
+ private let amountLabels = [
21
+ NativeListAccessoryButton(type: .system), NativeListAccessoryButton(type: .system),
22
+ ]
23
+ private let actions = UIStackView()
24
+ private let buttons = (0..<3).map { _ in UIButton(type: .system) }
25
+ private var actionKeys: [String] = []
26
+ private var dimensions: [NSLayoutConstraint] = []
27
+ override var assetFields: [String] { ["leading", "secondaryLeading", "amounts"] }
28
+
29
+ override init(frame: CGRect) {
30
+ super.init(frame: frame)
31
+ root.axis = .horizontal
32
+ column.axis = .vertical
33
+ column.alignment = .fill
34
+ column.setContentHuggingPriority(UILayoutPriority(1), for: .horizontal)
35
+ column.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
36
+ titleLine.axis = .horizontal
37
+ titleLine.alignment = .center
38
+ titleLine.spacing = 8
39
+ title.setContentCompressionResistancePriority(.required, for: .horizontal)
40
+ failure.setContentHuggingPriority(.required, for: .horizontal)
41
+ titleLine.addArrangedSubview(title)
42
+ titleLine.addArrangedSubview(failure)
43
+ [titleLine, descriptionLabel, status, actions].forEach(column.addArrangedSubview)
44
+ amounts.axis = .vertical
45
+ amounts.alignment = .trailing
46
+ amounts.setContentHuggingPriority(.required, for: .horizontal)
47
+ amounts.setContentCompressionResistancePriority(.required, for: .horizontal)
48
+ amountLabels.forEach {
49
+ amounts.addArrangedSubview($0)
50
+ // Legacy amounts keep their full width; the text column yields first.
51
+ $0.setContentHuggingPriority(.required, for: .horizontal)
52
+ $0.setContentCompressionResistancePriority(.required, for: .horizontal)
53
+ }
54
+ actions.axis = .horizontal
55
+ actions.alignment = .center
56
+ actions.spacing = 8
57
+ for (index, button) in buttons.enumerated() {
58
+ button.tag = index
59
+ button.titleLabel?.font = nativeListFont(ofSize: 12, weight: .medium)
60
+ button.layer.cornerRadius = 8
61
+ button.contentEdgeInsets = UIEdgeInsets(top: 4, left: 8, bottom: 4, right: 8)
62
+ button.addTarget(self, action: #selector(pressed(_:)), for: .touchUpInside)
63
+ actions.addArrangedSubview(button)
64
+ }
65
+ [visual, column, amounts, details].forEach(root.addArrangedSubview)
66
+ details.isHidden = true
67
+ details.onAction = { [weak self] key, view, source, slot in
68
+ self?.emitAction(key, from: view, source: source, slot: slot)
69
+ }
70
+ }
71
+ required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
72
+ override func bindContent(
73
+ _ item: NativeListItem, theme: [String: Any]?, layout: String,
74
+ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
75
+ ) {
76
+ let data = item.data
77
+ let rich = data["amounts"] != nil
78
+ details.isHidden = !rich
79
+ [visual, column, amounts].forEach { $0.isHidden = rich }
80
+ root.axis = rich ? .vertical : .horizontal
81
+ root.alignment = rich ? .fill : .center
82
+ if rich {
83
+ let style = data.dictionary("style") ?? [:]
84
+ let hp = CGFloat(style.double("horizontalPadding", default: data.string("presentation") == "table" ? 16 : 12))
85
+ let vp = CGFloat(style.double("verticalPadding", default: 8))
86
+ contentInsets = UIEdgeInsets(top: vp, left: hp, bottom: vp, right: hp)
87
+ visual.recycle()
88
+ details.bind(item, theme: theme)
89
+ return
90
+ }
91
+ details.recycle()
92
+ let style = data.dictionary("style") ?? [:]
93
+ let image = style.dictionary("image") ?? [:]
94
+ root.spacing = 12
95
+ root.setCustomSpacing(CGFloat(style.double("leadingGap", default: 12)), after: visual)
96
+ switch style.dictionary("container")?.string("contentVerticalAlignment") {
97
+ case "top": root.alignment = .top
98
+ case "bottom": root.alignment = .bottom
99
+ default: root.alignment = .center
100
+ }
101
+ column.spacing = CGFloat(style.double("lineGap"))
102
+ titleLine.spacing = CGFloat(style.double("titleBadgeGap", default: 8))
103
+ amounts.spacing = CGFloat(style.double("trailingGap", default: 2))
104
+ contentInsets = UIEdgeInsets(
105
+ top: CGFloat(style.double("verticalPadding", default: 8)),
106
+ left: CGFloat(style.double("horizontalPadding", default: layout == "table" ? 16 : 12)),
107
+ bottom: CGFloat(style.double("verticalPadding", default: 8)),
108
+ right: CGFloat(style.double("horizontalPadding", default: layout == "table" ? 16 : 12)))
109
+ NSLayoutConstraint.deactivate(dimensions)
110
+ dimensions = [
111
+ visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40))),
112
+ visual.heightAnchor.constraint(equalToConstant: CGFloat(image.double("height", default: 40))),
113
+ ]
114
+ NSLayoutConstraint.activate(dimensions)
115
+ if let leading = data.dictionary("leading") {
116
+ visual.bind(
117
+ leading, style: image, key: item.key, theme: theme, isUnread: false,
118
+ secondaryVisual: data.dictionary("secondaryLeading"))
119
+ } else {
120
+ // Legacy kept an empty leading slot (no placeholder disc) when no visual was given.
121
+ visual.clear()
122
+ }
123
+ func bind(
124
+ _ view: NativeListTextLabel, _ value: String, _ slot: String, size: CGFloat,
125
+ weight: NativeListFontWeight = .regular, color: UIColor, line: CGFloat, lines: Int = 1
126
+ ) {
127
+ NativeListResolvedText(
128
+ value, style: style.dictionary(slot), size: size, weight: weight, color: color,
129
+ lineHeight: line, lines: lines
130
+ ).bind(view)
131
+ }
132
+ bind(
133
+ title, data.string("title"), "title", size: 16, weight: .medium,
134
+ color: nativeListColor(theme, "primaryText", "#202020"), line: 24)
135
+ bind(
136
+ descriptionLabel, data.string("description"), "description", size: 14,
137
+ color: nativeListColor(theme, "secondaryText", "#646464"), line: 20, lines: 2)
138
+ let failed = data.string("status") == "Failed"
139
+ bind(
140
+ status, failed ? "" : data.string("status"), "status", size: 12,
141
+ color: nativeListColor(theme, "secondaryText", "#646464"),
142
+ line: nativeListFont(ofSize: 12).lineHeight)
143
+ bind(
144
+ failure, failed ? " Failed " : "", "status", size: 12, weight: .medium,
145
+ color: nativeListColor(theme, "negative", "#CE2C31"),
146
+ line: nativeListFont(ofSize: 12, weight: .medium).lineHeight)
147
+ failure.backgroundColor = nativeListColor(theme, "criticalBackground", "#F3000D14")
148
+ failure.layer.cornerRadius = 4
149
+ failure.clipsToBounds = true
150
+ for (index, slot) in ["primaryAmount", "secondaryAmount"].enumerated() {
151
+ let button = amountLabels[index]
152
+ let value = data.string(slot)
153
+ let color =
154
+ index == 0
155
+ ? nativeListColor(
156
+ theme, value.hasPrefix("+") ? "positive" : "primaryText",
157
+ value.hasPrefix("+") ? "#218358" : "#202020")
158
+ : nativeListColor(theme, "secondaryText", "#646464")
159
+ button.titleLabel?.numberOfLines = 1
160
+ button.titleLabel?.lineBreakMode = .byTruncatingTail
161
+ button.contentHorizontalAlignment = .center
162
+ button.contentVerticalAlignment = .center
163
+ button.rowTextOffsetY = 0
164
+ let resolved = NativeListResolvedText(
165
+ value, style: nil, size: index == 0 ? 16 : 14, weight: index == 0 ? .medium : .regular,
166
+ color: color, lineHeight: index == 0 ? 24 : 20, lines: 1, tabular: true)
167
+ button.setAttributedTitle(
168
+ resolved.attributed(direction: button.effectiveUserInterfaceLayoutDirection), for: .normal)
169
+ button.titleLabel?.font = resolved.font
170
+ button.isHidden = value.isEmpty
171
+ if let text = style.dictionary(slot) { NativeListTextStyles.applyStyledButton(button, text) }
172
+ }
173
+ let descriptors = Array(data.dictionaries("footerActions").prefix(3))
174
+ actions.isHidden = descriptors.isEmpty
175
+ actionKeys = descriptors.map { $0.string("key") }
176
+ for (index, button) in buttons.enumerated() {
177
+ button.isHidden = index >= descriptors.count
178
+ guard index < descriptors.count else { continue }
179
+ let action = descriptors[index]
180
+ button.setTitle(action.string("label"), for: .normal)
181
+ // Legacy: only the action's own flag disables it; a disabled row is already dimmed
182
+ // and non-interactive as a whole.
183
+ button.isEnabled = !action.bool("disabled")
184
+ button.backgroundColor = nativeListColor(theme, "strongBackground", "#F0F0F0")
185
+ button.setTitleColor(
186
+ nativeListColor(
187
+ theme, action.string("tone") == "danger" ? "negative" : "primaryText",
188
+ action.string("tone") == "danger" ? "#CE2C31" : "#202020"), for: .normal)
189
+ }
190
+ }
191
+ @objc private func pressed(_ button: UIButton) {
192
+ guard button.tag < actionKeys.count else { return }
193
+ emitAction(actionKeys[button.tag], from: button, source: "footerAction", slot: button.tag)
194
+ }
195
+ override func recycleContent() {
196
+ visual.recycle()
197
+ details.recycle()
198
+ actionKeys = []
199
+ buttons.forEach { $0.isHidden = true }
200
+ }
201
+ }