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

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 (148) 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 +35 -7
  4. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
  5. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
  6. package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
  7. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
  8. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
  9. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
  10. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +147 -33
  11. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
  12. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
  13. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
  14. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +51 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
  16. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -0
  17. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
  18. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
  19. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
  20. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
  21. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
  22. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
  23. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
  24. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
  25. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
  26. package/docs/ROW_TEMPLATES.md +70 -11
  27. package/docs/SPEC.md +1235 -20
  28. package/docs/STYLE_SPEC.md +6 -0
  29. package/ios/HybridNativeList.swift +21 -2
  30. package/ios/NativeListAccessoryStack.swift +235 -39
  31. package/ios/NativeListActivityDetailsView.swift +30 -11
  32. package/ios/NativeListActivityRenderer.swift +8 -2
  33. package/ios/NativeListButtonGroupRenderer.swift +89 -0
  34. package/ios/NativeListDataRowRenderer.swift +155 -27
  35. package/ios/NativeListDesignAssets.swift +9 -0
  36. package/ios/NativeListIdentityRenderer.swift +239 -31
  37. package/ios/NativeListLeadingVisual.swift +119 -22
  38. package/ios/NativeListMarketRenderer.swift +113 -18
  39. package/ios/NativeListMessageRenderer.swift +34 -1
  40. package/ios/NativeListModels.swift +42 -2
  41. package/ios/NativeListRendererRegistry.swift +1 -0
  42. package/ios/NativeListResolvedText.swift +2 -1
  43. package/ios/NativeListRowHost.swift +14 -0
  44. package/ios/NativeListSectionHeaderRenderer.swift +88 -0
  45. package/ios/RNCNativeListView.swift +1052 -58
  46. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
  47. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
  48. package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/Contents.json +1 -0
  49. package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/icon.svg +1 -0
  50. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/Contents.json +1 -0
  51. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/icon.svg +1 -0
  52. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
  53. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
  54. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/Contents.json +1 -0
  55. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/icon.svg +1 -0
  56. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
  57. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
  58. package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/Contents.json +1 -0
  59. package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/icon.svg +1 -0
  60. package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/Contents.json +1 -0
  61. package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/icon.svg +1 -0
  62. package/ios/tests/NativeListAccessoryStackTests.swift +89 -0
  63. package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
  64. package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
  65. package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
  66. package/ios/tests/NativeListLifecycleTests.swift +2789 -3
  67. package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
  68. package/lib/module/NativeList.js +223 -36
  69. package/lib/module/NativeList.web.js +260 -33
  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 +1386 -81
  74. package/lib/module/web/NativeListWebEngine.js +914 -80
  75. package/lib/module/web/templates/ActivityRowRenderer.js +487 -7
  76. package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
  77. package/lib/module/web/templates/DataRowRenderer.js +40 -5
  78. package/lib/module/web/templates/IdentityRowRenderer.js +145 -5
  79. package/lib/module/web/templates/MarketRowRenderer.js +8 -3
  80. package/lib/module/web/templates/MarketTableRowRenderer.js +577 -0
  81. package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
  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 +8 -3
  85. package/lib/module/web/templates/SectionHeaderRowRenderer.js +70 -3
  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 +29 -1
  102. package/lib/typescript/src/NativeList.web.d.ts +2 -2
  103. package/lib/typescript/src/index.d.ts +2 -2
  104. package/lib/typescript/src/models.d.ts +196 -17
  105. package/lib/typescript/src/validation.d.ts +20 -0
  106. package/lib/typescript/src/web/NativeListWebEngine.d.ts +58 -1
  107. package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
  108. package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
  109. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
  110. package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
  111. package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
  112. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +10 -4
  113. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
  114. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  115. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  116. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  117. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  118. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  119. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  120. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  121. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  122. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  123. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  124. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  125. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  126. package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  127. package/package.json +3 -3
  128. package/react-native-native-list.podspec +1 -0
  129. package/src/NativeList.nitro.ts +2 -0
  130. package/src/NativeList.tsx +418 -89
  131. package/src/NativeList.types.ts +34 -1
  132. package/src/NativeList.web.tsx +417 -66
  133. package/src/index.ts +2 -0
  134. package/src/models.ts +355 -143
  135. package/src/selection.ts +1 -0
  136. package/src/validation.ts +3315 -166
  137. package/src/web/NativeListWebEngine.ts +1473 -113
  138. package/src/web/templates/ActivityRowRenderer.ts +732 -8
  139. package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
  140. package/src/web/templates/DataRowRenderer.ts +93 -20
  141. package/src/web/templates/IdentityRowRenderer.ts +217 -6
  142. package/src/web/templates/MarketRowRenderer.ts +19 -3
  143. package/src/web/templates/MarketTableRowRenderer.ts +755 -0
  144. package/src/web/templates/MediaTileRowRenderer.ts +313 -5
  145. package/src/web/templates/MessageRowRenderer.ts +23 -7
  146. package/src/web/templates/RowContainerStyle.ts +2 -0
  147. package/src/web/templates/RowRendererRegistry.ts +21 -6
  148. package/src/web/templates/SectionHeaderRowRenderer.ts +89 -5
