@onekeyfe/react-native-native-list 6.7.0-2 → 6.7.0-20

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 (144) hide show
  1. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
  2. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +245 -9
  3. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +7 -4
  4. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +29 -3
  5. package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
  6. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
  7. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +87 -7
  8. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +193 -10
  9. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +147 -33
  10. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +145 -2
  12. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +51 -0
  13. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
  14. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
  16. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
  17. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
  18. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1920 -109
  19. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +29 -0
  20. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
  21. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
  22. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
  23. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
  24. package/docs/ROW_TEMPLATES.md +60 -9
  25. package/docs/SPEC.md +1004 -17
  26. package/docs/STYLE_SPEC.md +6 -0
  27. package/ios/HybridNativeList.swift +21 -2
  28. package/ios/NativeListAccessoryStack.swift +235 -39
  29. package/ios/NativeListActivityDetailsView.swift +18 -8
  30. package/ios/NativeListActivityRenderer.swift +8 -2
  31. package/ios/NativeListButtonGroupRenderer.swift +89 -0
  32. package/ios/NativeListDataRowRenderer.swift +155 -27
  33. package/ios/NativeListDesignAssets.swift +9 -0
  34. package/ios/NativeListIdentityRenderer.swift +191 -30
  35. package/ios/NativeListLeadingVisual.swift +119 -22
  36. package/ios/NativeListMessageRenderer.swift +34 -1
  37. package/ios/NativeListModels.swift +42 -2
  38. package/ios/NativeListRendererRegistry.swift +1 -0
  39. package/ios/NativeListResolvedText.swift +2 -1
  40. package/ios/NativeListRowHost.swift +14 -0
  41. package/ios/NativeListSectionHeaderRenderer.swift +88 -0
  42. package/ios/RNCNativeListView.swift +1031 -55
  43. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
  44. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
  45. package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/Contents.json +1 -0
  46. package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/icon.svg +1 -0
  47. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/Contents.json +1 -0
  48. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/icon.svg +1 -0
  49. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
  50. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
  51. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/Contents.json +1 -0
  52. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/icon.svg +1 -0
  53. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
  54. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
  55. package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/Contents.json +1 -0
  56. package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/icon.svg +1 -0
  57. package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/Contents.json +1 -0
  58. package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/icon.svg +1 -0
  59. package/ios/tests/NativeListAccessoryStackTests.swift +89 -0
  60. package/ios/tests/NativeListActivityPresentationTests.swift +56 -0
  61. package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
  62. package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
  63. package/ios/tests/NativeListLifecycleTests.swift +2720 -3
  64. package/lib/module/NativeList.js +200 -32
  65. package/lib/module/NativeList.web.js +262 -32
  66. package/lib/module/index.js +1 -1
  67. package/lib/module/models.js +1 -0
  68. package/lib/module/selection.js +1 -1
  69. package/lib/module/validation.js +776 -52
  70. package/lib/module/web/NativeListWebEngine.js +919 -79
  71. package/lib/module/web/templates/ActivityRowRenderer.js +487 -7
  72. package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
  73. package/lib/module/web/templates/DataRowRenderer.js +40 -5
  74. package/lib/module/web/templates/IdentityRowRenderer.js +90 -4
  75. package/lib/module/web/templates/MarketRowRenderer.js +8 -3
  76. package/lib/module/web/templates/MarketTableRowRenderer.js +577 -0
  77. package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
  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 +8 -3
  81. package/lib/module/web/templates/SectionHeaderRowRenderer.js +70 -3
  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 +29 -1
  98. package/lib/typescript/src/NativeList.web.d.ts +2 -2
  99. package/lib/typescript/src/index.d.ts +2 -2
  100. package/lib/typescript/src/models.d.ts +176 -10
  101. package/lib/typescript/src/validation.d.ts +15 -0
  102. package/lib/typescript/src/web/NativeListWebEngine.d.ts +58 -1
  103. package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
  104. package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
  105. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
  106. package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
  107. package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
  108. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +10 -4
  109. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
  110. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  111. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  112. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  113. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  114. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  115. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  116. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  117. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  118. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  119. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  120. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  121. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  122. package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  123. package/package.json +3 -3
  124. package/react-native-native-list.podspec +1 -0
  125. package/src/NativeList.nitro.ts +2 -0
  126. package/src/NativeList.tsx +391 -82
  127. package/src/NativeList.types.ts +34 -1
  128. package/src/NativeList.web.tsx +420 -65
  129. package/src/index.ts +2 -0
  130. package/src/models.ts +210 -3
  131. package/src/selection.ts +1 -0
  132. package/src/validation.ts +1635 -76
  133. package/src/web/NativeListWebEngine.ts +1476 -112
  134. package/src/web/templates/ActivityRowRenderer.ts +732 -8
  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 +150 -5
  138. package/src/web/templates/MarketRowRenderer.ts +19 -3
  139. package/src/web/templates/MarketTableRowRenderer.ts +755 -0
  140. package/src/web/templates/MediaTileRowRenderer.ts +313 -5
  141. package/src/web/templates/MessageRowRenderer.ts +23 -7
  142. package/src/web/templates/RowContainerStyle.ts +2 -0
  143. package/src/web/templates/RowRendererRegistry.ts +21 -6
  144. package/src/web/templates/SectionHeaderRowRenderer.ts +89 -5
