@onekeyfe/react-native-native-list 6.7.0-6 → 6.7.0-61

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 (216) hide show
  1. package/README.md +312 -375
  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 +50 -13
  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/NativeListMediaPlaceholderView.kt +244 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
  16. package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
  17. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
  18. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +209 -3
  19. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -287
  20. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
  21. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +7 -0
  22. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +8 -3
  23. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
  24. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +130 -1
  25. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1978 -136
  26. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
  27. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -0
  28. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
  29. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
  30. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
  31. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
  32. package/docs/ROW_TEMPLATES.md +78 -14
  33. package/docs/SPEC.md +1318 -16
  34. package/docs/STYLE_SPEC.md +18 -0
  35. package/ios/HybridNativeList.swift +21 -2
  36. package/ios/NativeListAccessoryStack.swift +237 -51
  37. package/ios/NativeListActivityDetailsView.swift +43 -16
  38. package/ios/NativeListActivityRenderer.swift +8 -2
  39. package/ios/NativeListButtonGroupRenderer.swift +89 -0
  40. package/ios/NativeListDataRowRenderer.swift +167 -30
  41. package/ios/NativeListDesignAssets.swift +13 -75
  42. package/ios/NativeListGeneratedIcons.swift +55 -0
  43. package/ios/NativeListIconBinding.swift +171 -0
  44. package/ios/NativeListIdentityRenderer.swift +256 -39
  45. package/ios/NativeListLeadingVisual.swift +127 -28
  46. package/ios/NativeListMarketRenderer.swift +120 -31
  47. package/ios/NativeListMediaPlaceholderView.swift +189 -0
  48. package/ios/NativeListMediaPreviewSlot.swift +122 -61
  49. package/ios/NativeListMediaTileRenderer.swift +15 -11
  50. package/ios/NativeListMessageRenderer.swift +34 -1
  51. package/ios/NativeListMetricCardRenderer.swift +4 -2
  52. package/ios/NativeListModels.swift +42 -2
  53. package/ios/NativeListRendererRegistry.swift +1 -0
  54. package/ios/NativeListResolvedText.swift +17 -5
  55. package/ios/NativeListRowHost.swift +14 -0
  56. package/ios/NativeListSectionHeaderRenderer.swift +100 -4
  57. package/ios/NativeListTextLabel.swift +106 -0
  58. package/ios/RNCNativeListView.swift +1097 -60
  59. package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
  60. package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
  61. package/ios/tests/NativeListActivityPresentationTests.swift +423 -0
  62. package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
  63. package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
  64. package/ios/tests/NativeListLifecycleTests.swift +2959 -4
  65. package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
  66. package/ios/tests/NativeListMediaVisibilityTests.swift +41 -7
  67. package/ios/tests/NativeListSharedIconTests.swift +236 -0
  68. package/lib/module/NativeList.js +236 -38
  69. package/lib/module/NativeList.web.js +163 -45
  70. package/lib/module/index.js +1 -1
  71. package/lib/module/models.js +3 -0
  72. package/lib/module/selection.js +1 -1
  73. package/lib/module/validation.js +1263 -48
  74. package/lib/module/web/NativeListGeneratedIcons.js +31 -0
  75. package/lib/module/web/NativeListWebEngine.js +513 -275
  76. package/lib/module/web/templates/ActivityRowRenderer.js +41 -54
  77. package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
  78. package/lib/module/web/templates/DataRowRenderer.js +56 -5
  79. package/lib/module/web/templates/IdentityRowRenderer.js +161 -7
  80. package/lib/module/web/templates/MarketTableRowRenderer.js +36 -19
  81. package/lib/module/web/templates/MediaTileRowRenderer.js +84 -25
  82. package/lib/module/web/templates/MessageRowRenderer.js +18 -2
  83. package/lib/module/web/templates/RowContainerStyle.js +1 -0
  84. package/lib/module/web/templates/RowRendererRegistry.js +3 -0
  85. package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
  86. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  87. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  88. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  89. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  90. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  91. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  92. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  93. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  94. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  95. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  96. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  97. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  98. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  99. package/lib/typescript/src/NativeList.d.ts +3 -3
  100. package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
  101. package/lib/typescript/src/NativeList.types.d.ts +20 -2
  102. package/lib/typescript/src/index.d.ts +2 -2
  103. package/lib/typescript/src/models.d.ts +134 -17
  104. package/lib/typescript/src/validation.d.ts +20 -0
  105. package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
  106. package/lib/typescript/src/web/NativeListWebEngine.d.ts +32 -1
  107. package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
  108. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
  109. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
  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 +16 -10
  124. package/react-native-native-list.podspec +2 -6
  125. package/scripts/generate-icons.mjs +150 -0
  126. package/scripts/generate-icons.test.mjs +288 -0
  127. package/scripts/native-list-icons.json +260 -0
  128. package/src/NativeList.nitro.ts +2 -0
  129. package/src/NativeList.tsx +439 -91
  130. package/src/NativeList.types.ts +24 -2
  131. package/src/NativeList.web.tsx +286 -88
  132. package/src/index.ts +2 -0
  133. package/src/models.ts +272 -144
  134. package/src/selection.ts +1 -0
  135. package/src/validation.ts +3041 -146
  136. package/src/web/NativeListGeneratedIcons.ts +28 -0
  137. package/src/web/NativeListWebEngine.ts +818 -343
  138. package/src/web/templates/ActivityRowRenderer.ts +71 -91
  139. package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
  140. package/src/web/templates/DataRowRenderer.ts +121 -20
  141. package/src/web/templates/IdentityRowRenderer.ts +234 -9
  142. package/src/web/templates/MarketTableRowRenderer.ts +53 -33
  143. package/src/web/templates/MediaTileRowRenderer.ts +90 -28
  144. package/src/web/templates/MessageRowRenderer.ts +23 -7
  145. package/src/web/templates/RowContainerStyle.ts +2 -0
  146. package/src/web/templates/RowRendererRegistry.ts +11 -1
  147. package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
  148. package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
  149. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
  150. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
  151. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
  152. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
  153. package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
  154. package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
  155. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
  156. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
  157. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
  158. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
  159. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
  160. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
  161. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
  162. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
  163. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
  164. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
  165. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
  166. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
  167. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
  168. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
  169. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
  170. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
  171. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
  172. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
  173. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
  174. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
  175. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
  176. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
  177. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
  178. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
  179. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
  180. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
  181. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
  182. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
  183. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
  184. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
  185. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
  186. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
  187. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
  188. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
  189. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
  190. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
  191. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
  192. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
  193. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
  194. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
  195. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
  196. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
  197. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
  198. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
  199. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
  200. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
  201. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
  202. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
  203. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
  204. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
  205. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
  206. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
  207. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
  208. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
  209. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
  210. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
  211. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
  212. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
  213. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
  214. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
  215. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
  216. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
