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

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 (126) hide show
  1. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +5 -0
  2. package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +47 -0
  3. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +5 -0
  4. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -338
  5. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +5 -0
  6. package/docs/SPEC.md +175 -9
  7. package/ios/NativeListAccessoryStack.swift +6 -16
  8. package/ios/NativeListDataRowRenderer.swift +15 -6
  9. package/ios/NativeListDesignAssets.swift +13 -84
  10. package/ios/NativeListGeneratedIcons.swift +55 -0
  11. package/ios/NativeListIconBinding.swift +171 -0
  12. package/ios/NativeListIdentityRenderer.swift +19 -10
  13. package/ios/NativeListLeadingVisual.swift +11 -9
  14. package/ios/NativeListMarketRenderer.swift +7 -13
  15. package/ios/NativeListMediaTileRenderer.swift +6 -2
  16. package/ios/NativeListMetricCardRenderer.swift +4 -2
  17. package/ios/NativeListSectionHeaderRenderer.swift +12 -4
  18. package/ios/tests/NativeListAccessoryStackTests.swift +12 -0
  19. package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
  20. package/ios/tests/NativeListSharedIconTests.swift +236 -0
  21. package/lib/module/web/NativeListGeneratedIcons.js +31 -0
  22. package/lib/module/web/NativeListWebEngine.js +21 -323
  23. package/lib/module/web/templates/ActivityRowRenderer.js +4 -24
  24. package/lib/module/web/templates/IdentityRowRenderer.js +16 -4
  25. package/lib/module/web/templates/MarketTableRowRenderer.js +36 -19
  26. package/lib/module/web/templates/MediaTileRowRenderer.js +2 -12
  27. package/lib/typescript/src/NativeList.types.d.ts +2 -2
  28. package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
  29. package/lib/typescript/src/web/NativeListWebEngine.d.ts +0 -1
  30. package/package.json +16 -10
  31. package/react-native-native-list.podspec +0 -5
  32. package/scripts/generate-icons.mjs +150 -0
  33. package/scripts/generate-icons.test.mjs +288 -0
  34. package/scripts/native-list-icons.json +260 -0
  35. package/src/NativeList.types.ts +2 -2
  36. package/src/web/NativeListGeneratedIcons.ts +28 -0
  37. package/src/web/NativeListWebEngine.ts +25 -405
  38. package/src/web/templates/ActivityRowRenderer.ts +15 -53
  39. package/src/web/templates/IdentityRowRenderer.ts +18 -4
  40. package/src/web/templates/MarketTableRowRenderer.ts +53 -33
  41. package/src/web/templates/MediaTileRowRenderer.ts +2 -15
  42. package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
  43. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
  44. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
  45. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
  46. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
  47. package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
  48. package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
  49. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
  50. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
  51. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
  52. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
  53. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
  54. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
  55. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
  56. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
  57. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
  58. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
  59. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
  60. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
  61. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
  62. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
  63. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +0 -15
  64. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +0 -4
  65. package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/Contents.json +0 -1
  66. package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/icon.svg +0 -1
  67. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
  68. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
  69. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/Contents.json +0 -1
  70. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/icon.svg +0 -1
  71. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
  72. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
  73. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
  74. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
  75. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +0 -15
  76. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +0 -3
  77. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
  78. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
  79. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
  80. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
  81. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
  82. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
  83. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
  84. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
  85. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
  86. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
  87. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
  88. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
  89. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/Contents.json +0 -1
  90. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/icon.svg +0 -1
  91. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
  92. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
  93. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
  94. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
  95. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +0 -15
  96. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +0 -3
  97. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
  98. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
  99. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
  100. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
  101. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
  102. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
  103. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
  104. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
  105. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
  106. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
  107. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
  108. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
  109. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
  110. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
  111. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
  112. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
  113. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
  114. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
  115. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
  116. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
  117. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
  118. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
  119. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
  120. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
  121. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
  122. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
  123. package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/Contents.json +0 -1
  124. package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/icon.svg +0 -1
  125. package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/Contents.json +0 -1
  126. package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/icon.svg +0 -1