@@ -0,0 +1,89 @@
1
+ import UIKit
2
+
3
+ final class NativeListButtonGroupCell: NativeListRendererCell {
4
+ override class func measure(
5
+ _ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String,
6
+ fonts: NativeListFontFamilies
7
+ ) -> CGFloat? { 64 }
8
+
9
+ private var buttons: [UIButton] = []
10
+ private var actionKeys: [String] = []
11
+ private var rowOpacity: CGFloat = 1
12
+
13
+ override func applyAppearance() {
14
+ super.applyAppearance()
15
+ contentView.alpha = rowOpacity
16
+ }
17
+
18
+ override init(frame: CGRect) {
19
+ super.init(frame: frame)
20
+ root.axis = .horizontal
21
+ root.alignment = .fill
22
+ root.distribution = .fillEqually
23
+ root.spacing = 10
24
+ }
25
+ required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
26
+
27
+ override func bindContent(
28
+ _ item: NativeListItem, theme: [String: Any]?, layout: String,
29
+ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
30
+ ) {
31
+ recycleContent()
32
+ rowOpacity = CGFloat(item.data.dictionary("style")?.dictionary("container")?.double("opacity", default: item.data.double("opacity", default: 1)) ?? item.data.double("opacity", default: 1))
33
+ contentInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0)
34
+ let info = nativeListColor(theme, "info", "#0F69F6")
35
+ for (index, descriptor) in item.data.dictionaries("buttons").enumerated() {
36
+ let button = NativeListAccessoryButton(type: .custom)
37
+ button.tag = index
38
+ button.setTitle(descriptor.string("label"), for: .normal)
39
+ button.titleLabel?.font = nativeListFont(ofSize: 14, weight: .medium, fonts: fonts)
40
+ button.titleLabel?.lineBreakMode = .byTruncatingTail
41
+ button.setTitleColor(info, for: .normal)
42
+ button.contentEdgeInsets = UIEdgeInsets(top: 12, left: 8, bottom: 12, right: 8)
43
+ button.layer.cornerRadius = 12
44
+ button.layer.borderWidth = 1
45
+ button.layer.borderColor = info.withAlphaComponent(0.35).cgColor
46
+ button.normalBackgroundColor = .clear
47
+ button.pressedBackgroundColor = info.withAlphaComponent(0.17)
48
+ button.isEnabled = !item.data.bool("disabled") && !descriptor.bool("disabled") && !descriptor.bool("loading")
49
+ button.alpha = button.isEnabled ? 1 : 0.4
50
+ button.accessibilityIdentifier = descriptor["testID"] as? String
51
+ button.accessibilityLabel = descriptor.string("accessibilityLabel", default: descriptor.string("label"))
52
+ button.addTarget(self, action: #selector(pressed(_:)), for: .touchUpInside)
53
+ if descriptor.bool("loading"), let titleLabel = button.titleLabel {
54
+ let spinner = UIActivityIndicatorView(style: .medium)
55
+ spinner.color = info
56
+ spinner.isUserInteractionEnabled = false
57
+ spinner.translatesAutoresizingMaskIntoConstraints = false
58
+ button.addSubview(spinner)
59
+ button.contentEdgeInsets = UIEdgeInsets(top: 12, left: 36, bottom: 12, right: 8)
60
+ NSLayoutConstraint.activate([
61
+ spinner.trailingAnchor.constraint(equalTo: titleLabel.leadingAnchor, constant: -8),
62
+ spinner.centerYAnchor.constraint(equalTo: button.centerYAnchor),
63
+ spinner.widthAnchor.constraint(equalToConstant: 20),
64
+ spinner.heightAnchor.constraint(equalToConstant: 20),
65
+ ])
66
+ spinner.startAnimating()
67
+ }
68
+ buttons.append(button)
69
+ actionKeys.append(descriptor.string("actionKey"))
70
+ root.addArrangedSubview(button)
71
+ }
72
+ }
73
+
74
+ @objc private func pressed(_ button: UIButton) {
75
+ guard button.isEnabled, buttons.indices.contains(button.tag), buttons[button.tag] === button else { return }
76
+ emitAction(actionKeys[button.tag], from: button, source: "buttonGroup", slot: button.tag)
77
+ }
78
+
79
+ override func recycleContent() {
80
+ for button in buttons {
81
+ button.removeTarget(self, action: nil, for: .allEvents)
82
+ button.subviews.compactMap { $0 as? UIActivityIndicatorView }.forEach { $0.stopAnimating() }
83
+ root.removeArrangedSubview(button)
84
+ button.removeFromSuperview()
85
+ }
86
+ buttons.removeAll()
87
+ actionKeys.removeAll()
88
+ }
89
+ }
@@ -6,7 +6,7 @@ final class NativeListDataRowCell: NativeListRendererCell {
6
6
  fonts: NativeListFontFamilies
7
7
  ) -> CGFloat? {
8
8
  let secondary = item.data.dictionaries("columns").contains {
9
- !$0.string("secondaryText").isEmpty
9
+ !nativeListDataColumnText($0, "secondaryText").isEmpty
10
10
  }
11
11
  return secondary ? 60 : layout == "table" ? 48 : 56
12
12
  }