@@ -70,8 +70,10 @@ final class NativeListActivityDetailsView: UIStackView {
70
70
  let verticalPadding = CGFloat(style.double("verticalPadding", default: 8))
71
71
  let lineGap = CGFloat(style.double("lineGap"))
72
72
  let gap = CGFloat(style.double("leadingGap", default: 12))
73
+ let hideLeading = data.bool("hideLeading")
73
74
  let imageWidth = CGFloat(image.double("width", default: 40))
74
75
  let imageHeight = CGFloat(image.double("height", default: 40))
76
+ let leadingWidth = hideLeading ? 0 : imageWidth + gap
75
77
  let mainWidth = max(0, width - horizontalPadding * 2)
76
78
 
77
79
  let amounts = data.dictionaries("amounts").map { amount -> (width: CGFloat, height: CGFloat) in
@@ -112,10 +114,11 @@ final class NativeListActivityDetailsView: UIStackView {
112
114
  let feeColumn = data.dictionary("fee") == nil ? 0 : gap + feeWidth
113
115
  let identityWidth: CGFloat
114
116
  if table {
115
- let shared = (mainWidth - imageWidth - gap * 2 - feeColumn) / 2
116
- identityWidth = min(mainWidth * 0.42, shared)
117
+ let hasFee = data.dictionary("fee") != nil
118
+ let columnWidth = max(0, mainWidth - gap * (hasFee ? 2 : 1)) / (hasFee ? 2.6 : 2)
119
+ identityWidth = columnWidth - leadingWidth
117
120
  } else {
118
- identityWidth = mainWidth - imageWidth - gap * 2 - feeColumn - min(amountsWidth, mainWidth * 0.5)
121
+ identityWidth = mainWidth - leadingWidth - gap - feeColumn - min(amountsWidth, mainWidth * 0.5)
119
122
  }
120
123
 
121
124
  let title = NativeListResolvedText(data.string("title"), style: style.dictionary("title"), size: 16,
@@ -140,7 +143,7 @@ final class NativeListActivityDetailsView: UIStackView {
140
143
  return max(height, ceil(sizingButton.intrinsicContentSize.height))
141
144
  } + 8
142
145
  }
143
- return max(imageHeight, identityHeight, amountsHeight, feeHeight) + actionsHeight + verticalPadding * 2
146
+ return max(hideLeading ? 0 : imageHeight, identityHeight, amountsHeight, feeHeight) + actionsHeight + verticalPadding * 2
144
147
  }
145
148
 
146
149
  func bind(_ item: NativeListItem, theme: [String: Any]?, fonts: NativeListFontFamilies) {
@@ -150,35 +153,58 @@ final class NativeListActivityDetailsView: UIStackView {
150
153
  let image = style.dictionary("image") ?? [:]
151
154
  let table = data.string("presentation") == "table"
152
155
  let gap = CGFloat(style.double("leadingGap", default: 12))
156
+ let hideLeading = data.bool("hideLeading")
153
157
  main.spacing = gap
154
158
  identity.spacing = CGFloat(style.double("lineGap"))
155
159
  amounts.spacing = CGFloat(style.double("trailingGap", default: 2))
156
160
  titleLine.spacing = CGFloat(style.double("titleBadgeGap", default: 4))
157
161
  NSLayoutConstraint.deactivate(dimensions)
162
+ let visualWidth = visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40)))
163
+ if hideLeading { visualWidth.priority = UILayoutPriority(999) }
158
164
  dimensions = [
159
- visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40))),
165
+ visualWidth,
160
166
  visual.heightAnchor.constraint(equalToConstant: CGFloat(image.double("height", default: 40))),