@@ -0,0 +1,171 @@
1
+ import OneKeyImage
2
+ import UIKit
3
+
4
+ /// One request owner per glyph slot; metadata also supplies detached measurement.
5
+ private final class NativeListIconBinding {
6
+ private weak var view: UIView?
7
+ private let owner = NSObject()
8
+ private let apply: (UIImage?) -> Void
9
+ private var descriptor: NativeListIconMetadata?
10
+ private var pointSize = CGSize.zero
11
+ private var template = true
12
+ private var sizeOverride: CGSize?
13
+ private var currentImage: UIImage?
14
+ private var placeholder: UIImage?
15
+ private var updateDepth = 0
16
+ private var pendingClear = false
17
+ private var revision: UInt64 = 0
18
+ private var identity: String?
19
+
20
+ init(view: UIView, apply: @escaping (UIImage?) -> Void) { self.view = view; self.apply = apply }
21
+
22
+ func bind(_ name: String?, size: CGSize? = nil) {
23
+ guard let name, let metadata = nativeListIconMetadata(named: name) else {
24
+ clearNow(); return
25
+ }
26
+ if descriptor?.name == metadata.name, descriptor?.original == metadata.original,
27
+ descriptor?.size == metadata.size, sizeOverride == size {
28
+ pendingClear = false
29
+ apply(currentImage)
30
+ refresh(); return
31
+ }
32
+ clearNow()
33
+ descriptor = metadata
34
+ pointSize = size ?? metadata.size
35
+ sizeOverride = size
36
+ template = size != nil || !metadata.original
37
+ let format = UIGraphicsImageRendererFormat(); format.scale = 1
38
+ placeholder = UIGraphicsImageRenderer(size: pointSize, format: format).image { _ in }
39
+ .withRenderingMode(template ? .alwaysTemplate : .alwaysOriginal)
40
+ currentImage = placeholder
41
+ apply(currentImage)
42
+ refresh()
43
+ }
44
+
45
+ func clear(display: Bool = true) {
46
+ if display, updateDepth > 0 {
47
+ pendingClear = true; apply(nil); return
48
+ }
49
+ clearNow(display: display)
50
+ }
51
+
52
+ private func clearNow(display: Bool = true) {
53
+ revision &+= 1; identity = nil; descriptor = nil; currentImage = nil; placeholder = nil
54
+ pendingClear = false
55
+ OneKeyNamedSVG.shared.cancel(owner: owner)
56
+ if display { apply(nil) }
57
+ }
58
+
59
+ func beginUpdate() { updateDepth += 1 }
60
+ func endUpdate() {
61
+ updateDepth -= 1
62
+ guard updateDepth == 0 else { return }
63
+ if pendingClear { clearNow() } else { refresh() }
64
+ }
65
+
66
+ func retint() { if descriptor != nil && !pendingClear { apply(currentImage) } }
67
+
68
+ func refresh(force: Bool = false) {
69
+ guard updateDepth == 0, let view, let descriptor else { return }
70
+ let attached = view.window != nil && !view.isHidden && !view.bounds.isEmpty
71
+ let screenScale = max(1, view.window?.screen.scale ?? view.traitCollection.displayScale)
72
+ let fit = min(view.bounds.width / pointSize.width, view.bounds.height / pointSize.height)
73
+ let rasterScale = ceil(screenScale * max(1, fit))
74
+ let next = "\(descriptor.name)|\(pointSize)|\(rasterScale)|\(screenScale)|\(attached)|\(template)"
75
+ guard force || next != identity else { return }
76
+ identity = next; revision &+= 1
77
+ let generation = revision
78
+ OneKeyNamedSVG.shared.cancel(owner: owner)
79
+ currentImage = placeholder
80
+ apply(currentImage)
81
+ guard attached else { return }
82
+ if descriptor.name == "Circle" {
83
+ let image = UIGraphicsImageRenderer(size: pointSize).image { _ in
84
+ UIColor.black.setFill(); UIBezierPath(ovalIn: CGRect(origin: .zero, size: pointSize)).fill()
85
+ }
86
+ currentImage = image.withRenderingMode(.alwaysTemplate); apply(currentImage); return
87
+ }
88
+ let sourceSize = descriptor.size
89
+ let sourceScale = sizeOverride == nil ? rasterScale : ceil(rasterScale * max(pointSize.width / sourceSize.width, pointSize.height / sourceSize.height))
90
+ let pixelWidth = ceil(sourceSize.width * sourceScale), pixelHeight = ceil(sourceSize.height * sourceScale)
91
+ guard pixelWidth.isFinite, pixelHeight.isFinite, pixelWidth > 0, pixelHeight > 0,
92
+ pixelWidth <= 4096, pixelHeight <= 4096, pixelWidth * pixelHeight <= 4_194_304 else { return }
93
+ OneKeyNamedSVG.shared.request(owner: owner, name: descriptor.name, color: "rgba(0,0,0,1)",
94
+ width: Int(pixelWidth), height: Int(pixelHeight),
95
+ scale: screenScale) { [weak self] image in
96
+ guard let self, self.revision == generation, let view = self.view,
97
+ view.window != nil, !view.isHidden else { return }
98
+ guard let cgImage = image?.cgImage else { return }
99
+ var result = UIImage(cgImage: cgImage, scale: sourceScale, orientation: .up)
100
+ if let size = self.sizeOverride {
101
+ let format = UIGraphicsImageRendererFormat(); format.scale = rasterScale
102
+ result = UIGraphicsImageRenderer(size: size, format: format).image { _ in
103
+ result.draw(in: CGRect(origin: .zero, size: size))
104
+ }
105
+ }
106
+ self.currentImage = result.withRenderingMode(self.template ? .alwaysTemplate : .alwaysOriginal)
107
+ self.apply(self.currentImage)
108
+ }
109
+ }
110
+
111
+ deinit { OneKeyNamedSVG.shared.cancel(owner: owner) }
112
+ }
113
+
114
+ final class NativeListIconImageView: UIImageView {
115
+ private var applying = false
116
+ private lazy var iconBinding = NativeListIconBinding(view: self) { [weak self] image in
117
+ guard let self else { return }
118
+ self.applying = true; self.image = image; self.applying = false
119
+ }
120
+ func bindIcon(_ name: String?, size: CGSize? = nil) { iconBinding.bind(name, size: size) }
121
+ func beginIconUpdate() { iconBinding.beginUpdate() }
122
+ func endIconUpdate() { iconBinding.endUpdate() }
123
+ override var image: UIImage? { didSet { if !applying { iconBinding.clear(display: image == nil) } } }
124
+ override var isHidden: Bool { didSet { iconBinding.refresh() } }
125
+ override func layoutSubviews() { super.layoutSubviews(); iconBinding.refresh() }
126
+ override func didMoveToWindow() { super.didMoveToWindow(); iconBinding.refresh() }
127
+ override func tintColorDidChange() { super.tintColorDidChange(); iconBinding.retint() }
128
+ override func traitCollectionDidChange(_ previous: UITraitCollection?) {
129
+ super.traitCollectionDidChange(previous); iconBinding.refresh()
130
+ }
131
+ }
132
+
133
+ class NativeListIconButton: UIButton {
134
+ private var applying = false
135
+ private lazy var iconBinding = NativeListIconBinding(view: self) { [weak self] image in
136
+ guard let self else { return }
137
+ self.applying = true
138
+ self.setImage(image, for: .normal)
139
+ self.setImage(image?.withTintColor(self.tintColor, renderingMode: .alwaysOriginal), for: .disabled)
140
+ self.applying = false
141
+ }
142
+ func bindIcon(_ name: String?, size: CGSize? = nil) { iconBinding.bind(name, size: size) }
143
+ func beginIconUpdate() { iconBinding.beginUpdate() }
144
+ func endIconUpdate() { iconBinding.endUpdate() }
145
+ override func setImage(_ image: UIImage?, for state: UIControl.State) {
146
+ if !applying && state == .normal { iconBinding.clear(display: image == nil) }
147
+ super.setImage(image, for: state)
148
+ }
149
+ override var isHidden: Bool { didSet { iconBinding.refresh() } }
150
+ override func layoutSubviews() { super.layoutSubviews(); iconBinding.refresh() }
151
+ override func didMoveToWindow() { super.didMoveToWindow(); iconBinding.refresh() }
152
+ override func tintColorDidChange() { super.tintColorDidChange(); iconBinding.retint() }
153
+ override func traitCollectionDidChange(_ previous: UITraitCollection?) {
154
+ super.traitCollectionDidChange(previous); iconBinding.refresh()
155
+ }
156
+ }
157
+
158
+ /// A synchronous renderer bind may clear then restore the same glyph descriptor.
159
+ final class NativeListIconUpdate {
160
+ private var images: [NativeListIconImageView] = []
161
+ private var buttons: [NativeListIconButton] = []
162
+ init(_ root: UIView) {
163
+ func collect(_ view: UIView) {
164
+ if let image = view as? NativeListIconImageView { images.append(image); image.beginIconUpdate() }
165
+ if let button = view as? NativeListIconButton { buttons.append(button); button.beginIconUpdate() }
166
+ view.subviews.forEach(collect)
167
+ }
168
+ collect(root)
169
+ }
170
+ func finish() { images.forEach { $0.endIconUpdate() }; buttons.forEach { $0.endIconUpdate() } }
171
+ }
@@ -109,7 +109,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
109
109
  private let mainStack = UIStackView()