@@ -4,6 +4,51 @@ final class NativeListIdentityCell: NativeListRendererCell {
4
4
  override class func appliesSizePreset(_ item: NativeListItem) -> Bool {
5
5
  !["walletSidebar", "networkSelector"].contains(item.data.string("presentation"))
6
6
  }
7
+ private class func configureTrailingStack(
8
+ _ stack: NativeListAccessoryStack, descriptors: [[String: Any]]
9
+ ) {
10
+ stack.axis = .vertical
11
+ stack.alignment = .trailing
12
+ stack.spacing = 2
13
+ if descriptors.contains(where: { $0.string("kind") == "checkbox" })
14
+ && descriptors.contains(where: { $0.string("kind") == "value" })
15
+ {
16
+ stack.axis = .horizontal
17
+ stack.alignment = .center
18
+ stack.spacing = 12
19
+ } else if descriptors.count == 2,
20
+ descriptors[0].string("kind") == "valuePair",
21
+ (descriptors[1].string("kind") == "menu"
22
+ || (descriptors[1].string("kind") == "icon"
23
+ && descriptors[1].string("name") == "DotVerSolid"
24
+ && descriptors[1].string("actionKey") == "menu"))
25
+ {
26
+ stack.axis = .horizontal
27
+ stack.alignment = .center
28
+ stack.spacing = 8
29
+ } else if descriptors.count == 2,
30
+ (descriptors[0].string("kind") == "valuePair"
31
+ && descriptors[1].string("kind") == "chevron")
32
+ || (descriptors[0].string("kind") == "icon"
33
+ && descriptors[0].string("name") == "RefreshCcwOutline"
34
+ && descriptors[0].string("actionKey").isEmpty
35
+ && descriptors[1].string("kind") == "chevron")
36
+ {
37
+ stack.axis = .horizontal
38
+ stack.alignment = .center
39
+ stack.spacing = 12
40
+ } else if descriptors.count == 2,
41
+ descriptors[0].string("kind") == "icon",
42
+ descriptors[0].string("name") == "PencilOutline",
43
+ descriptors[1].string("kind") == "icon",
44
+ descriptors[1].string("name") == "DragOutline"
45
+ {
46
+ stack.axis = .horizontal
47
+ stack.alignment = .center
48
+ // Source 36-point icon frames with -7 margins need a 10-point gap.
49
+ stack.spacing = 10
50
+ }
51
+ }
7
52
  override class func measure(
8
53
  _ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String,
9
54
  fonts: NativeListFontFamilies
@@ -12,6 +57,50 @@ final class NativeListIdentityCell: NativeListRendererCell {
12
57
  return item.data.dictionaries("badges").isEmpty ? 68 : 92
13
58
  }
14
59
  if item.data.string("presentation") == "networkSelector" { return 47 }
60
+ if item.data.string("contentHeight") == "auto" {
61
+ let style = item.data.dictionary("style") ?? [:]
62
+ let horizontalPadding = CGFloat(style.double("horizontalPadding", default: layout == "table" ? 16 : 12))
63
+ let verticalPadding = CGFloat(style.double("verticalPadding", default: 8))
64
+ let imageWidth = CGFloat(style.dictionary("image")?.double("width", default: 40) ?? 40)
65
+ let imageHeight = CGFloat(style.dictionary("image")?.double("height", default: 40) ?? 40)
66
+ let leadingGap = CGFloat(style.double("leadingGap", default: 12))
67
+ let accessories = item.data.dictionaries("trailing")
68
+ let trailing = NativeListAccessoryStack(frame: .zero)
69
+ configureTrailingStack(trailing, descriptors: accessories)
70
+ trailing.bind(
71
+ item, descriptors: accessories, theme: theme, style: style,
72
+ defaultSpacing: trailing.spacing, checkboxState: { _, _, fallback in fallback }, fonts: fonts)
73
+ trailing.isHidden = false
74
+ let trailingSize = trailing.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)
75
+ let rightInset = style["horizontalPadding"] != nil
76
+ ? horizontalPadding : trailing.endInset ?? horizontalPadding
77
+ let contentGap = trailing.contentGap ?? 12
78
+ let textWidth = max(1,
79
+ width - horizontalPadding - rightInset - imageWidth - leadingGap
80
+ - trailingSize.width - contentGap)
81
+ let title = NativeListResolvedText(
82
+ item.data.string("title"), style: style.dictionary("title"), size: 16,
83
+ weight: .medium, color: .black, lineHeight: 24,
84
+ lines: item.data.int("titleLines", default: 1), fonts: fonts)
85
+ let subtitle = NativeListResolvedText(
86
+ item.data.string("subtitle"), style: style.dictionary("subtitle"), size: 14,
87
+ color: .black, lineHeight: 20,
88
+ lines: item.data.int("subtitleLines", default: 1),
89
+ breakMode: item.data.int("subtitleLines", default: 1) == 0 ? .byWordWrapping : .byTruncatingTail,
90
+ fonts: fonts)
91
+ let tertiary = NativeListResolvedText(
92
+ item.data.string("tertiary"), style: style.dictionary("tertiary"), size: 14,
93
+ color: .black, lineHeight: 20, lines: 1, fonts: fonts)
94
+ let titleImageSize = CGFloat(item.data.dictionary("titleImage")?.dictionary("image")?.double("width") ?? 0)
95
+ let titleImageWidth = titleImageSize > 0
96
+ ? titleImageSize + 4 + (item.data.dictionary("titleIcon") == nil ? 0 : 24) : 0
97
+ let textHeight = max(titleImageSize, title.measure(width: max(1, textWidth - titleImageWidth)))
98
+ + subtitle.measure(width: textWidth)
99
+ + tertiary.measure(width: textWidth)
100
+ + (item.data.string("subtitle").isEmpty ? 0 : CGFloat(style.double("lineGap", default: 0)))
101
+ return max(item.data.string("subtitle").isEmpty ? 56 : 60,
102
+ verticalPadding * 2 + max(imageHeight, textHeight, trailingSize.height))
103
+ }
15
104
  return !item.data.string("tertiary").isEmpty
16
105
  ? 72 : !item.data.string("subtitle").isEmpty ? 60 : 56
17
106
  }