161
- amounts.widthAnchor.constraint(lessThanOrEqualTo: main.widthAnchor, multiplier: table ? 0.42 : 0.5),
162
167
  ]
163
- if table { dimensions.append(amounts.widthAnchor.constraint(equalTo: identity.widthAnchor)) }
168
+ if table {
169
+ // The leading visual belongs to identity, so its visibility cannot shift amounts.
170
+ let leadingWidth = hideLeading ? 0 : CGFloat(image.double("width", default: 40)) + gap
171
+ dimensions.append(amounts.widthAnchor.constraint(equalTo: identity.widthAnchor, constant: leadingWidth))
172
+ if data.dictionary("fee") != nil {
173
+ dimensions.append(fee.widthAnchor.constraint(equalTo: amounts.widthAnchor, multiplier: 0.6))
174
+ }
175
+ } else {
176
+ dimensions.append(amounts.widthAnchor.constraint(lessThanOrEqualTo: main.widthAnchor, multiplier: 0.5))
177
+ }
164
178
  NSLayoutConstraint.activate(dimensions)
165
- visual.bind(data.dictionary("leading") ?? [:], style: image, key: item.key, theme: theme,
166
- isUnread: false, secondaryVisual: data.dictionary("secondaryLeading"), fonts: fonts)
179
+ visual.isHidden = hideLeading
180
+ if hideLeading {
181
+ visual.recycle()
182
+ } else {
183
+ visual.bind(data.dictionary("leading") ?? [:], style: image, key: item.key, theme: theme,
184
+ isUnread: false, secondaryVisual: data.dictionary("secondaryLeading"), fonts: fonts)
185
+ }
167
186
  NativeListResolvedText(data.string("title"), style: style.dictionary("title"), size: 16,
168
187
  weight: .medium, color: nativeListColor(theme, "primaryText", "#202020"), lineHeight: 24,
169
188
  lines: 1, fonts: fonts
170
189
  ).bind(title)
171
- NativeListResolvedText(data.string("description"), style: style.dictionary("description"), size: 14,
190
+ let descriptionText = NativeListResolvedText(data.string("description"), style: style.dictionary("description"), size: 14,
172
191
  color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 20, lines: 2,
173
- fonts: fonts
174
- ).bind(descriptionLabel)
192
+ fonts: fonts)
193
+ descriptionText.bind(descriptionLabel)
175
194
  NativeListResolvedText(data.string("status"), style: style.dictionary("status"), size: 12,
176
195
  color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 16, lines: 1,
177
196
  fonts: fonts
178
197
  ).bind(status)
179
198
  descriptionKey = data.string("descriptionActionKey")
