@onekeyfe/react-native-native-list 6.7.0-16 → 6.7.0-17

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 (115) 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 +240 -11
  3. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +7 -4
  4. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +6 -3
  5. package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
  6. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
  7. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +87 -7
  8. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +177 -1
  9. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +43 -14
  10. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +33 -2
  12. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +22 -0
  13. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
  14. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
  16. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
  17. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
  18. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1877 -41
  19. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +1 -0
  20. package/docs/ROW_TEMPLATES.md +60 -9
  21. package/docs/SPEC.md +401 -5
  22. package/docs/STYLE_SPEC.md +6 -0
  23. package/ios/HybridNativeList.swift +17 -2
  24. package/ios/NativeListAccessoryStack.swift +227 -39
  25. package/ios/NativeListActivityDetailsView.swift +18 -8
  26. package/ios/NativeListActivityRenderer.swift +8 -2
  27. package/ios/NativeListButtonGroupRenderer.swift +89 -0
  28. package/ios/NativeListDataRowRenderer.swift +155 -27
  29. package/ios/NativeListDesignAssets.swift +3 -0
  30. package/ios/NativeListIdentityRenderer.swift +166 -30
  31. package/ios/NativeListLeadingVisual.swift +49 -14
  32. package/ios/NativeListMessageRenderer.swift +34 -1
  33. package/ios/NativeListModels.swift +42 -2
  34. package/ios/NativeListRendererRegistry.swift +1 -0
  35. package/ios/NativeListResolvedText.swift +2 -1
  36. package/ios/NativeListRowHost.swift +14 -0
  37. package/ios/NativeListSectionHeaderRenderer.swift +88 -0
  38. package/ios/RNCNativeListView.swift +984 -53
  39. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
  40. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
  41. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
  42. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
  43. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
  44. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
  45. package/ios/tests/NativeListActivityPresentationTests.swift +56 -0
  46. package/ios/tests/NativeListLifecycleTests.swift +2494 -3
  47. package/lib/module/NativeList.js +171 -28
  48. package/lib/module/NativeList.web.js +54 -4
  49. package/lib/module/models.js +1 -0
  50. package/lib/module/selection.js +1 -1
  51. package/lib/module/validation.js +331 -8
  52. package/lib/module/web/NativeListWebEngine.js +503 -18
  53. package/lib/module/web/templates/ActivityRowRenderer.js +8 -7
  54. package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
  55. package/lib/module/web/templates/DataRowRenderer.js +40 -5
  56. package/lib/module/web/templates/IdentityRowRenderer.js +90 -4
  57. package/lib/module/web/templates/MessageRowRenderer.js +18 -2
  58. package/lib/module/web/templates/RowContainerStyle.js +1 -0
  59. package/lib/module/web/templates/RowRendererRegistry.js +3 -0
  60. package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
  61. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  62. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  63. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  64. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  65. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  66. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  67. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  68. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  69. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  70. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  71. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  72. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  73. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  74. package/lib/typescript/src/NativeList.d.ts +1 -1
  75. package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
  76. package/lib/typescript/src/NativeList.types.d.ts +18 -0
  77. package/lib/typescript/src/index.d.ts +1 -1
  78. package/lib/typescript/src/models.d.ts +105 -9
  79. package/lib/typescript/src/validation.d.ts +10 -0
  80. package/lib/typescript/src/web/NativeListWebEngine.d.ts +31 -0
  81. package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
  82. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
  83. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
  84. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  85. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  86. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  87. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  88. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  89. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  90. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  91. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  92. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  93. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  94. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  95. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  96. package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  97. package/package.json +3 -3
  98. package/react-native-native-list.podspec +1 -0
  99. package/src/NativeList.nitro.ts +2 -0
  100. package/src/NativeList.tsx +307 -44
  101. package/src/NativeList.types.ts +22 -0
  102. package/src/NativeList.web.tsx +75 -8
  103. package/src/index.ts +1 -0
  104. package/src/models.ts +117 -3
  105. package/src/selection.ts +1 -0
  106. package/src/validation.ts +742 -6
  107. package/src/web/NativeListWebEngine.ts +798 -19
  108. package/src/web/templates/ActivityRowRenderer.ts +14 -6
  109. package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
  110. package/src/web/templates/DataRowRenderer.ts +93 -20
  111. package/src/web/templates/IdentityRowRenderer.ts +150 -5
  112. package/src/web/templates/MessageRowRenderer.ts +23 -7
  113. package/src/web/templates/RowContainerStyle.ts +2 -0
  114. package/src/web/templates/RowRendererRegistry.ts +11 -1
  115. package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