@@ -20,6 +109,13 @@ final class NativeListIdentityCell: NativeListRendererCell {
20
109
  private let mainStack = UIStackView()
21
110
  private let titleRowStack = UIStackView()
22
111
  private let titleLabel = NativeListTextLabel()
112
+ private let titleIconView = UIImageView()
113
+ private var titleImageSlot: NativeListImageSlot?
114
+ private var titleImageConstraints: [NSLayoutConstraint] = []
115
+ // Absorbs the title row's slack so the title keeps its intrinsic width and the
116
+ // title icon / badge follow the text (OK-66041); Android's PackedTitleLineLayout
117
+ // and the Web flex row already pack the title row at its start.
118
+ private let titleRowFiller = UIView()
23
119
  private let subtitleLabel = NativeListTextLabel()
24
120
  private let tertiaryLabel = NativeListTextLabel()
25
121
  private let badgeLabel = NativeListInsetLabel()
@@ -40,7 +136,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
40
136
  private var currentItem: NativeListItem?
41
137
  private var currentTheme: [String: Any]?
42
138
  private var leadingActionKey: String?
43
- override var assetFields: [String] { ["leading"] }
139
+ override var assetFields: [String] { ["leading", "titleImage"] }
44
140
  override var defaultSeparatorInset: CGFloat { 60 }
45
141
  override var defaultCornerRadius: CGFloat {
46
142
  guard let item = currentItem else { return 0 }
@@ -75,7 +171,20 @@ final class NativeListIdentityCell: NativeListRendererCell {
75
171
  titleRowStack.axis = .horizontal
76
172
  titleRowStack.alignment = .center
77
173
  titleRowStack.addArrangedSubview(titleLabel)
174
+ titleRowStack.addArrangedSubview(titleIconView)
78
175
  titleRowStack.addArrangedSubview(badgeLabel)
176
+ titleRowStack.addArrangedSubview(titleRowFiller)
177
+ titleRowFiller.setContentHuggingPriority(UILayoutPriority(1), for: .horizontal)
178
+ titleRowFiller.setContentCompressionResistancePriority(UILayoutPriority(1), for: .horizontal)
179
+ titleIconView.translatesAutoresizingMaskIntoConstraints = false
180
+ let titleIconWidth = titleIconView.widthAnchor.constraint(equalToConstant: 20)
181
+ titleIconWidth.priority = UILayoutPriority(999)
182
+ NSLayoutConstraint.activate([
183
+ titleIconWidth,
184
+ titleIconView.heightAnchor.constraint(equalToConstant: 20),
185
+ ])
186
+ titleIconView.contentMode = .scaleAspectFit
187
+ titleIconView.setContentHuggingPriority(.required, for: .horizontal)
79
188
  [titleRowStack, subtitleLabel, tertiaryLabel].forEach(mainStack.addArrangedSubview)
80
189
  visual.translatesAutoresizingMaskIntoConstraints = false
81
190
  leadingWidth = visual.widthAnchor.constraint(equalToConstant: 40)
@@ -133,6 +242,15 @@ final class NativeListIdentityCell: NativeListRendererCell {
133
242
  titleRowStack.setCustomSpacing(UIStackView.spacingUseDefault, after: $0)
134
243
  }
135
244
  titleRowStack.spacing = 8
245
+ titleIconView.image = nil
246
+ titleIconView.isHidden = true
247
+ titleIconView.accessibilityLabel = nil
248
+ titleIconView.isAccessibilityElement = false
249
+ titleImageSlot?.view.isHidden = true
250
+ titleImageSlot?.view.accessibilityLabel = nil
251
+ titleImageSlot?.view.isAccessibilityElement = false
252
+ NSLayoutConstraint.deactivate(titleImageConstraints)
253
+ titleImageConstraints = []
136
254
  titleRowStack.setContentHuggingPriority(.defaultLow, for: .horizontal)
137
255
  titleRowStack.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
138
256
  for label in [titleLabel, subtitleLabel, tertiaryLabel, badgeLabel] {
@@ -165,6 +283,10 @@ final class NativeListIdentityCell: NativeListRendererCell {
165
283
  leadingWidth.constant = 40
166
284
  leadingHeight.constant = 40
167
285
  visual.glyphSize = 18
286
+ visual.bitmapBorderWidth =
287
+ item.data.dictionary("leading")?.string("borderColor").isEmpty == false
288
+ && item.data.dictionary("leading")?.string("borderStyle") != "dashed"
289
+ ? 1 : 0
168
290
  fallbackLabel.attributedText = nil
169
291
  fallbackLabel.font = nativeListFont(ofSize: 13, weight: .bold, fonts: fonts)
170
292
  trailingStack.reset()
@@ -175,6 +297,67 @@ final class NativeListIdentityCell: NativeListRendererCell {
175
297
  leadingActionButton.setImage(nil, for: .normal)
176
298
  bindIdentity(item, theme: theme, selected: item.data.bool("selected"), checkboxState)
177
299
  let style = item.data.dictionary("style") ?? [:]
300
+ if let titleIcon = item.data.dictionary("titleIcon") {
301
+ titleIconView.image = nativeListIcon(named: titleIcon.string("name"))
302
+ titleIconView.tintColor = UIColor(
303
+ nativeListHex: titleIcon.string("tintColor",
304
+ default: theme?["iconSubdued"] as? String ?? "#8D8D8D"),
305
+ fallback: .gray)
306
+ titleIconView.isHidden = false
307
+ let label = titleIcon.string("accessibilityLabel")
308
+ titleIconView.accessibilityLabel = label.isEmpty ? nil : label
309
+ titleIconView.isAccessibilityElement = !label.isEmpty
310
+ titleRowStack.setCustomSpacing(4, after: titleLabel)
311
+ // A long title truncates ahead of the 20pt glyph (Android caps the title
312
+ // at row width minus accessories, Web shrinks the title first); with the
313
+ // title at `.required` the icon's 999 width constraint collapsed to 0.
314
+ titleLabel.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
315
+ }
316
+ if let descriptor = item.data.dictionary("titleImage"),
317
+ let image = descriptor.dictionary("image"), !image.string("uri").isEmpty
318
+ {
319
+ let size = CGFloat(image.double("width"))
320
+ let slot = titleImageSlot ?? NativeListImageSlot()
321
+ titleImageSlot = slot
322
+ let view = slot.view
323
+ if view.superview == nil {
324
+ let index = titleRowStack.arrangedSubviews.firstIndex(of: titleIconView)! + 1
325
+ titleRowStack.insertArrangedSubview(view, at: index)
326
+ }
327
+ view.clipsToBounds = true
328
+ view.setContentHuggingPriority(.required, for: .horizontal)
329
+ view.setContentCompressionResistancePriority(.required, for: .horizontal)
330
+ view.translatesAutoresizingMaskIntoConstraints = false
331
+ view.layer.cornerRadius = size / 2
332
+ view.isHidden = false
333
+ let label = descriptor.string("accessibilityLabel")
334
+ view.accessibilityLabel = label.isEmpty ? nil : label
335
+ view.isAccessibilityElement = !label.isEmpty
336
+ titleImageConstraints = [
337
+ view.widthAnchor.constraint(equalToConstant: size),
338
+ view.heightAnchor.constraint(equalToConstant: size),
339
+ ]
340
+ titleImageConstraints.forEach { $0.priority = UILayoutPriority(999) }
341
+ NSLayoutConstraint.activate(titleImageConstraints)
342
+ titleRowStack.setCustomSpacing(4, after: titleIconView.isHidden ? titleLabel : titleIconView)
343
+ titleLabel.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
344
+ slot.bind(image, key: "\(item.key):titleImage", placeholder: "#00000000")
345
+ } else {
346
+ titleImageSlot?.recycle()
347
+ }
348
+ if let ratio = style["leadingContentMaxWidthRatio"] as? NSNumber,
349
+ root.arrangedSubviews.contains(visual)
350
+ {
351
+ titleLabel.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
352
+ let visualWidth = CGFloat(style.dictionary("image")?.double("width", default: 40) ?? 40)
353
+ let leadingGap = CGFloat(style.double("leadingGap", default: 12))
354
+ let constraint = mainStack.widthAnchor.constraint(
355
+ lessThanOrEqualTo: root.widthAnchor,
356
+ multiplier: CGFloat(ratio.doubleValue),
357
+ constant: -(visualWidth + leadingGap))
358
+ constraint.isActive = true
359
+ selectorConstraints.append(constraint)
360
+ }
178
361
  if style["horizontalPadding"] != nil {
179
362
  leftInset = CGFloat(style.double("horizontalPadding"))
180
363
  rightInset = -leftInset
@@ -196,7 +379,10 @@ final class NativeListIdentityCell: NativeListRendererCell {
196
379
  if walletBadgeLine != nil {
197
380
  mainStack.setCustomSpacing(CGFloat(style.double("titleBadgeGap")), after: titleRowStack)
198
381
  } else {
199
- titleRowStack.setCustomSpacing(CGFloat(style.double("titleBadgeGap")), after: titleLabel)
382
+ titleRowStack.setCustomSpacing(
383
+ CGFloat(style.double("titleBadgeGap")),
384
+ after: titleImageSlot?.view.isHidden == false ? titleImageSlot!.view
385
+ : titleIconView.isHidden ? titleLabel : titleIconView)
200
386
  }
201
387
  }
202
388
  if style["trailingGap"] != nil { trailingStack.spacing = CGFloat(style.double("trailingGap")) }
@@ -219,8 +405,19 @@ final class NativeListIdentityCell: NativeListRendererCell {
219
405
  : style.dictionary("container")?.string("contentVerticalAlignment") == "bottom"
220
406
  ? .bottom : .center
221
407
  }
408
+ settleTitleRowFillerSpacing()
222
409
  applySelectorTypography(item)
223
410
  }
411
+
412
+ /// The filler is the title row's last arranged view; the stack's default
413
+ /// spacing before it would shave 8pt off the title's available width (visible
414
+ /// under `leadingContentMaxWidthRatio`), so the gap before the filler is zero.
415
+ private func settleTitleRowFillerSpacing() {
416
+ let visible = titleRowStack.arrangedSubviews.filter { $0 !== titleRowFiller && !$0.isHidden }
417
+ if let last = visible.last {
418
+ titleRowStack.setCustomSpacing(0, after: last)
419
+ }
420
+ }
224
421
  override func bindSelectionContent(
225
422
  _ item: NativeListItem,
226
423
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
@@ -259,6 +456,10 @@ final class NativeListIdentityCell: NativeListRendererCell {
259
456
  }
260
457
  override func recycleContent() {
261
458
  visual.recycle()
459
+ titleImageSlot?.recycle()
460
+ titleImageSlot?.view.isHidden = true
461
+ titleImageSlot?.view.accessibilityLabel = nil
462
+ titleImageSlot?.view.isAccessibilityElement = false
262
463
  trailingStack.reset()
263
464
  currentItem = nil
264
465
  }
@@ -440,9 +641,40 @@ final class NativeListIdentityCell: NativeListRendererCell {
440
641
  }
441
642
  root.addArrangedSubview(mainStack)
442
643
  show(titleLabel, item.data.string("title"), lines: item.data.int("titleLines", default: 1))
644
+ let titleSuffixes = item.data.dictionaries("titleSuffixes")
645
+ if !titleSuffixes.isEmpty {
646
+ titleLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
647
+ let minimumTitleWidth = titleLabel.widthAnchor.constraint(greaterThanOrEqualToConstant: 80)
648
+ minimumTitleWidth.priority = UILayoutPriority(751)
649
+ minimumTitleWidth.isActive = true
650
+ selectorConstraints.append(minimumTitleWidth)
651
+ for suffix in titleSuffixes {
652
+ let label = NativeListTextLabel()
653
+ label.font = nativeListFont(ofSize: 12, fonts: fonts)
654
+ label.textColor = dataTextColor(suffix.string("tone", default: "secondary"), theme: theme)
655
+ label.numberOfLines = 1
656
+ label.lineBreakMode = .byTruncatingTail
657
+ label.setContentHuggingPriority(.defaultHigh, for: .horizontal)
658
+ label.setContentCompressionResistancePriority(UILayoutPriority(749), for: .horizontal)
659
+ setLineHeight(label, text: suffix.string("text"), lineHeight: 16)
660
+ if let maxWidth = suffix["maxWidth"] as? NSNumber {
661
+ let limit = label.widthAnchor.constraint(lessThanOrEqualToConstant: CGFloat(truncating: maxWidth))
662
+ limit.isActive = true
663
+ selectorConstraints.append(limit)
664
+ }
665
+ titleRowStack.insertArrangedSubview(
666
+ label,
667
+ at: titleRowStack.arrangedSubviews.firstIndex(of: badgeLabel)
668
+ ?? titleRowStack.arrangedSubviews.count)
669
+ selectorViews.append(label)
670
+ }
671
+ }
443
672
  show(
444
673
  subtitleLabel, item.data.string("subtitle"), lines: item.data.int("subtitleLines", default: 1)
445
674
  )
675
+ if item.data.int("subtitleLines", default: 1) == 0 {
676
+ subtitleLabel.lineBreakMode = .byWordWrapping
677
+ }
446
678
  show(tertiaryLabel, item.data.string("tertiary"), lines: 1)
447
679
  if !item.data.string("subtitle").isEmpty, item.data.string("tertiary").isEmpty {
448
680
  mainStack.spacing = 0
@@ -556,32 +788,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
556
788
  }
557
789
  root.addArrangedSubview(trailingStack)
558
790
  let accessories = item.data.dictionaries("trailing")
559
- if accessories.contains(where: { $0.string("kind") == "checkbox" })
560
- && accessories.contains(where: { $0.string("kind") == "value" })
561
- {
562
- trailingStack.axis = .horizontal
563
- trailingStack.alignment = .center
564
- trailingStack.spacing = 12
565
- } else if accessories.count == 2,
566
- accessories[0].string("kind") == "valuePair",
567
- accessories[1].string("kind") == "menu"
568
- {
569
- trailingStack.axis = .horizontal
570
- trailingStack.alignment = .center
571
- trailingStack.spacing = 8
572
- } else if accessories.count == 2,
573
- accessories[0].string("kind") == "icon",
574
- accessories[0].string("name") == "PencilOutline",
575
- accessories[1].string("kind") == "icon",
576
- accessories[1].string("name") == "DragOutline"
577
- {
578
- trailingStack.axis = .horizontal
579
- trailingStack.alignment = .center
580
- // Each source IconButton has a 36-point frame and m=-7. XStack gap=$6
581
- // therefore places the physical frames 10 points apart (46-point
582
- // center distance), not 24 points apart.
583
- trailingStack.spacing = 10
584
- }
791
+ Self.configureTrailingStack(trailingStack, descriptors: accessories)
585
792
  trailingStack.bind(
586
793
  item, descriptors: accessories, theme: theme, style: item.data.dictionary("style") ?? [:],
587
794
  defaultSpacing: trailingStack.spacing, checkboxState: checkboxState, fonts: fonts)
@@ -590,12 +797,13 @@ final class NativeListIdentityCell: NativeListRendererCell {
590
797
  trailingStack.isHidden = false
591
798
  if let gap = trailingStack.contentGap { root.setCustomSpacing(gap, after: mainStack) }
592
799
  if let inset = trailingStack.endInset { rightInset = -inset }
593
- if item.data.string("presentation") == "accountSelector",
594
- accessories.count == 1,
800
+ if accessories.count == 1,
801
+ (item.data.string("presentation") == "accountSelector"
802
+ || accessories[0].string("kind") == "valuePair"),
595
803
  let accessory = trailingStack.firstVisibleControl
596
804
  {
597
805
  // The vertical trailing stack has no stable intrinsic width, so keep its
598
- // flexible space in the account title and subtitle column.
806
+ // flexible space in the title and subtitle column.
599
807
  let width = trailingStack.widthAnchor.constraint(equalTo: accessory.widthAnchor)
600
808
  width.isActive = true
601
809
  selectorConstraints.append(width)