180
- descriptionLabel.isUserInteractionEnabled = !descriptionKey.isEmpty
181
- descriptionLabel.accessibilityTraits = descriptionKey.isEmpty ? .staticText : .button
199
+ // The label spans the identity column, so with an action only its text
200
+ // from the caller's `descriptionActionStart` on takes touches. The start is
201
+ // never read out of the string, and one at the end leaves no action.
202
+ let actionStart = descriptionKey.isEmpty
203
+ ? nil : descriptionText.displayOffset(data.int("descriptionActionStart"), in: data.string("description"))
204
+ let hasActionText = actionStart.map { $0 < (descriptionText.text as NSString).length } ?? false
205
+ descriptionLabel.touchableTextStart = actionStart
206
+ descriptionLabel.isUserInteractionEnabled = hasActionText
207
+ descriptionLabel.accessibilityTraits = hasActionText ? .button : .staticText
182
208
  for badge in badgeViews { titleLine.removeArrangedSubview(badge); badge.removeFromSuperview() }
183
209
  badgeViews = data.dictionaries("badges").map { descriptor in
184
210
  let label = NativeListTextLabel()
@@ -225,7 +251,7 @@ final class NativeListActivityDetailsView: UIStackView {
225
251
  let actionData = data.dictionaries("footerActions")
226
252
  actionKeys = actionData.map { $0.string("key") }
227
253
  actions.isHidden = actionData.isEmpty
228
- actions.directionalLayoutMargins = NSDirectionalEdgeInsets(top: 0, leading: CGFloat(image.double("width", default: 40)) + gap, bottom: 0, trailing: 0)
254
+ actions.directionalLayoutMargins = NSDirectionalEdgeInsets(top: 0, leading: hideLeading ? 0 : CGFloat(image.double("width", default: 40)) + gap, bottom: 0, trailing: 0)
229
255
  for (index, descriptor) in actionData.enumerated() {
230
256
  let button = UIButton(type: .system); button.tag = index
231
257
  button.setTitle(descriptor.string("label"), for: .normal)
@@ -249,7 +275,8 @@ final class NativeListActivityDetailsView: UIStackView {
249
275
  onAction?(actionKeys[button.tag], button, "footerAction", button.tag)
250
276
  }
251
277
  func recycle() {
252
- visual.recycle(); amountViews.forEach { $0.recycle() }; actionKeys = []; descriptionKey = ""
278
+ visual.recycle(); visual.isHidden = false; amountViews.forEach { $0.recycle() }; actionKeys = []; descriptionKey = ""
279
+ descriptionLabel.touchableTextStart = nil
253
280
  }
254
281
  }
255
282
 
@@ -97,6 +97,7 @@ final class NativeListActivityCell: NativeListRendererCell {
97
97
  details.recycle()
98
98
  let style = data.dictionary("style") ?? [:]
99
99
  let image = style.dictionary("image") ?? [:]
100
+ let hideLeading = data.bool("hideLeading")
100
101
  root.spacing = 12
101
102
  root.setCustomSpacing(CGFloat(style.double("leadingGap", default: 12)), after: visual)
102
103
  switch style.dictionary("container")?.string("contentVerticalAlignment") {
@@ -113,12 +114,17 @@ final class NativeListActivityCell: NativeListRendererCell {
113
114
  bottom: CGFloat(style.double("verticalPadding", default: 8)),
114
115
  right: CGFloat(style.double("horizontalPadding", default: layout == "table" ? 16 : 12)))
115
116
  NSLayoutConstraint.deactivate(dimensions)
117
+ let visualWidth = visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40)))
118
+ if hideLeading { visualWidth.priority = UILayoutPriority(999) }
116
119
  dimensions = [
117
- visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40))),
120
+ visualWidth,
118
121
  visual.heightAnchor.constraint(equalToConstant: CGFloat(image.double("height", default: 40))),
119
122
  ]
120
123
  NSLayoutConstraint.activate(dimensions)