@@ -14,9 +14,13 @@ final class NativeListDataRowCell: NativeListRendererCell {
14
14
  private let visual = NativeListLeadingVisual()
15
15
  private let favorite = UIImageView()
16
16
  private let accessories = NativeListAccessoryStack()
17
+ private let trailingAccessories = NativeListAccessoryStack()
17
18
  private let columns = UIStackView()
18
19
  private let cells = (0..<4).map { _ in NativeListTableColumnView() }
19
20
  private var rowConstraints: [NSLayoutConstraint] = []
21
+ private var trailingWidthConstraint: NSLayoutConstraint?
22
+ private var columnWidthConstraints: [NSLayoutConstraint] = []
23
+ private var columnWeights: [Int]?
20
24
  override func unselectedBackground(
21
25
  _ item: NativeListItem, theme: [String: Any]?, layout: String, itemIndex: Int?
22
26
  ) -> UIColor {
@@ -34,10 +38,13 @@ final class NativeListDataRowCell: NativeListRendererCell {
34
38
  columns.alignment = .center
35
39
  columns.spacing = 8
36
40
  cells.forEach(columns.addArrangedSubview)
37
- [favorite, visual, accessories, columns].forEach(root.addArrangedSubview)
41
+ [favorite, visual, accessories, columns, trailingAccessories].forEach(root.addArrangedSubview)
38
42
  accessories.onAction = { [weak self] key, view, slot, target in
39
43
  self?.emitAction(key, from: view, source: "trailingAccessory", slot: slot, target: target)
40
44
  }
45
+ trailingAccessories.onAction = { [weak self] key, view, slot, target in
46
+ self?.emitAction(key, from: view, source: "trailingAccessory", slot: slot, target: target)
47
+ }
41
48
  }
42
49
  required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
43
50
  override func bindContent(
@@ -86,16 +93,55 @@ final class NativeListDataRowCell: NativeListRendererCell {
86
93
  item, descriptors: descriptors, theme: theme, style: accessoryStyle,
87
94
  checkboxState: checkboxState, fonts: fonts)
88
95
  accessories.isHidden = descriptors.isEmpty
89
- NSLayoutConstraint.deactivate(rowConstraints)
90
- rowConstraints = [
91
- favorite.widthAnchor.constraint(equalToConstant: 20),
92
- favorite.heightAnchor.constraint(equalToConstant: 20),
93
- visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40))),
94
- visual.heightAnchor.constraint(equalToConstant: CGFloat(image.double("height", default: 40))),
95
- ]
96
+ let trailing = data.dictionaries("trailing")
97
+ trailingAccessories.bind(
98
+ item, descriptors: trailing, theme: theme, style: style,
99
+ checkboxState: checkboxState, fonts: fonts)
100
+ trailingAccessories.isHidden = trailing.isEmpty
101
+ if rowConstraints.isEmpty {
102
+ rowConstraints = [
103
+ favorite.widthAnchor.constraint(equalToConstant: 20),
104
+ favorite.heightAnchor.constraint(equalToConstant: 20),
105
+ visual.widthAnchor.constraint(equalToConstant: 40),
106
+ visual.heightAnchor.constraint(equalToConstant: 40),
107
+ ]
108
+ NSLayoutConstraint.activate(rowConstraints)
109
+ }
110
+ let visualWidth = CGFloat(image.double("width", default: 40))
111
+ let visualHeight = CGFloat(image.double("height", default: 40))
112
+ if rowConstraints[2].constant != visualWidth { rowConstraints[2].constant = visualWidth }
113
+ if rowConstraints[3].constant != visualHeight { rowConstraints[3].constant = visualHeight }
114
+ if !trailing.isEmpty {
115
+ // UIStackView has no intrinsic width of its own. Reserve the controls' fitted
116
+ // width so extra space goes to the weighted columns instead of this stack.
117
+ if trailingWidthConstraint == nil {
118
+ trailingWidthConstraint = trailingAccessories.widthAnchor.constraint(equalToConstant: 0)
119
+ }
120
+ if trailingWidthConstraint?.isActive == true { trailingWidthConstraint?.isActive = false }
121
+ let trailingWidth =
122
+ trailingAccessories.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).width
123
+ if trailingWidthConstraint?.constant != trailingWidth {
124
+ trailingWidthConstraint?.constant = trailingWidth
125
+ }
126
+ trailingWidthConstraint?.isActive = true
127
+ } else {
128
+ if trailingWidthConstraint?.isActive == true { trailingWidthConstraint?.isActive = false }
129
+ }
96
130
  let values = Array(data.dictionaries("columns").prefix(4))