110
110
  private let titleRowStack = UIStackView()
111
111
  private let titleLabel = NativeListTextLabel()
112
- private let titleIconView = UIImageView()
112
+ private let titleIconView = NativeListIconImageView()
113
113
  private var titleImageSlot: NativeListImageSlot?
114
114
  private var titleImageConstraints: [NSLayoutConstraint] = []
115
115
  // Absorbs the title row's slack so the title keeps its intrinsic width and the
@@ -120,7 +120,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
120
120
  private let tertiaryLabel = NativeListTextLabel()
121
121
  private let badgeLabel = NativeListInsetLabel()
122
122
  private let trailingStack = NativeListAccessoryStack(frame: .zero)
123
- private let leadingActionButton = UIButton(type: .system)
123
+ private let leadingActionButton = NativeListIconButton(type: .system)
124
124
  private var leadingWidth: NSLayoutConstraint!
125
125
  private var leadingHeight: NSLayoutConstraint!
126
126
  private var leftInset: CGFloat = 12
@@ -208,6 +208,9 @@ final class NativeListIdentityCell: NativeListRendererCell {
208
208
  _ item: NativeListItem, theme: [String: Any]?, layout: String,
209
209
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
210
210
  ) {
211
+ let iconUpdate = NativeListIconUpdate(self)
212
+ defer { iconUpdate.finish() }
213
+
211
214
  selectorTypographyRestorers.reversed().forEach { $0() }
212
215
  selectorTypographyRestorers = []
213
216
  currentItem = item
@@ -298,7 +301,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
298
301
  bindIdentity(item, theme: theme, selected: item.data.bool("selected"), checkboxState)
299
302
  let style = item.data.dictionary("style") ?? [:]
300
303
  if let titleIcon = item.data.dictionary("titleIcon") {
301
- titleIconView.image = nativeListIcon(named: titleIcon.string("name"))
304
+ titleIconView.bindIcon(titleIcon.string("name"))
302
305
  titleIconView.tintColor = UIColor(
303
306
  nativeListHex: titleIcon.string("tintColor",
304
307
  default: theme?["iconSubdued"] as? String ?? "#8D8D8D"),
@@ -407,6 +410,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
407
410
  }
408
411
  settleTitleRowFillerSpacing()
409
412
  applySelectorTypography(item)
413
+
410
414
  }
411
415
 
412
416
  /// The filler is the title row's last arranged view; the stack's default
@@ -422,6 +426,9 @@ final class NativeListIdentityCell: NativeListRendererCell {
422
426
  _ item: NativeListItem,
423
427
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
424
428
  ) {
429
+ let iconUpdate = NativeListIconUpdate(self)
430
+ defer { iconUpdate.finish() }
431
+
425
432
  currentItem = item
426
433
  trailingStack.updateSelection(item, checkboxState: checkboxState)
427
434
  if item.data.string("presentation") == "walletSidebar" {
@@ -439,6 +446,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
439
446
  NativeListTextStyles.applyStyledText(titleLabel, style, fonts: fonts)
440
447
  }
441
448
  }
449
+
442
450
  }