121
- if let leading = data.dictionary("leading") {
124
+ visual.isHidden = hideLeading
125
+ if hideLeading {
126
+ visual.recycle()
127
+ } else if let leading = data.dictionary("leading") {
122
128
  visual.bind(
123
129
  leading, style: image, key: item.key, theme: theme, isUnread: false,
124
130
  secondaryVisual: data.dictionary("secondaryLeading"), fonts: fonts)
@@ -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,17 +6,21 @@ 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
  }
13
13
 
14
14
  private let visual = NativeListLeadingVisual()
15
- private let favorite = UIImageView()
15
+ private let favorite = NativeListIconImageView()
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,16 +38,22 @@ 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(
44
51
  _ item: NativeListItem, theme: [String: Any]?, layout: String,
45
52
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
46
53
  ) {
54
+ let iconUpdate = NativeListIconUpdate(self)
55
+ defer { iconUpdate.finish() }
56
+
47
57
  let data = item.data
48
58
  let style = data.dictionary("style") ?? [:]
49
59
  let image = style.dictionary("image") ?? [:]
@@ -57,8 +67,7 @@ final class NativeListDataRowCell: NativeListRendererCell {
57
67
  let vp = CGFloat(style.double("verticalPadding", default: layout == "table" ? 10 : 8))
58
68
  contentInsets = UIEdgeInsets(top: vp, left: hp, bottom: vp, right: hp)
59
69
  favorite.isHidden = !data.bool("favorite") && !data.bool("favoriteActive")
60
- favorite.image = nativeListIcon(
61
- named: data.bool("favoriteActive") ? "StarSolid" : "StarOutline")
70
+ favorite.bindIcon(data.bool("favoriteActive") ? "StarSolid" : "StarOutline")
62
71
  favorite.tintColor = nativeListColor(
63
72
  theme, data.bool("favoriteActive") ? "icon" : "iconSubdued",
64
73
  data.bool("favoriteActive") ? "#646464" : "#8D8D8D")
@@ -86,16 +95,55 @@ final class NativeListDataRowCell: NativeListRendererCell {
86
95
  item, descriptors: descriptors, theme: theme, style: accessoryStyle,
87
96
  checkboxState: checkboxState, fonts: fonts)
88
97
  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
- ]
98
+ let trailing = data.dictionaries("trailing")
99
+ trailingAccessories.bind(
100
+ item, descriptors: trailing, theme: theme, style: style,
101
+ checkboxState: checkboxState, fonts: fonts)
102
+ trailingAccessories.isHidden = trailing.isEmpty
103
+ if rowConstraints.isEmpty {
104
+ rowConstraints = [
105
+ favorite.widthAnchor.constraint(equalToConstant: 20),
106
+ favorite.heightAnchor.constraint(equalToConstant: 20),
107
+ visual.widthAnchor.constraint(equalToConstant: 40),
108
+ visual.heightAnchor.constraint(equalToConstant: 40),
109
+ ]
110
+ NSLayoutConstraint.activate(rowConstraints)
111
+ }
112
+ let visualWidth = CGFloat(image.double("width", default: 40))
113
+ let visualHeight = CGFloat(image.double("height", default: 40))
114
+ if rowConstraints[2].constant != visualWidth { rowConstraints[2].constant = visualWidth }
115
+ if rowConstraints[3].constant != visualHeight { rowConstraints[3].constant = visualHeight }
116
+ if !trailing.isEmpty {
117
+ // UIStackView has no intrinsic width of its own. Reserve the controls' fitted
118
+ // width so extra space goes to the weighted columns instead of this stack.
119
+ if trailingWidthConstraint == nil {
120
+ trailingWidthConstraint = trailingAccessories.widthAnchor.constraint(equalToConstant: 0)
121
+ }
122
+ if trailingWidthConstraint?.isActive == true { trailingWidthConstraint?.isActive = false }
123
+ let trailingWidth =
124
+ trailingAccessories.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).width
125
+ if trailingWidthConstraint?.constant != trailingWidth {
126
+ trailingWidthConstraint?.constant = trailingWidth
127
+ }
128
+ trailingWidthConstraint?.isActive = true
129
+ } else {
130
+ if trailingWidthConstraint?.isActive == true { trailingWidthConstraint?.isActive = false }
131
+ }
96
132
  let values = Array(data.dictionaries("columns").prefix(4))
133
+ let weights = values.map { max(1, $0.int("weight", default: 1)) }
134
+ var divisor = weights.first ?? 1
135
+ for weight in weights.dropFirst() {
136
+ var a = divisor
137
+ var b = weight
138
+ while b != 0 { (a, b) = (b, a % b) }
139
+ divisor = a
140
+ }
141
+ let normalizedWeights = weights.map { $0 / divisor }
142
+ let columnsChanged = columnWeights != normalizedWeights
143
+ if columnsChanged { NSLayoutConstraint.deactivate(columnWidthConstraints) }
97
144
  for (index, cell) in cells.enumerated() {
98
- cell.isHidden = index >= values.count
145
+ let hidden = index >= values.count
146
+ if cell.isHidden != hidden { cell.isHidden = hidden }
99
147
  guard index < values.count else {
100
148
  cell.reset()
101
149
  continue
@@ -109,23 +157,34 @@ final class NativeListDataRowCell: NativeListRendererCell {
109
157
  cell.applyStyle(style) { label, style in
110
158
  NativeListTextStyles.applyStyledText(label, style, fonts: fonts)
111
159
  }
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
- }
160
+ cell.applySegments(values[index])
161
+ cell.bindTitleIcons(values[index], theme: theme)
162
+ }
163
+ if columnsChanged {
164
+ columnWidthConstraints = values.count > 1 ? (1..<values.count).map { index in
165
+ cells[index].widthAnchor.constraint(equalTo: cells[0].widthAnchor,
166
+ multiplier: CGFloat(weights[index]) / CGFloat(weights[0]))
167
+ } : []
168
+ NSLayoutConstraint.activate(columnWidthConstraints)
169
+ columnWeights = normalizedWeights
119
170
  }
120
- NSLayoutConstraint.activate(rowConstraints)
171
+
121
172
  }
122
173
  override func bindSelectionContent(
123
174
  _ item: NativeListItem,
124
175
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
125
- ) { accessories.updateSelection(item, checkboxState: checkboxState) }
176
+ ) {
177
+ let iconUpdate = NativeListIconUpdate(self)
178
+ defer { iconUpdate.finish() }
179
+
180
+ accessories.updateSelection(item, checkboxState: checkboxState)
181
+ trailingAccessories.updateSelection(item, checkboxState: checkboxState)
182
+
183
+ }
126
184
  override func recycleContent() {
127
185
  visual.recycle()
128
186
  accessories.reset()
187
+ trailingAccessories.reset()
129
188
  cells.forEach { $0.reset() }
130
189
  }