131
+ let weights = values.map { max(1, $0.int("weight", default: 1)) }
132
+ var divisor = weights.first ?? 1
133
+ for weight in weights.dropFirst() {
134
+ var a = divisor
135
+ var b = weight
136
+ while b != 0 { (a, b) = (b, a % b) }
137
+ divisor = a
138
+ }
139
+ let normalizedWeights = weights.map { $0 / divisor }
140
+ let columnsChanged = columnWeights != normalizedWeights
141
+ if columnsChanged { NSLayoutConstraint.deactivate(columnWidthConstraints) }
97
142
  for (index, cell) in cells.enumerated() {
98
- cell.isHidden = index >= values.count
143
+ let hidden = index >= values.count
144
+ if cell.isHidden != hidden { cell.isHidden = hidden }
99
145
  guard index < values.count else {
100
146
  cell.reset()
101
147
  continue
@@ -109,23 +155,29 @@ final class NativeListDataRowCell: NativeListRendererCell {
109
155
  cell.applyStyle(style) { label, style in
110
156
  NativeListTextStyles.applyStyledText(label, style, fonts: fonts)
111
157
  }
112
- if index > 0 {
113
- rowConstraints.append(
114
- cell.widthAnchor.constraint(
115
- equalTo: cells[0].widthAnchor,
116
- multiplier: CGFloat(max(1, values[index].int("weight", default: 1)))
117
- / CGFloat(max(1, values[0].int("weight", default: 1)))))
118
- }
158
+ cell.applySegments(values[index])
159
+ cell.bindTitleIcons(values[index], theme: theme)
160
+ }
161
+ if columnsChanged {
162
+ columnWidthConstraints = values.count > 1 ? (1..<values.count).map { index in
163
+ cells[index].widthAnchor.constraint(equalTo: cells[0].widthAnchor,
164
+ multiplier: CGFloat(weights[index]) / CGFloat(weights[0]))
165
+ } : []
166
+ NSLayoutConstraint.activate(columnWidthConstraints)
167
+ columnWeights = normalizedWeights
119
168
  }
120
- NSLayoutConstraint.activate(rowConstraints)
121
169
  }
122
170
  override func bindSelectionContent(
123
171
  _ item: NativeListItem,
124
172
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
125
- ) { accessories.updateSelection(item, checkboxState: checkboxState) }
173
+ ) {
174
+ accessories.updateSelection(item, checkboxState: checkboxState)
175
+ trailingAccessories.updateSelection(item, checkboxState: checkboxState)
176
+ }
126
177
  override func recycleContent() {
127
178
  visual.recycle()
128
179
  accessories.reset()
180
+ trailingAccessories.reset()
129
181
  cells.forEach { $0.reset() }
130
182
  }