@@ -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,47 @@ 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 textHeight = title.measure(width: textWidth)
95
+ + subtitle.measure(width: textWidth)
96
+ + tertiary.measure(width: textWidth)
97
+ + (item.data.string("subtitle").isEmpty ? 0 : CGFloat(style.double("lineGap", default: 0)))
98
+ return max(item.data.string("subtitle").isEmpty ? 56 : 60,
99
+ verticalPadding * 2 + max(imageHeight, textHeight, trailingSize.height))
100
+ }
15
101
  return !item.data.string("tertiary").isEmpty
16
102
  ? 72 : !item.data.string("subtitle").isEmpty ? 60 : 56
17
103
  }
@@ -20,6 +106,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
20
106
  private let mainStack = UIStackView()
21
107
  private let titleRowStack = UIStackView()
22
108
  private let titleLabel = NativeListTextLabel()
109
+ private let titleIconView = UIImageView()
23
110
  private let subtitleLabel = NativeListTextLabel()
24
111
  private let tertiaryLabel = NativeListTextLabel()
25
112
  private let badgeLabel = NativeListInsetLabel()
@@ -75,7 +162,17 @@ final class NativeListIdentityCell: NativeListRendererCell {
75
162
  titleRowStack.axis = .horizontal
76
163
  titleRowStack.alignment = .center
77
164
  titleRowStack.addArrangedSubview(titleLabel)
165
+ titleRowStack.addArrangedSubview(titleIconView)
78
166
  titleRowStack.addArrangedSubview(badgeLabel)
167
+ titleIconView.translatesAutoresizingMaskIntoConstraints = false
168
+ let titleIconWidth = titleIconView.widthAnchor.constraint(equalToConstant: 20)
169
+ titleIconWidth.priority = UILayoutPriority(999)
170
+ NSLayoutConstraint.activate([
171
+ titleIconWidth,
172
+ titleIconView.heightAnchor.constraint(equalToConstant: 20),
173
+ ])
174
+ titleIconView.contentMode = .scaleAspectFit
175
+ titleIconView.setContentHuggingPriority(.required, for: .horizontal)
79
176
  [titleRowStack, subtitleLabel, tertiaryLabel].forEach(mainStack.addArrangedSubview)
80
177
  visual.translatesAutoresizingMaskIntoConstraints = false
81
178
  leadingWidth = visual.widthAnchor.constraint(equalToConstant: 40)
@@ -133,6 +230,10 @@ final class NativeListIdentityCell: NativeListRendererCell {
133
230
  titleRowStack.setCustomSpacing(UIStackView.spacingUseDefault, after: $0)
134
231
  }
135
232
  titleRowStack.spacing = 8
233
+ titleIconView.image = nil
234
+ titleIconView.isHidden = true
235
+ titleIconView.accessibilityLabel = nil
236
+ titleIconView.isAccessibilityElement = false
136
237
  titleRowStack.setContentHuggingPriority(.defaultLow, for: .horizontal)
137
238
  titleRowStack.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
138
239
  for label in [titleLabel, subtitleLabel, tertiaryLabel, badgeLabel] {
@@ -165,6 +266,10 @@ final class NativeListIdentityCell: NativeListRendererCell {
165
266
  leadingWidth.constant = 40
166
267
  leadingHeight.constant = 40
167
268
  visual.glyphSize = 18
269
+ visual.bitmapBorderWidth =
270
+ item.data.dictionary("leading")?.string("borderColor").isEmpty == false
271
+ && item.data.dictionary("leading")?.string("borderStyle") != "dashed"
272
+ ? 1 : 0
168
273
  fallbackLabel.attributedText = nil
169
274
  fallbackLabel.font = nativeListFont(ofSize: 13, weight: .bold, fonts: fonts)
170
275
  trailingStack.reset()
@@ -175,6 +280,31 @@ final class NativeListIdentityCell: NativeListRendererCell {
175
280
  leadingActionButton.setImage(nil, for: .normal)
176
281
  bindIdentity(item, theme: theme, selected: item.data.bool("selected"), checkboxState)
177
282
  let style = item.data.dictionary("style") ?? [:]
283
+ if let titleIcon = item.data.dictionary("titleIcon") {
284
+ titleIconView.image = nativeListIcon(named: titleIcon.string("name"))
285
+ titleIconView.tintColor = UIColor(
286
+ nativeListHex: titleIcon.string("tintColor",
287
+ default: theme?["iconSubdued"] as? String ?? "#8D8D8D"),
288
+ fallback: .gray)
289
+ titleIconView.isHidden = false
290
+ let label = titleIcon.string("accessibilityLabel")
291
+ titleIconView.accessibilityLabel = label.isEmpty ? nil : label
292
+ titleIconView.isAccessibilityElement = !label.isEmpty
293
+ titleRowStack.setCustomSpacing(4, after: titleLabel)
294
+ }
295
+ if let ratio = style["leadingContentMaxWidthRatio"] as? NSNumber,
296
+ root.arrangedSubviews.contains(visual)
297
+ {
298
+ titleLabel.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
299
+ let visualWidth = CGFloat(style.dictionary("image")?.double("width", default: 40) ?? 40)
300
+ let leadingGap = CGFloat(style.double("leadingGap", default: 12))
301
+ let constraint = mainStack.widthAnchor.constraint(
302
+ lessThanOrEqualTo: root.widthAnchor,
303
+ multiplier: CGFloat(ratio.doubleValue),
304
+ constant: -(visualWidth + leadingGap))
305
+ constraint.isActive = true
306
+ selectorConstraints.append(constraint)
307
+ }
178
308
  if style["horizontalPadding"] != nil {
179
309
  leftInset = CGFloat(style.double("horizontalPadding"))
180
310
  rightInset = -leftInset
@@ -196,7 +326,9 @@ final class NativeListIdentityCell: NativeListRendererCell {
196
326
  if walletBadgeLine != nil {
197
327
  mainStack.setCustomSpacing(CGFloat(style.double("titleBadgeGap")), after: titleRowStack)
198
328
  } else {
199
- titleRowStack.setCustomSpacing(CGFloat(style.double("titleBadgeGap")), after: titleLabel)
329
+ titleRowStack.setCustomSpacing(
330
+ CGFloat(style.double("titleBadgeGap")),
331
+ after: titleIconView.isHidden ? titleLabel : titleIconView)
200
332
  }
201
333
  }
202
334
  if style["trailingGap"] != nil { trailingStack.spacing = CGFloat(style.double("trailingGap")) }
@@ -440,9 +572,37 @@ final class NativeListIdentityCell: NativeListRendererCell {
440
572
  }
441
573
  root.addArrangedSubview(mainStack)
442
574
  show(titleLabel, item.data.string("title"), lines: item.data.int("titleLines", default: 1))
575
+ let titleSuffixes = item.data.dictionaries("titleSuffixes")
576
+ if !titleSuffixes.isEmpty {
577
+ titleLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
578
+ let minimumTitleWidth = titleLabel.widthAnchor.constraint(greaterThanOrEqualToConstant: 80)
579
+ minimumTitleWidth.priority = UILayoutPriority(751)
580
+ minimumTitleWidth.isActive = true
581
+ selectorConstraints.append(minimumTitleWidth)
582
+ for suffix in titleSuffixes {
583
+ let label = NativeListTextLabel()
584
+ label.font = nativeListFont(ofSize: 12, fonts: fonts)
585
+ label.textColor = dataTextColor(suffix.string("tone", default: "secondary"), theme: theme)
586
+ label.numberOfLines = 1
587
+ label.lineBreakMode = .byTruncatingTail
588
+ label.setContentHuggingPriority(.defaultHigh, for: .horizontal)
589
+ label.setContentCompressionResistancePriority(UILayoutPriority(749), for: .horizontal)
590
+ setLineHeight(label, text: suffix.string("text"), lineHeight: 16)
591
+ if let maxWidth = suffix["maxWidth"] as? NSNumber {
592
+ let limit = label.widthAnchor.constraint(lessThanOrEqualToConstant: CGFloat(truncating: maxWidth))
593
+ limit.isActive = true
594
+ selectorConstraints.append(limit)
595
+ }
596
+ titleRowStack.insertArrangedSubview(label, at: titleRowStack.arrangedSubviews.count - 1)
597
+ selectorViews.append(label)
598
+ }
599
+ }
443
600
  show(
444
601
  subtitleLabel, item.data.string("subtitle"), lines: item.data.int("subtitleLines", default: 1)
445
602
  )
603
+ if item.data.int("subtitleLines", default: 1) == 0 {
604
+ subtitleLabel.lineBreakMode = .byWordWrapping
605
+ }
446
606
  show(tertiaryLabel, item.data.string("tertiary"), lines: 1)
447
607
  if !item.data.string("subtitle").isEmpty, item.data.string("tertiary").isEmpty {
448
608
  mainStack.spacing = 0
@@ -556,32 +716,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
556
716
  }
557
717
  root.addArrangedSubview(trailingStack)
558
718
  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
- }
719
+ Self.configureTrailingStack(trailingStack, descriptors: accessories)
585
720
  trailingStack.bind(
586
721
  item, descriptors: accessories, theme: theme, style: item.data.dictionary("style") ?? [:],
587
722
  defaultSpacing: trailingStack.spacing, checkboxState: checkboxState, fonts: fonts)
@@ -590,12 +725,13 @@ final class NativeListIdentityCell: NativeListRendererCell {
590
725
  trailingStack.isHidden = false
591
726
  if let gap = trailingStack.contentGap { root.setCustomSpacing(gap, after: mainStack) }
592
727
  if let inset = trailingStack.endInset { rightInset = -inset }
593
- if item.data.string("presentation") == "accountSelector",
594
- accessories.count == 1,
728
+ if accessories.count == 1,
729
+ (item.data.string("presentation") == "accountSelector"
730
+ || accessories[0].string("kind") == "valuePair"),
595
731
  let accessory = trailingStack.firstVisibleControl
596
732
  {
597
733
  // The vertical trailing stack has no stable intrinsic width, so keep its
598
- // flexible space in the account title and subtitle column.
734
+ // flexible space in the title and subtitle column.
599
735
  let width = trailingStack.widthAnchor.constraint(equalTo: accessory.widthAnchor)
600
736
  width.isActive = true
601
737
  selectorConstraints.append(width)
@@ -21,6 +21,7 @@ final class NativeListLeadingVisual: UIView {
21
21
  private let cornerBackdrop = UIView()
22
22
  private var slots: [NativeListImageSlot] = []
23
23
  private var overlaySlots: [NativeListImageSlot] = []
24
+ private var overlayFallbackIcons: [UIImageView] = []
24
25
  private var overlays: [(UIView, [String: Any])] = []
25
26
  private let dashedBorder = CAShapeLayer()
26
27
  private var visual: [String: Any] = [:]
@@ -87,6 +88,7 @@ final class NativeListLeadingVisual: UIView {
87
88
  }
88
89
  let placeholder = theme?.string("strongBackground", default: "#0000000F") ?? "#0000000F"
89
90
  let fallbackIcon = visual.dictionary("fallbackIcon")
91
+ let fallbackBackground = fallbackIcon?.string("backgroundColor", default: placeholder) ?? placeholder
90
92
  let sourceFallback =
91
93
  kind != "icon" && !sources.isEmpty
92
94
  && sources[0].0.string("loadingStrategy", default: "none") != "none"
@@ -95,7 +97,8 @@ final class NativeListLeadingVisual: UIView {
95
97
  let restored = fallbackKey.map(NativeListSourceFallbackState.has) ?? false
96
98
  let fallbackData = kind == "icon" ? visual : fallbackIcon
97
99
  fallback.text = String(visual.string("fallbackText").prefix(2))
98
- fallback.textColor = UIColor(nativeListHex: "#8D8D8D", fallback: .gray)
100
+ fallback.textColor = UIColor(
101
+ nativeListHex: visual.string("fallbackTextColor", default: "#8D8D8D"), fallback: .gray)
99
102
  icon.image = fallbackData.map { nativeListIcon(named: $0.string("name")) } ?? nil
100
103
  icon.tintColor = UIColor(
101
104
  nativeListHex: fallbackData?.string("tintColor", default: "#646464") ?? "#646464",
@@ -106,7 +109,9 @@ final class NativeListLeadingVisual: UIView {
106
109
  nativeListHex: visual.string(
107
110
  "backgroundColor", default: sources.isEmpty ? placeholder : "#00000000"), fallback: .clear)
108
111
  backgroundColor =
109
- sourceFallback ? UIColor(nativeListHex: placeholder, fallback: .clear) : visualBackground
112
+ sources.isEmpty && fallbackIcon?["backgroundColor"] != nil || restored
113
+ ? UIColor(nativeListHex: fallbackBackground, fallback: .clear)
114
+ : sourceFallback ? UIColor(nativeListHex: placeholder, fallback: .clear) : visualBackground
110
115
  layer.borderWidth = kind == "icon" ? 1 / UIScreen.main.scale : 0
111
116
  layer.borderColor = UIColor(nativeListHex: "#0000001F", fallback: .clear).cgColor
112
117
  if bitmapBorderWidth > 0 {
@@ -121,7 +126,7 @@ final class NativeListLeadingVisual: UIView {
121
126
  continue
122
127
  }
123
128
  let source = sources[index]
124
- slot.view.isHidden = index > 0 || sourceFallback
129
+ slot.view.isHidden = index > 0 || restored
125
130
  slot.bind(
126
131
  source.0, key: "\(key):leading:\(index)", variant: source.1,
127
132
  fit: index == 0 ? style["contentFit"] as? String : nil, placeholder: placeholder
@@ -136,7 +141,7 @@ final class NativeListLeadingVisual: UIView {
136
141
  }
137
142
  }
138
143
  self.backgroundColor =
139
- loaded ? visualBackground : UIColor(nativeListHex: placeholder, fallback: .clear)
144
+ loaded ? visualBackground : UIColor(nativeListHex: fallbackBackground, fallback: .clear)
140
145
  self.fallback.isHidden = loaded || fallbackIcon != nil
141
146
  self.icon.isHidden = loaded || fallbackIcon == nil
142
147
  }
@@ -158,8 +163,17 @@ final class NativeListLeadingVisual: UIView {
158
163
  overlays.removeAll(keepingCapacity: true)
159
164
  let descriptors = Array(visual.dictionaries("overlays").prefix(2))
160
165
  while overlaySlots.count < descriptors.count { overlaySlots.append(NativeListImageSlot()) }
166
+ while overlayFallbackIcons.count < descriptors.count { overlayFallbackIcons.append(UIImageView()) }
161
167
  for (index, data) in descriptors.enumerated() {
162
168
  let frame = index < previousOverlays.count ? previousOverlays[index].0 : UIView()
169
+ let fallbackData = data.dictionary("fallbackIcon")
170
+ let fallbackGlyph = overlayFallbackIcons[index]
171
+ fallbackGlyph.image = fallbackData.flatMap { nativeListIcon(named: $0.string("name")) }
172
+ fallbackGlyph.tintColor = UIColor(
173
+ nativeListHex: fallbackData?.string("tintColor", default: "#646464") ?? "#646464",
174
+ fallback: .darkGray)
175
+ fallbackGlyph.contentMode = .scaleAspectFit
176
+ fallbackGlyph.isHidden = true
163
177
  frame.clipsToBounds = true
164
178
  frame.backgroundColor = UIColor(
165
179
  nativeListHex: data.string(
@@ -172,7 +186,9 @@ final class NativeListLeadingVisual: UIView {
172
186
  child = slot.view
173
187
  child.isHidden = true
174
188
  slot.bind(image, key: "\(key):overlay:\(index)", placeholder: placeholder) {
175
- [weak child] loaded in child?.isHidden = !loaded
189
+ [weak child, weak fallbackGlyph] loaded in
190
+ child?.isHidden = !loaded
191
+ fallbackGlyph?.isHidden = loaded || fallbackData == nil
176
192
  }
177
193
  } else if !data.string("text").isEmpty {
178
194
  overlaySlots[index].recycle()
@@ -181,7 +197,10 @@ final class NativeListLeadingVisual: UIView {
181
197
  label.textAlignment = .center
182
198
  // A line-height box is the legacy wallet text badge: regular weight, centered metrics.
183
199
  label.font = nativeListFont(
184
- ofSize: overlayTextFontSize, weight: overlayTextLineHeight == nil ? .medium : .regular,
200
+ ofSize: overlayTextFontSize,
201
+ weight: NativeListTextStyles.marketFontWeight(
202
+ data.string("fontWeight"),
203
+ fallback: overlayTextLineHeight == nil ? .medium : .regular),
185
204
  fonts: fonts)
186
205
  if let line = overlayTextLineHeight {
187
206
  let paragraph = NSMutableParagraphStyle()
@@ -207,10 +226,9 @@ final class NativeListLeadingVisual: UIView {
207
226
  nativeListHex: data.string("tintColor", default: "#646464"), fallback: .darkGray)
208
227
  child = glyph
209
228
  }
210
- if child.superview !== frame {
211
- frame.subviews.forEach { $0.removeFromSuperview() }
212
- frame.addSubview(child)
213
- }
229
+ frame.subviews.forEach { $0.removeFromSuperview() }
230
+ frame.addSubview(child)
231
+ if data.dictionary("image") != nil && fallbackData != nil { frame.addSubview(fallbackGlyph) }
214
232
  if frame.superview == nil { addSubview(frame) }
215
233
  overlays.append((frame, data))
216
234
  }
@@ -253,10 +271,16 @@ final class NativeListLeadingVisual: UIView {
253
271
  }
254
272
  fallback.frame = bounds
255
273
  let fallbackIcon = visual.dictionary("fallbackIcon")
274
+ let explicitFallbackSize: CGFloat? = fallbackIcon.flatMap { data in
275
+ guard data["size"] != nil else { return nil }
276
+ let size = data.double("size")
277
+ return size > 0 ? CGFloat(size) : nil
278
+ }
256
279
  let iconSize: CGFloat =
257
- !sources.isEmpty && fallbackIcon != nil
280
+ explicitFallbackSize
281
+ ?? (!sources.isEmpty && fallbackIcon != nil
258
282
  ? min(bounds.width, bounds.height)
259
- * (fallbackIcon?.string("name") == "GlobusOutline" ? 1.2 : 1) : glyphSize
283
+ * (fallbackIcon?.string("name") == "GlobusOutline" ? 1.2 : 1) : glyphSize)
260
284
  icon.frame = CGRect(
261
285
  x: (bounds.width - iconSize) / 2, y: (bounds.height - iconSize) / 2, width: iconSize,
262
286
  height: iconSize)
@@ -306,7 +330,8 @@ final class NativeListLeadingVisual: UIView {
306
330
  cornerBackdrop.frame = networkBackdrop.frame
307
331
  corner.frame = cornerBackdrop.frame.insetBy(dx: 1, dy: 1)
308
332
  unread.frame = logical(CGRect(x: bounds.width - 8, y: 0, width: 8, height: 8))
309
- for (frame, data) in overlays {
333
+ for (index, overlay) in overlays.enumerated() {
334
+ let (frame, data) = overlay
310
335
  let size = CGFloat(data.double("size", default: 20))
311
336
  // Legacy wallet text badges size to their text (tabular 12pt + 4) at the line height.
312
337
  let textBadgeLine =
@@ -331,9 +356,19 @@ final class NativeListLeadingVisual: UIView {
331
356
  height: height))
332
357
  frame.layer.cornerRadius = min(width, height) / 2
333
358
  let inset = CGFloat(data.double("padding", default: 0))
334
- frame.subviews.first?.frame = frame.bounds.insetBy(
359
+ let contentFrame = frame.bounds.insetBy(
335
360
  dx: data["text"] != nil ? overlayTextHorizontalInset ?? inset : inset,
336
361
  dy: data["text"] != nil && overlayTextHorizontalInset != nil ? 0 : inset)
362
+ frame.subviews.forEach { $0.frame = contentFrame }
363
+ let slot = overlaySlots[index].view
364
+ if data.dictionary("image") != nil {
365
+ let circularImage = inset > 0 && width == height
366
+ slot.layer.cornerRadius = circularImage ? min(contentFrame.width, contentFrame.height) / 2 : 0
367
+ slot.clipsToBounds = circularImage
368
+ } else {
369
+ slot.layer.cornerRadius = 0
370
+ slot.clipsToBounds = false
371
+ }
337
372
  }
338
373
  dashedBorder.isHidden = visual.string("borderStyle") != "dashed"
339
374
  dashedBorder.strokeColor =
@@ -29,7 +29,9 @@ enum NativeListMessageRenderer {
29
29
  body = NativeListResolvedText(
30
30
  item.data.string("body"), style: style.dictionary("body"), size: 14,
31
31
  color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 20,
32
- lines: item.data.int("bodyLines", default: 3), fonts: fonts)
32
+ lines: item.data.int("bodyLines", default: 3),
33
+ breakMode: item.data.int("bodyLines", default: 3) == 0 ? .byWordWrapping : .byTruncatingTail,
34
+ fonts: fonts)
33
35
  time = NativeListResolvedText(
34
36
  item.data.string("time"), style: style.dictionary("time"), size: 12,
35
37
  color: nativeListColor(theme, "disabledText", "#8D8D8D"), lineHeight: 16, lines: 1,
@@ -150,6 +152,11 @@ enum NativeListMessageRenderer {
150
152
  }
151
153
 
152
154
  final class NativeListMessageCell: NativeListRendererCell {
155
+ private let topWarningBorder = CALayer()
156
+ private let bottomWarningBorder = CALayer()
157
+ private var warningBorderWidth: CGFloat = 0
158
+ private var warningBorderColor = UIColor.clear
159
+ private var isInlineWarning = false
153
160
  override class func measure(
154
161
  _ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String,
155
162
  fonts: NativeListFontFamilies
@@ -167,6 +174,10 @@ final class NativeListMessageCell: NativeListRendererCell {
167
174
  _ item: NativeListItem, theme: [String: Any]?, layout: String,
168
175
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
169
176
  ) {
177
+ let container = item.data.dictionary("style")?.dictionary("container") ?? [:]
178
+ isInlineWarning = item.data.string("presentation") == "inlineWarning"
179
+ warningBorderWidth = isInlineWarning ? CGFloat(container.double("borderWidth")) : 0
180
+ warningBorderColor = UIColor(nativeListHex: container.string("borderColor"), fallback: .clear)
170
181
  let resolved = NativeListMessageRenderer.Resolved(
171
182
  item, theme: theme, layout: layout, fonts: fonts)
172
183
  views.bind(resolved, item: item, theme: theme, fonts: fonts)
@@ -174,5 +185,27 @@ final class NativeListMessageCell: NativeListRendererCell {
174
185
  top: resolved.verticalPadding, left: resolved.horizontalPadding,
175
186
  bottom: resolved.verticalPadding, right: resolved.horizontalPadding)
176
187
  }
188
+ override func applyAppearance() {
189
+ super.applyAppearance()
190
+ if isInlineWarning {
191
+ layer.cornerRadius = 0
192
+ contentView.layer.cornerRadius = 0
193
+ contentView.layer.borderWidth = 0
194
+ topWarningBorder.backgroundColor = warningBorderColor.cgColor
195
+ bottomWarningBorder.backgroundColor = warningBorderColor.cgColor
196
+ if topWarningBorder.superlayer == nil { contentView.layer.addSublayer(topWarningBorder) }
197
+ if bottomWarningBorder.superlayer == nil { contentView.layer.addSublayer(bottomWarningBorder) }
198
+ } else {
199
+ topWarningBorder.removeFromSuperlayer()
200
+ bottomWarningBorder.removeFromSuperlayer()
201
+ }
202
+ }
203
+ override func layoutSubviews() {
204
+ super.layoutSubviews()
205
+ let height = max(0, warningBorderWidth)
206
+ topWarningBorder.frame = CGRect(x: 0, y: 0, width: contentView.bounds.width, height: height)
207
+ bottomWarningBorder.frame = CGRect(
208
+ x: 0, y: contentView.bounds.height - height, width: contentView.bounds.width, height: height)
209
+ }
177
210
  override func recycleContent() { views.recycle() }
178
211
  }
@@ -1,9 +1,10 @@
1
1
  import Foundation
2
+ import CoreFoundation
2
3
  import UIKit
3
4
 
4
5
  // Template type alone partitions reuse; data keys and styles never select a renderer.
5
6
  enum NativeListRendererKey: String, CaseIterable {
6
- case message, rail, mediaTile, action, system, activity, dataRow, metricCard, market, identity, sectionHeader, walletGroup
7
+ case message, rail, mediaTile, action, buttonGroup, system, activity, dataRow, metricCard, market, identity, sectionHeader, walletGroup
7
8
  /// Not a template: legacy accepted any non-empty type and drew an empty row with the
8
9
  /// shared chrome. Unknown types keep that placeholder instead of failing the snapshot.
9
10
  case unsupported = "__nativeListUnsupported"
@@ -35,7 +36,7 @@ struct NativeListItem {
35
36
  }
36
37
 
37
38
  var isRowPressEnabled: Bool {
38
- !data.bool("disabled") &&
39
+ type != "buttonGroup" && !data.bool("disabled") &&
39
40
  !data.bool("pressDisabled") &&
40
41
  (type != "system" || data.string("variant") == "retry")
41
42
  }
@@ -78,7 +79,18 @@ struct NativeListItem {
78
79
  }
79
80
 
80
81
  struct NativeListConfig {
82
+ struct StructuralTransition {
83
+ let id: String
84
+ let duration: TimeInterval
85
+ let anchorKey: String?
86
+ }
87
+ struct Disclosure {
88
+ let expanded: Bool
89
+ let expandedTrailingInset: CGFloat
90
+ }
81
91
  let generation: Int
92
+ let structuralTransition: StructuralTransition?
93
+ let disclosure: Disclosure?
82
94
  let layout: String
83
95
  let orientation: String
84
96
  let gridColumns: Int
@@ -129,6 +141,32 @@ struct NativeListConfig {
129
141
  let capabilities = root["capabilities"] as? [String: Any]
130
142
  let sectionIndex = capabilities?["sectionIndex"] as? [String: Any]
131
143
  let footer = try (root["fixedFooter"] as? [String: Any]).map(NativeListItem.init)
144
+ let transition = root["structuralTransition"] as? [String: Any]
145
+ let structuralTransition = (transition?["id"] as? String).map { id in
146
+ StructuralTransition(
147
+ id: id,
148
+ duration: min(2, max(0, (transition?["durationMs"] as? Double ?? 220) / 1000)),
149
+ anchorKey: transition?["anchorKey"] as? String)
150
+ }
151
+ let disclosure: Disclosure?
152
+ if let value = root["disclosure"] {
153
+ guard let data = value as? [String: Any],
154
+ let expandedNumber = data["expanded"] as? NSNumber,
155
+ CFGetTypeID(expandedNumber) == CFBooleanGetTypeID() else {
156
+ throw NativeListModelError.invalidSnapshot
157
+ }
158
+ let insetNumber = data["expandedTrailingInset"] as? NSNumber
159
+ guard data["expandedTrailingInset"] == nil || insetNumber != nil,
160
+ insetNumber.map({ CFGetTypeID($0) != CFBooleanGetTypeID() }) ?? true else {
161
+ throw NativeListModelError.invalidSnapshot
162
+ }
163
+ let inset = insetNumber?.doubleValue ?? 0
164
+ guard inset.isFinite, inset >= 0 else { throw NativeListModelError.invalidSnapshot }
165
+ disclosure = Disclosure(expanded: expandedNumber.boolValue,
166
+ expandedTrailingInset: CGFloat(inset))
167
+ } else {
168
+ disclosure = nil
169
+ }
132
170
 
133
171
  let contentPadding = max(0, CGFloat(layoutData.double("contentPadding")))
134
172
  let contentPaddingHorizontal = layoutData["contentPaddingHorizontal"] == nil
@@ -143,6 +181,8 @@ struct NativeListConfig {
143
181
 
144
182
  return NativeListConfig(
145
183
  generation: generation,
184
+ structuralTransition: structuralTransition,
185
+ disclosure: disclosure,
146
186
  layout: layout,
147
187
  orientation: layoutData["orientation"] as? String ?? "vertical",
148
188
  gridColumns: min(7, max(1, layoutData["gridColumns"] as? Int ?? 1)),
@@ -18,6 +18,7 @@ enum NativeListRendererRegistry {
18
18
  .activity: (NativeListActivityCell.self, { NativeListActivityCell(frame: .zero) }),
19
19
  .system: (NativeListSystemCell.self, { NativeListSystemCell(frame: .zero) }),
20
20
  .action: (NativeListActionCell.self, { NativeListActionCell(frame: .zero) }),
21
+ .buttonGroup: (NativeListButtonGroupCell.self, { NativeListButtonGroupCell(frame: .zero) }),
21
22
  .unsupported: (
22
23
  NativeListUnsupportedCell.self, { NativeListUnsupportedCell(frame: .zero) }
23
24
  ),
@@ -26,7 +26,8 @@ struct NativeListResolvedText {
26
26
  let style = style ?? [:]
27
27
  self.tabular = tabular
28
28
  self.preservesBreakMode = preservesBreakMode
29
- self.lines = min(3, max(1, style.int("lines", default: lines)))
29
+ let requestedLines = style.int("lines", default: lines)
30
+ self.lines = requestedLines == 0 ? 0 : min(3, max(1, requestedLines))
30
31
  explicitTruncation = style["lines"] != nil || style["truncate"] != nil
31
32
  text =
32
33
  self.lines == 1 && explicitTruncation
@@ -42,6 +42,20 @@ class NativeListRowHost: UICollectionViewCell {
42
42
  var listStyle: [String: Any]?
43
43
  var onAction: ((NativeListItem, String, NativeSelectionTarget?, NativeListActionOrigin?) -> Void)?
44
44
  var onBindingInvalidated: ((NativeListRowHost, Int) -> Void)?
45
+ var structuralContentHeight: CGFloat?
46
+
47
+ override func layoutSubviews() {
48
+ super.layoutSubviews()
49
+ // UIKit relays out cells again when the collection's offset changes.
50
+ if let structuralContentHeight {
51
+ contentView.frame = CGRect(x: 0, y: 0, width: bounds.width, height: structuralContentHeight)
52
+ }
53
+ }
54
+
55
+ override func prepareForReuse() {
56
+ super.prepareForReuse()
57
+ structuralContentHeight = nil
58
+ }
45
59
 
46
60
  func bind(
47
61
  item: NativeListItem, theme: [String: Any]?, layout: String, itemIndex: Int? = nil,