131
190
  }
@@ -133,6 +192,8 @@ final class NativeListDataRowCell: NativeListRendererCell {
133
192
  private final class NativeListTableColumnView: UIStackView {
134
193
  private let primaryLine = UIStackView()
135
194
  private let primaryLabel = NativeListTextLabel()
195
+ private let titleIconView = NativeListIconImageView()
196
+ private let secondaryTitleIconView = NativeListIconImageView()
136
197
  private let badgesStack = UIStackView()
137
198
  private let secondaryLine = UIStackView()
138
199
  private let secondaryLeadingLabel = NativeListTextLabel()
@@ -152,11 +213,21 @@ private final class NativeListTableColumnView: UIStackView {
152
213
  primaryLabel.numberOfLines = 1
153
214
  primaryLabel.lineBreakMode = .byTruncatingTail
154
215
  primaryLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
216
+ for icon in [titleIconView, secondaryTitleIconView] {
217
+ icon.contentMode = .scaleAspectFit
218
+ icon.translatesAutoresizingMaskIntoConstraints = false
219
+ icon.widthAnchor.constraint(equalToConstant: 20).isActive = true
220
+ icon.heightAnchor.constraint(equalToConstant: 20).isActive = true
221
+ icon.setContentHuggingPriority(.required, for: .horizontal)
222
+ icon.isHidden = true
223
+ }
155
224
  badgesStack.axis = .horizontal
156
225
  badgesStack.alignment = .center
157
226
  badgesStack.spacing = 4
158
227
  badgesStack.setContentCompressionResistancePriority(.required, for: .horizontal)
159
228
  primaryLine.addArrangedSubview(primaryLabel)
229
+ primaryLine.addArrangedSubview(titleIconView)
230
+ primaryLine.addArrangedSubview(secondaryTitleIconView)
160
231
  primaryLine.addArrangedSubview(badgesStack)
161
232
 
162
233
  secondaryLine.axis = .horizontal
@@ -178,8 +249,17 @@ private final class NativeListTableColumnView: UIStackView {
178
249
  fatalError("init(coder:) has not been implemented")
179
250
  }
180
251
 
181
- func reset() {
252
+ func reset(clearPrimaryText: Bool = true) {
182
253
  linear = false
254
+ primaryLine.alignment = .center
255
+ for icon in [titleIconView, secondaryTitleIconView] {
256
+ icon.image = nil
257
+ icon.isHidden = true
258
+ icon.accessibilityLabel = nil
259
+ icon.isAccessibilityElement = false
260
+ }
261
+ primaryLine.setCustomSpacing(UIStackView.spacingUseDefault, after: primaryLabel)
262
+ primaryLine.setCustomSpacing(UIStackView.spacingUseDefault, after: titleIconView)
183
263
  for label in [primaryLabel, secondaryLeadingLabel, secondaryLabel] {
184
264
  label.rowVerticalAlignment = nil
185
265
  label.rowOffsetY = 0
@@ -190,7 +270,7 @@ private final class NativeListTableColumnView: UIStackView {
190
270
  primaryLabel.numberOfLines = 1
191
271
  secondaryLeadingLabel.numberOfLines = 1
192
272
  secondaryLabel.numberOfLines = 1
193
- primaryLabel.attributedText = nil
273
+ if clearPrimaryText { primaryLabel.attributedText = nil }
194
274
  secondaryLeadingLabel.attributedText = nil
195
275
  secondaryLabel.attributedText = nil
196
276
  secondaryLeadingLabel.isHidden = true
@@ -202,12 +282,36 @@ private final class NativeListTableColumnView: UIStackView {
202
282
  }
203
283
  }
204
284
 
285
+ func bindTitleIcons(_ column: [String: Any], theme: [String: Any]?) {
286
+ let descriptors = [column.dictionary("titleIcon"), column.dictionary("secondaryTitleIcon")]
287
+ for (index, descriptor) in descriptors.enumerated() {
288
+ guard let descriptor else { continue }
289
+ let icon = index == 0 ? titleIconView : secondaryTitleIconView
290
+ icon.bindIcon(descriptor.string("name"))
291
+ icon.tintColor = UIColor(
292
+ nativeListHex: descriptor.string("tintColor",
293
+ default: theme?["iconSubdued"] as? String ?? "#8D8D8D"),
294
+ fallback: .gray)
295
+ icon.isHidden = false
296
+ let label = descriptor.string("accessibilityLabel")
297
+ icon.accessibilityLabel = label.isEmpty ? nil : label
298
+ icon.isAccessibilityElement = !label.isEmpty
299
+ }
300
+ if descriptors.contains(where: { $0 != nil }) {
301
+ primaryLine.setCustomSpacing(4, after: primaryLabel)
302
+ primaryLine.setCustomSpacing(4, after: titleIconView)
303
+ if linear { primaryLine.alignment = .top }
304
+ }
305
+ }
306
+
205
307
  func bind(
206
308
  column: [String: Any],
207
309
  badges: [[String: Any]],
208
310
  theme: [String: Any]?,
209
311
  fonts: NativeListFontFamilies
210
312
  ) {
313
+ let iconUpdate = NativeListIconUpdate(self)
314
+ defer { iconUpdate.finish() }
211
315
  reset()
212
316
  let textAlignment: NSTextAlignment
213
317
  switch column.string("alignment") {
@@ -228,7 +332,7 @@ private final class NativeListTableColumnView: UIStackView {
228
332
  secondaryLeadingLabel.font = nativeListFont(ofSize: 12, fonts: fonts)
229
333
  secondaryLabel.font = nativeListFont(ofSize: 12, fonts: fonts)
230
334
  primaryLabel.attributedText = line(
231
- column.string("text"),
335
+ nativeListDataColumnText(column, "text"),
232
336
  font: nativeListFont(ofSize: 14, weight: .medium, fonts: fonts),
233
337
  color: textColor(column.string("tone"), theme: theme),
234
338
  height: 20
@@ -261,7 +365,7 @@ private final class NativeListTableColumnView: UIStackView {
261
365
  secondaryLeadingLabel.isHidden = false
262
366
  secondaryLine.isHidden = false
263
367
  }
264
- let secondary = column.string("secondaryText")
368
+ let secondary = nativeListDataColumnText(column, "secondaryText")
265
369
  if !secondary.isEmpty {
266
370
  secondaryLabel.attributedText = line(
267
371
  secondary,
@@ -286,7 +390,7 @@ private final class NativeListTableColumnView: UIStackView {
286
390
  column: [String: Any], badges: [[String: Any]], theme: [String: Any]?,
287
391
  style: [String: Any] = [:], fonts: NativeListFontFamilies
288
392
  ) {
289
- reset()
393
+ reset(clearPrimaryText: !linear)
290
394
  linear = true
291
395
  alignment = .fill
292
396
  badgesStack.isHidden = true
@@ -331,14 +435,15 @@ private final class NativeListTableColumnView: UIStackView {
331
435
  primaryLabel.textAlignment =
332
436
  column.string("alignment") == "end"
333
437
  ? .right : column.string("alignment") == "center" ? .center : .left
334
- let secondary = column.string("secondaryText")
438
+ let secondary = nativeListDataColumnText(column, "secondaryText")
335
439
  let primaryFont = font(primaryStyle, size: 14, weight: .medium)
336
440
  let attributed = NSMutableAttributedString(
337
- string: column.string("text"),
441
+ string: nativeListDataColumnText(column, "text"),
338
442
  attributes: [
339
443
  .font: primaryFont,
340
444
  .foregroundColor: color(primaryStyle, textColor(column.string("tone"), theme: theme)),
341
445
  ])
446
+ attributed.setAttributedString(nativeListDataSegments(attributed, column.dictionaries("textSegments")))
342
447
  let primaryLength = attributed.length
343
448
  // Every badge run is the legacy " text " pill: both lead spaces sit inside the badge
344
449
  // background and are its left padding. `titleBadgeGap` adds an exact, unfilled gap between
@@ -378,7 +483,10 @@ private final class NativeListTableColumnView: UIStackView {
378
483
  textColor(column.string("secondaryTone", default: "secondary"), theme: theme)),
379
484
  ]
380
485
  attributes.merge(paragraph(secondaryStyle, font: secondaryFont, spacing: nil)) { $1 }
381
- attributed.append(NSAttributedString(string: "\n\(secondary)", attributes: attributes))
486
+ attributed.append(NSAttributedString(string: "\n", attributes: attributes))
487
+ attributed.append(nativeListDataSegments(
488
+ NSAttributedString(string: secondary, attributes: attributes),
489
+ column.dictionaries("secondaryTextSegments")))
382
490
  lines = min(3, lines + max(1, secondaryStyle.int("lines", default: 1)))
383
491
  }
384
492
  primaryLabel.font = nativeListFont(ofSize: 12, fonts: fonts)
@@ -400,6 +508,16 @@ private final class NativeListTableColumnView: UIStackView {
400
508
  primaryStyle.double("offsetY", default: secondaryStyle.double("offsetY")))
401
509
  }
402
510
 
511
+ func applySegments(_ column: [String: Any]) {
512
+ guard !linear else { return }
513
+ if let text = primaryLabel.attributedText {
514
+ primaryLabel.attributedText = nativeListDataSegments(text, column.dictionaries("textSegments"))
515
+ }
516
+ if let text = secondaryLabel.attributedText {
517
+ secondaryLabel.attributedText = nativeListDataSegments(text, column.dictionaries("secondaryTextSegments"))
518
+ }
519
+ }
520
+
403
521
  func applyStyle(_ style: [String: Any], text: (UILabel, [String: Any]) -> Void) {
404
522
  // The linear single label already mapped its styles onto attributed ranges.
405
523
  guard !linear else { return }
@@ -446,3 +564,22 @@ private final class NativeListTableColumnView: UIStackView {
446
564
  }
447
565
  }
448
566
  }
567
+
568
+ private func nativeListDataColumnText(_ column: [String: Any], _ field: String) -> String {
569
+ let segments = column.dictionaries("\(field)Segments")
570
+ return segments.isEmpty ? column.string(field) : segments.map { $0.string("text") }.joined()
571
+ }
572
+
573
+ private func nativeListDataSegments(_ fallback: NSAttributedString, _ segments: [[String: Any]]) -> NSAttributedString {
574
+ guard !segments.isEmpty, fallback.length > 0 else { return fallback }
575
+ let attributes = fallback.attributes(at: 0, effectiveRange: nil)
576
+ let result = NSMutableAttributedString(string: "")
577
+ for segment in segments {
578
+ var runAttributes = attributes
579
+ if segment.string("style") == "subscript", let font = attributes[.font] as? UIFont {
580
+ runAttributes[.font] = font.withSize(ceil(font.pointSize * 0.6))
581
+ }
582
+ result.append(NSAttributedString(string: segment.string("text"), attributes: runAttributes))
583
+ }
584
+ return result
585
+ }