131
183
  }
@@ -133,6 +185,8 @@ final class NativeListDataRowCell: NativeListRendererCell {
133
185
  private final class NativeListTableColumnView: UIStackView {
134
186
  private let primaryLine = UIStackView()
135
187
  private let primaryLabel = NativeListTextLabel()
188
+ private let titleIconView = UIImageView()
189
+ private let secondaryTitleIconView = UIImageView()
136
190
  private let badgesStack = UIStackView()
137
191
  private let secondaryLine = UIStackView()
138
192
  private let secondaryLeadingLabel = NativeListTextLabel()
@@ -152,11 +206,21 @@ private final class NativeListTableColumnView: UIStackView {
152
206
  primaryLabel.numberOfLines = 1
153
207
  primaryLabel.lineBreakMode = .byTruncatingTail
154
208
  primaryLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
209
+ for icon in [titleIconView, secondaryTitleIconView] {
210
+ icon.contentMode = .scaleAspectFit
211
+ icon.translatesAutoresizingMaskIntoConstraints = false
212
+ icon.widthAnchor.constraint(equalToConstant: 20).isActive = true
213
+ icon.heightAnchor.constraint(equalToConstant: 20).isActive = true
214
+ icon.setContentHuggingPriority(.required, for: .horizontal)
215
+ icon.isHidden = true
216
+ }
155
217
  badgesStack.axis = .horizontal
156
218
  badgesStack.alignment = .center
157
219
  badgesStack.spacing = 4
158
220
  badgesStack.setContentCompressionResistancePriority(.required, for: .horizontal)
159
221
  primaryLine.addArrangedSubview(primaryLabel)
222
+ primaryLine.addArrangedSubview(titleIconView)
223
+ primaryLine.addArrangedSubview(secondaryTitleIconView)
160
224
  primaryLine.addArrangedSubview(badgesStack)
161
225
 
162
226
  secondaryLine.axis = .horizontal
@@ -178,8 +242,17 @@ private final class NativeListTableColumnView: UIStackView {
178
242
  fatalError("init(coder:) has not been implemented")
179
243
  }
180
244
 
181
- func reset() {
245
+ func reset(clearPrimaryText: Bool = true) {
182
246
  linear = false
247
+ primaryLine.alignment = .center
248
+ for icon in [titleIconView, secondaryTitleIconView] {
249
+ icon.image = nil
250
+ icon.isHidden = true
251
+ icon.accessibilityLabel = nil
252
+ icon.isAccessibilityElement = false
253
+ }
254
+ primaryLine.setCustomSpacing(UIStackView.spacingUseDefault, after: primaryLabel)
255
+ primaryLine.setCustomSpacing(UIStackView.spacingUseDefault, after: titleIconView)
183
256
  for label in [primaryLabel, secondaryLeadingLabel, secondaryLabel] {
184
257
  label.rowVerticalAlignment = nil
185
258
  label.rowOffsetY = 0
@@ -190,7 +263,7 @@ private final class NativeListTableColumnView: UIStackView {
190
263
  primaryLabel.numberOfLines = 1
191
264
  secondaryLeadingLabel.numberOfLines = 1
192
265
  secondaryLabel.numberOfLines = 1
193
- primaryLabel.attributedText = nil
266
+ if clearPrimaryText { primaryLabel.attributedText = nil }
194
267
  secondaryLeadingLabel.attributedText = nil
195
268
  secondaryLabel.attributedText = nil
196
269
  secondaryLeadingLabel.isHidden = true
@@ -202,6 +275,28 @@ private final class NativeListTableColumnView: UIStackView {
202
275
  }
203
276
  }
204
277
 
278
+ func bindTitleIcons(_ column: [String: Any], theme: [String: Any]?) {
279
+ let descriptors = [column.dictionary("titleIcon"), column.dictionary("secondaryTitleIcon")]
280
+ for (index, descriptor) in descriptors.enumerated() {
281
+ guard let descriptor else { continue }
282
+ let icon = index == 0 ? titleIconView : secondaryTitleIconView
283
+ icon.image = nativeListIcon(named: descriptor.string("name"))
284
+ icon.tintColor = UIColor(
285
+ nativeListHex: descriptor.string("tintColor",
286
+ default: theme?["iconSubdued"] as? String ?? "#8D8D8D"),
287
+ fallback: .gray)
288
+ icon.isHidden = false
289
+ let label = descriptor.string("accessibilityLabel")
290
+ icon.accessibilityLabel = label.isEmpty ? nil : label
291
+ icon.isAccessibilityElement = !label.isEmpty
292
+ }
293
+ if descriptors.contains(where: { $0 != nil }) {
294
+ primaryLine.setCustomSpacing(4, after: primaryLabel)
295
+ primaryLine.setCustomSpacing(4, after: titleIconView)
296
+ if linear { primaryLine.alignment = .top }
297
+ }
298
+ }
299
+
205
300
  func bind(
206
301
  column: [String: Any],
207
302
  badges: [[String: Any]],
@@ -228,7 +323,7 @@ private final class NativeListTableColumnView: UIStackView {
228
323
  secondaryLeadingLabel.font = nativeListFont(ofSize: 12, fonts: fonts)
229
324
  secondaryLabel.font = nativeListFont(ofSize: 12, fonts: fonts)
230
325
  primaryLabel.attributedText = line(
231
- column.string("text"),
326
+ nativeListDataColumnText(column, "text"),
232
327
  font: nativeListFont(ofSize: 14, weight: .medium, fonts: fonts),
233
328
  color: textColor(column.string("tone"), theme: theme),
234
329
  height: 20
@@ -261,7 +356,7 @@ private final class NativeListTableColumnView: UIStackView {
261
356
  secondaryLeadingLabel.isHidden = false
262
357
  secondaryLine.isHidden = false
263
358
  }
264
- let secondary = column.string("secondaryText")
359
+ let secondary = nativeListDataColumnText(column, "secondaryText")
265
360
  if !secondary.isEmpty {
266
361
  secondaryLabel.attributedText = line(
267
362
  secondary,
@@ -286,7 +381,7 @@ private final class NativeListTableColumnView: UIStackView {
286
381
  column: [String: Any], badges: [[String: Any]], theme: [String: Any]?,
287
382
  style: [String: Any] = [:], fonts: NativeListFontFamilies
288
383
  ) {
289
- reset()
384
+ reset(clearPrimaryText: !linear)
290
385
  linear = true
291
386
  alignment = .fill
292
387
  badgesStack.isHidden = true
@@ -331,14 +426,15 @@ private final class NativeListTableColumnView: UIStackView {
331
426
  primaryLabel.textAlignment =
332
427
  column.string("alignment") == "end"
333
428
  ? .right : column.string("alignment") == "center" ? .center : .left
334
- let secondary = column.string("secondaryText")
429
+ let secondary = nativeListDataColumnText(column, "secondaryText")
335
430
  let primaryFont = font(primaryStyle, size: 14, weight: .medium)
336
431
  let attributed = NSMutableAttributedString(
337
- string: column.string("text"),
432
+ string: nativeListDataColumnText(column, "text"),
338
433
  attributes: [
339
434
  .font: primaryFont,
340
435
  .foregroundColor: color(primaryStyle, textColor(column.string("tone"), theme: theme)),
341
436
  ])
437
+ attributed.setAttributedString(nativeListDataSegments(attributed, column.dictionaries("textSegments")))
342
438
  let primaryLength = attributed.length
343
439
  // Every badge run is the legacy " text " pill: both lead spaces sit inside the badge
344
440
  // background and are its left padding. `titleBadgeGap` adds an exact, unfilled gap between
@@ -378,7 +474,10 @@ private final class NativeListTableColumnView: UIStackView {
378
474
  textColor(column.string("secondaryTone", default: "secondary"), theme: theme)),
379
475
  ]
380
476
  attributes.merge(paragraph(secondaryStyle, font: secondaryFont, spacing: nil)) { $1 }
381
- attributed.append(NSAttributedString(string: "\n\(secondary)", attributes: attributes))
477
+ attributed.append(NSAttributedString(string: "\n", attributes: attributes))
478
+ attributed.append(nativeListDataSegments(
479
+ NSAttributedString(string: secondary, attributes: attributes),
480
+ column.dictionaries("secondaryTextSegments")))
382
481
  lines = min(3, lines + max(1, secondaryStyle.int("lines", default: 1)))
383
482
  }
384
483
  primaryLabel.font = nativeListFont(ofSize: 12, fonts: fonts)
@@ -400,6 +499,16 @@ private final class NativeListTableColumnView: UIStackView {
400
499
  primaryStyle.double("offsetY", default: secondaryStyle.double("offsetY")))
401
500
  }
402
501
 
502
+ func applySegments(_ column: [String: Any]) {
503
+ guard !linear else { return }
504
+ if let text = primaryLabel.attributedText {
505
+ primaryLabel.attributedText = nativeListDataSegments(text, column.dictionaries("textSegments"))
506
+ }
507
+ if let text = secondaryLabel.attributedText {
508
+ secondaryLabel.attributedText = nativeListDataSegments(text, column.dictionaries("secondaryTextSegments"))
509
+ }
510
+ }
511
+
403
512
  func applyStyle(_ style: [String: Any], text: (UILabel, [String: Any]) -> Void) {
404
513
  // The linear single label already mapped its styles onto attributed ranges.
405
514
  guard !linear else { return }
@@ -446,3 +555,22 @@ private final class NativeListTableColumnView: UIStackView {
446
555
  }
447
556
  }
448
557
  }
558
+
559
+ private func nativeListDataColumnText(_ column: [String: Any], _ field: String) -> String {
560
+ let segments = column.dictionaries("\(field)Segments")
561
+ return segments.isEmpty ? column.string(field) : segments.map { $0.string("text") }.joined()
562
+ }
563
+
564
+ private func nativeListDataSegments(_ fallback: NSAttributedString, _ segments: [[String: Any]]) -> NSAttributedString {
565
+ guard !segments.isEmpty, fallback.length > 0 else { return fallback }
566
+ let attributes = fallback.attributes(at: 0, effectiveRange: nil)
567
+ let result = NSMutableAttributedString(string: "")
568
+ for segment in segments {
569
+ var runAttributes = attributes
570
+ if segment.string("style") == "subscript", let font = attributes[.font] as? UIFont {
571
+ runAttributes[.font] = font.withSize(ceil(font.pointSize * 0.6))
572
+ }
573
+ result.append(NSAttributedString(string: segment.string("text"), attributes: runAttributes))
574
+ }
575
+ return result
576
+ }
@@ -110,6 +110,9 @@ func nativeListIcon(named name: String) -> UIImage? {
110
110
  case "LockSolid": assetName = "onekey_selector_lock_solid"
111
111
  // OneKey patch: official selector icon geometry.
112
112
  case "GlobusOutline": assetName = "onekey_selector_globus_outline"
113
+ case "GasSolid": assetName = "onekey_gas_solid"
114
+ case "RefreshCcwOutline": assetName = "onekey_refresh_ccw_outline"
115
+ case "CryptoCoinOutline": assetName = "onekey_crypto_coin_outline"
113
116
  case "ArrowBottomOutline": assetName = "onekey_arrow_bottom"
114
117
  case "ArrowTopOutline": assetName = "onekey_arrow_top"
115
118
  case "ChartTrendingUpOutline": assetName = "onekey_chart_trending_up"
@@ -136,6 +139,12 @@ func nativeListIcon(named name: String) -> UIImage? {
136
139
  case "ErrorSolid": assetName = "onekey_error_solid"
137
140
  case "QuestionmarkSolid": assetName = "onekey_questionmark_solid"
138
141
  case "ImageSquareWavesOutline": assetName = "onekey_image_square_waves"
142
+ // Asset-list icons the app passes by name (OK-66072 audit): unmapped names rendered nothing.
143
+ case "DotVerSolid": assetName = "onekey_dot_ver_solid"
144
+ case "Document2Outline": assetName = "onekey_document2"
145
+ case "WalletOutline": assetName = "onekey_wallet"
146
+ case "PlusLargeOutline": assetName = "onekey_plus_large"
147
+ case "TicketOutline": assetName = "onekey_ticket"
139
148
  default: return nil
140
149
  }
141
150
  return UIImage(named: assetName, in: NativeListResources.bundle, compatibleWith: nil)?