443
451
  override func layoutSubviews() {
444
452
  super.layoutSubviews()
@@ -610,13 +618,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
610
618
  fallback: .darkGray
611
619
  )
612
620
  leadingActionButton.tintColor = tintColor
613
- if let image = nativeListIcon(named: leadingAction.string("name")) {
614
- leadingActionButton.setImage(image, for: .normal)
615
- leadingActionButton.setImage(
616
- image.withTintColor(tintColor, renderingMode: .alwaysOriginal),
617
- for: .disabled
618
- )
619
- }
621
+ leadingActionButton.bindIcon(leadingAction.string("name"))
620
622
  leadingActionButton.isEnabled = !leadingAction.bool("disabled")
621
623
  leadingActionButton.alpha = leadingActionButton.isEnabled ? 1 : 0.4
622
624
  leadingActionKey = leadingAction.string("actionKey")
@@ -807,6 +809,13 @@ final class NativeListIdentityCell: NativeListRendererCell {
807
809
  let width = trailingStack.widthAnchor.constraint(equalTo: accessory.widthAnchor)
808
810
  width.isActive = true
809
811
  selectorConstraints.append(width)
812
+ } else if item.data.string("presentation") == "accountSelector" {
813
+ // Keep flexible space in the text column when there is no accessory button.
814
+ // Stay below visible controls' compression resistance and the hidden checkbox's width.
815
+ let width = trailingStack.widthAnchor.constraint(equalToConstant: 0)
816
+ width.priority = UILayoutPriority(749)
817
+ width.isActive = true
818
+ selectorConstraints.append(width)
810
819
  }
811
820
  }
812
821
  private func dataTextColor(_ tone: String, theme: [String: Any]?) -> UIColor {
@@ -14,16 +14,16 @@ final class NativeListLeadingVisual: UIView {
14
14
  var overlayTextFontSize: CGFloat = 10
15
15
  var overlayTextLineHeight: CGFloat?
16
16
  var overlayTextHorizontalInset: CGFloat?
17
- private let icon = UIImageView()
17
+ private let icon = NativeListIconImageView()
18
18
  private let unread = UIView()
19
19
  private let networkBackdrop = UIView()
20
20
  // Ring under the secondary token of an Activity pair (SPEC "Activity leading pair").
21
21
  private let pairBackdrop = UIView()
22
- private let corner = UIImageView()
22
+ private let corner = NativeListIconImageView()
23
23
  private let cornerBackdrop = UIView()
24
24
  private var slots: [NativeListImageSlot] = []
25
25
  private var overlaySlots: [NativeListImageSlot] = []
26
- private var overlayFallbackIcons: [UIImageView] = []
26
+ private var overlayFallbackIcons: [NativeListIconImageView] = []
27
27
  private var overlays: [(UIView, [String: Any])] = []
28
28
  private let dashedBorder = CAShapeLayer()
29
29
  private var visual: [String: Any] = [:]
@@ -54,6 +54,8 @@ final class NativeListLeadingVisual: UIView {
54
54
  isUnread: Bool, secondaryVisual: [String: Any]? = nil,
55
55
  fonts: NativeListFontFamilies
56
56
  ) {
57
+ let iconUpdate = NativeListIconUpdate(self)
58
+ defer { iconUpdate.finish() }
57
59
  self.fonts = fonts
58
60
  fallback.font = nativeListFont(ofSize: 13, weight: .bold, fonts: fonts)
59
61
  self.visual = visual
@@ -111,7 +113,7 @@ final class NativeListLeadingVisual: UIView {
111
113
  fallback.text = String(visual.string("fallbackText").prefix(2))
112
114
  fallback.textColor = UIColor(
113
115
  nativeListHex: visual.string("fallbackTextColor", default: "#8D8D8D"), fallback: .gray)
114
- icon.image = fallbackData.map { nativeListIcon(named: $0.string("name")) } ?? nil
116
+ icon.bindIcon(fallbackData?.string("name"))
115
117
  icon.tintColor = UIColor(
116
118
  nativeListHex: fallbackData?.string("tintColor", default: "#646464") ?? "#646464",
117
119
  fallback: .darkGray)
@@ -175,7 +177,7 @@ final class NativeListLeadingVisual: UIView {
175
177
  let badge = visual.dictionary("cornerIcon")
176
178
  corner.isHidden = badge == nil
177
179
  cornerBackdrop.isHidden = badge == nil
178
- corner.image = badge.flatMap { nativeListIcon(named: $0.string("name")) }
180
+ corner.bindIcon(badge?.string("name"))
179
181
  corner.tintColor = UIColor(
180
182
  nativeListHex: badge?.string("tintColor", default: "#646464") ?? "#646464",
181
183
  fallback: .darkGray)
@@ -187,12 +189,12 @@ final class NativeListLeadingVisual: UIView {
187
189
  overlays.removeAll(keepingCapacity: true)
188
190
  let descriptors = Array(visual.dictionaries("overlays").prefix(2))
189
191
  while overlaySlots.count < descriptors.count { overlaySlots.append(NativeListImageSlot()) }
190
- while overlayFallbackIcons.count < descriptors.count { overlayFallbackIcons.append(UIImageView()) }
192
+ while overlayFallbackIcons.count < descriptors.count { overlayFallbackIcons.append(NativeListIconImageView()) }
191
193
  for (index, data) in descriptors.enumerated() {
192
194
  let frame = index < previousOverlays.count ? previousOverlays[index].0 : UIView()
193
195
  let fallbackData = data.dictionary("fallbackIcon")
194
196
  let fallbackGlyph = overlayFallbackIcons[index]
195
- fallbackGlyph.image = fallbackData.flatMap { nativeListIcon(named: $0.string("name")) }
197
+ fallbackGlyph.bindIcon(fallbackData?.string("name"))
196
198
  fallbackGlyph.tintColor = UIColor(
197
199
  nativeListHex: fallbackData?.string("tintColor", default: "#646464") ?? "#646464",
198
200
  fallback: .darkGray)
@@ -243,8 +245,8 @@ final class NativeListLeadingVisual: UIView {
243
245
  child = label
244
246
  } else {
245
247
  overlaySlots[index].recycle()
246
- let glyph = frame.subviews.first as? UIImageView ?? UIImageView()
247
- glyph.image = nativeListIcon(named: data.string("name"))
248
+ let glyph = frame.subviews.first as? NativeListIconImageView ?? NativeListIconImageView()
249
+ glyph.bindIcon(data.string("name"))
248
250
  glyph.contentMode = .scaleAspectFit
249
251
  glyph.tintColor = UIColor(
250
252
  nativeListHex: data.string("tintColor", default: "#646464"), fallback: .darkGray)
@@ -35,7 +35,7 @@ final class NativeListMarketCell: NativeListRendererCell {
35
35
  private let marketBadgeButtons = (0..<3).map { _ in NativeListAccessoryButton(type: .system) }
36
36
  private let badgeSlots = (0..<3).map { _ in NativeListImageSlot() }
37
37
  private var marketBadgeImages: [UIView] { badgeSlots.map { $0.view } }
38
- private let leadingActionButton = UIButton(type: .system)
38
+ private let leadingActionButton = NativeListIconButton(type: .system)
39
39
  private var leadingWidth: NSLayoutConstraint!
40
40
  private var leadingHeight: NSLayoutConstraint!
41
41
  private var selectorConstraints: [NSLayoutConstraint] = []
@@ -99,6 +99,9 @@ final class NativeListMarketCell: NativeListRendererCell {
99
99
  _ item: NativeListItem, theme: [String: Any]?, layout: String,
100
100
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
101
101
  ) {
102
+ let iconUpdate = NativeListIconUpdate(self)
103
+ defer { iconUpdate.finish() }
104
+
102
105
  NSLayoutConstraint.deactivate(selectorConstraints + accessorySizeConstraints)
103
106
  selectorConstraints = []
104
107
  accessorySizeConstraints = []
@@ -166,6 +169,7 @@ final class NativeListMarketCell: NativeListRendererCell {
166
169
  ? .top
167
170
  : style?.dictionary("container")?.string("contentVerticalAlignment") == "bottom"
168
171
  ? .bottom : .center
172
+
169
173
  }
170
174
  private func resetButton(_ button: NativeListAccessoryButton) {
171
175
  button.setTitle(nil, for: .normal)
@@ -498,13 +502,7 @@ final class NativeListMarketCell: NativeListRendererCell {
498
502
  fallback: .darkGray
499
503
  )
500
504
  leadingActionButton.tintColor = tintColor
501
- if let image = nativeListIcon(named: leadingAction.string("name")) {
502
- leadingActionButton.setImage(image, for: .normal)
503
- leadingActionButton.setImage(
504
- image.withTintColor(tintColor, renderingMode: .alwaysOriginal),
505
- for: .disabled
506
- )
507
- }
505
+ leadingActionButton.bindIcon(leadingAction.string("name"))
508
506
  leadingActionButton.isEnabled = !leadingAction.bool("disabled")
509
507
  leadingActionButton.alpha = leadingActionButton.isEnabled ? 1 : 0.4
510
508
  leadingActionButton.accessibilityIdentifier = leadingAction["testID"] as? String
@@ -627,11 +625,7 @@ final class NativeListMarketCell: NativeListRendererCell {
627
625
  button.titleEdgeInsets = .zero
628
626
  button.imageView?.contentMode = .scaleAspectFit
629
627
  if hasBuiltInIcon {
630
- button.setImage(
631
- nativeListIcon(
632
- named: "BadgeVerifiedSolid", size: CGSize(width: iconSize, height: iconSize)),
633
- for: .normal
634
- )
628
+ button.bindIcon("BadgeVerifiedSolid", size: CGSize(width: iconSize, height: iconSize))
635
629
  }
636
630
  // OneKey patch: match source badge metrics at physical-pixel precision.
637
631
  // let height = button.heightAnchor.constraint(equalToConstant: 18)
@@ -11,7 +11,7 @@ final class NativeListMediaTileCell: NativeListRendererCell {
11
11
  private let picture = UIView()
12
12
  private let image = NativeListMediaPreviewSlot()
13
13
  private let network = NativeListImageSlot()
14
- private let errorIcon = UIImageView()
14
+ private let errorIcon = NativeListIconImageView()
15
15
  private let title = NativeListTextLabel()
16
16
  private let subtitle = NativeListTextLabel()
17
17
  private let badge = NativeListTextLabel()
@@ -87,6 +87,9 @@ final class NativeListMediaTileCell: NativeListRendererCell {
87
87
  _ item: NativeListItem, theme: [String: Any]?, layout: String,
88
88
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
89
89
  ) {
90
+ let iconUpdate = NativeListIconUpdate(self)
91
+ defer { iconUpdate.finish() }
92
+
90
93
  let style = item.data.dictionary("style") ?? [:]
91
94
  imageStyle = style.dictionary("image") ?? [:]
92
95
  let hp = CGFloat(style.double("horizontalPadding", default: 10))
@@ -122,7 +125,7 @@ final class NativeListMediaTileCell: NativeListRendererCell {
122
125
  let state = item.data.string("imageState")
123
126
  let placeholder = theme?.string("strongBackground", default: "#0000000F") ?? "#0000000F"
124
127
  errorIcon.isHidden = state != "error"
125
- errorIcon.image = nativeListIcon(named: "ImageSquareWavesOutline")
128
+ errorIcon.bindIcon("ImageSquareWavesOutline")
126
129
  errorIcon.tintColor = UIColor(nativeListHex: "#00000044", fallback: .lightGray)
127
130
  let media = item.data.dictionary("media")
128
131
  if state != "empty", state != "error", let source = media?.dictionary("source") ?? item.data.dictionary("image") {
@@ -164,6 +167,7 @@ final class NativeListMediaTileCell: NativeListRendererCell {
164
167
  close.setTitle("×", for: .normal)
165
168
  close.titleLabel?.font = nativeListFont(ofSize: 16, weight: .medium, fonts: fonts)
166
169
  close.setTitleColor(nativeListColor(theme, "primaryText", "#202020"), for: .normal)
170
+
167
171
  }
168
172
  override func layoutSubviews() {
169
173
  let width = CGFloat(
@@ -374,7 +374,7 @@ final class NativeListMetricCardCell: NativeListRendererCell {
374
374
  }
375
375
 
376
376
  private final class NativeListMetricVisual: UIView {
377
- private let icon = UIImageView()
377
+ private let icon = NativeListIconImageView()
378
378
  private let image = NativeListImageSlot()
379
379
  init() {
380
380
  super.init(frame: .zero)
@@ -389,6 +389,8 @@ private final class NativeListMetricVisual: UIView {
389
389
  }
390
390
  required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
391
391
  func bind(_ visual: [String: Any], key: String, placeholder: String) {
392
+ let iconUpdate = NativeListIconUpdate(self)
393
+ defer { iconUpdate.finish() }
392
394
  backgroundColor = UIColor(
393
395
  nativeListHex: visual.string("backgroundColor", default: "#0000000F"), fallback: .lightGray)
394
396
  layer.cornerRadius = visual.string("shape") == "square" ? 0 : 8
@@ -397,7 +399,7 @@ private final class NativeListMetricVisual: UIView {
397
399
  image.view.isHidden = true
398
400
  if kind == "icon" {
399
401
  image.recycle()
400
- icon.image = nativeListIcon(named: visual.string("name"))
402
+ icon.bindIcon(visual.string("name"))
401
403
  icon.tintColor = UIColor(
402
404
  nativeListHex: visual.string("tintColor", default: "#00000072"), fallback: .darkGray)
403
405
  } else if let source = kind == "stackedImages"
@@ -124,8 +124,8 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
124
124
  private let trailingStack = UIStackView()
125
125
  private let accessoryButtons = [NativeListAccessoryButton(type: .system)]
126
126
  private let checkboxControl = NativeListAccessoryStack(frame: .zero)
127
- private let headerTitleIconImageView = UIImageView()
128
- private let headerValueIconImageView = UIImageView()
127
+ private let headerTitleIconImageView = NativeListIconImageView()
128
+ private let headerValueIconImageView = NativeListIconImageView()
129
129
  private var accessoryActions: [(String, NativeSelectionTarget?)] = []
130
130
  private var currentItem: NativeListItem?
131
131
  private var currentTheme: [String: Any]?
@@ -187,6 +187,9 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
187
187
  _ item: NativeListItem, theme: [String: Any]?, layout: String,
188
188
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
189
189
  ) {
190
+ let iconUpdate = NativeListIconUpdate(self)
191
+ defer { iconUpdate.finish() }
192
+
190
193
  selectorTypographyRestorers.reversed().forEach { $0() }
191
194
  selectorTypographyRestorers = []
192
195
  currentItem = item
@@ -297,6 +300,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
297
300
  width.isActive = true
298
301
  selectorConstraints.append(width)
299
302
  }
303
+
300
304
  }
301
305
  private func bindPositionHeaderFields(_ item: NativeListItem, theme: [String: Any]?) {
302
306
  let style = item.data.dictionary("style") ?? [:]
@@ -371,6 +375,9 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
371
375
  _ item: NativeListItem,
372
376
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
373
377
  ) {
378
+ let iconUpdate = NativeListIconUpdate(self)
379
+ defer { iconUpdate.finish() }
380
+
374
381
  currentItem = item
375
382
  checkboxControl.updateSelection(item, checkboxState: checkboxState)
376
383
  if item.data.string("variant") == "summary" {
@@ -382,6 +389,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
382
389
  applyTextStyle(item)
383
390
  applySelectorTypography(item)
384
391
  }
392
+
385
393
  }
386
394
  private func bindCheckbox(
387
395
  _ item: NativeListItem, _ descriptor: [String: Any],
@@ -523,7 +531,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
523
531
  topInset = 12
524
532
  bottomInset = -2
525
533
  if let icon = item.data.dictionary("titleIcon") {
526
- headerTitleIconImageView.image = nativeListIcon(named: icon.string("name"))
534
+ headerTitleIconImageView.bindIcon(icon.string("name"))
527
535
  headerTitleIconImageView.tintColor = UIColor(
528
536
  nativeListHex: icon.string("tintColor", default: "#646464"),
529
537
  fallback: .darkGray
@@ -593,7 +601,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
593
601
  for: .normal
594
602
  )
595
603
  if let icon = item.data.dictionary("valueIcon") {
596
- headerValueIconImageView.image = nativeListIcon(named: icon.string("name"))
604
+ headerValueIconImageView.bindIcon(icon.string("name"))
597
605
  headerValueIconImageView.tintColor = UIColor(
598
606
  nativeListHex: icon.string("tintColor", default: "#646464"),
599
607
  fallback: .darkGray
@@ -42,6 +42,18 @@ final class NativeListAccessoryStackTests: XCTestCase {
42
42
  XCTAssertTrue(stack.hitTest(value.center, with: nil) === stack)
43
43
  }
44
44
 
45
+ func testSwapMenuUsesTheDotVerSolidImage() throws {
46
+ let metadata = try XCTUnwrap(nativeListIconMetadata(named: "DotVerSolid"))
47
+ XCTAssertGreaterThan(metadata.size.width, 0)
48
+ XCTAssertGreaterThan(metadata.size.height, 0)
49
+ let stack = try makeStack(trailing: [[
50
+ "kind": "icon", "name": "DotVerSolid", "buttonStyle": "tertiary",
51
+ "actionKey": "menu",
52
+ ]])
53
+ let button = try XCTUnwrap(try visibleControl(stack) as? UIButton)
54
+ XCTAssertNotNil(button.image(for: .normal))
55
+ }
56
+
45
57
  func testValuePairAccessoryLeavesTouchesToTheRow() throws {
46
58
  let stack = try makeStack(trailing: [
47
59
  ["kind": "valuePair", "primary": "$15.60", "secondary": "0.002 BTC"],
@@ -0,0 +1,96 @@
1
+ import UIKit
2
+ import XCTest
3
+ @testable import NativeListModule
4
+
5
+ @MainActor
6
+ final class NativeListAccountSelectorLayoutTests: XCTestCase {
7
+ private func child<T>(_ cell: NativeListIdentityCell, _ label: String, as type: T.Type) throws -> T {
8
+ try XCTUnwrap(Mirror(reflecting: cell).children.first { $0.label == label }?.value as? T)
9
+ }
10
+
11
+ private func bind(
12
+ _ cell: NativeListIdentityCell, title: String = "A", balance: String = "$16.30",
13
+ trailing: [[String: Any]] = []
14
+ ) throws {
15
+ let item = try NativeListItem(data: [
16
+ "key": "account", "type": "identity", "presentation": "accountSelector",
17
+ "title": title, "height": 60,
18
+ "leading": ["kind": "account", "fallbackText": "A"],
19
+ "subtitleSegments": [
20
+ ["text": balance, "tone": "secondary"],
21
+ ["text": "0x1234...5678", "tone": "secondary", "separatorBefore": true],
22
+ ],
23
+ "trailing": trailing,
24
+ ])
25
+ cell.bind(item: item, theme: nil, layout: "linear", selected: false,
26
+ checkboxState: { _, _, fallback in fallback }, fonts: NativeListFontFamilies())
27
+ cell.setNeedsLayout()
28
+ cell.layoutIfNeeded()
29
+ }
30
+
31
+ private func assertSubtitleFits(
32
+ _ cell: NativeListIdentityCell, file: StaticString = #filePath, line: UInt = #line
33
+ ) throws {
34
+ let labels = try child(cell, "semanticSubtitleLabels", as: [UILabel].self)
35
+ XCTAssertEqual(labels.count, 2, file: file, line: line)
36
+ for label in labels {
37
+ XCTAssertGreaterThanOrEqual(
38
+ label.bounds.width + 0.5, label.intrinsicContentSize.width,
39
+ "The balance and address must fit when the row has spare width", file: file, line: line)
40
+ }
41
+ }
42
+
43
+ func testEmptyTrailingDoesNotCollapseBalanceToShortTitleWidth() throws {
44
+ for width: CGFloat in [320, 390] {
45
+ let cell = NativeListIdentityCell(frame: CGRect(x: 0, y: 0, width: width, height: 60))
46
+ let window = UIWindow(frame: CGRect(x: 0, y: 0, width: width, height: 200))
47
+ window.addSubview(cell)
48
+ for title in ["A", "返佣5", "Pendle account"] {
49
+ for balance in ["$16.30", "$0", "****"] {
50
+ try bind(cell, title: title, balance: balance)
51
+ window.layoutIfNeeded()
52
+ try assertSubtitleFits(cell)
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ func testSpinnerPreservesItsIntrinsicWidthAndSubtitleSpace() throws {
59
+ let cell = NativeListIdentityCell(frame: CGRect(x: 0, y: 0, width: 320, height: 60))
60
+ let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
61
+ window.addSubview(cell)
62
+ try bind(cell, trailing: [["kind": "spinner"]])
63
+ window.layoutIfNeeded()
64
+
65
+ try assertSubtitleFits(cell)
66
+ let trailing = try child(cell, "trailingStack", as: NativeListAccessoryStack.self)
67
+ let spinner = try XCTUnwrap(trailing.arrangedSubviews.compactMap { $0 as? UIActivityIndicatorView }.first)
68
+ XCTAssertTrue(spinner.isAnimating)
69
+ XCTAssertFalse(spinner.isHidden)
70
+ XCTAssertGreaterThanOrEqual(spinner.bounds.width + 0.5, spinner.intrinsicContentSize.width)
71
+ XCTAssertGreaterThanOrEqual(trailing.bounds.width + 0.5, spinner.bounds.width)
72
+ }
73
+
74
+ func testRebindingBetweenIconEmptyAndSpinnerKeepsControlAndSubtitleWidths() throws {
75
+ let cell = NativeListIdentityCell(frame: CGRect(x: 0, y: 0, width: 320, height: 60))
76
+ let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
77
+ window.addSubview(cell)
78
+ for icon in ["DotHorOutline", "PlusSmallOutline"] {
79
+ let descriptor: [String: Any] = ["kind": "icon", "name": icon, "actionKey": "action"]
80
+ let states: [[[String: Any]]] = [[descriptor], [], [["kind": "spinner"]], [descriptor], []]
81
+ for accessories in states {
82
+ try bind(cell, trailing: accessories)
83
+ window.layoutIfNeeded()
84
+ try assertSubtitleFits(cell)
85
+ let trailing = try child(cell, "trailingStack", as: NativeListAccessoryStack.self)
86
+ if accessories.first?["kind"] as? String == "icon" {
87
+ let control = try XCTUnwrap(trailing.firstVisibleControl)
88
+ XCTAssertGreaterThan(control.bounds.width, 0)
89
+ XCTAssertEqual(trailing.bounds.width, control.bounds.width, accuracy: 0.5)
90
+ } else {
91
+ XCTAssertNil(trailing.firstVisibleControl)
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }