@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.
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +245 -9
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +35 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +147 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +51 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
- package/docs/ROW_TEMPLATES.md +70 -11
- package/docs/SPEC.md +1235 -20
- package/docs/STYLE_SPEC.md +6 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +235 -39
- package/ios/NativeListActivityDetailsView.swift +30 -11
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +155 -27
- package/ios/NativeListDesignAssets.swift +9 -0
- package/ios/NativeListIdentityRenderer.swift +239 -31
- package/ios/NativeListLeadingVisual.swift +119 -22
- package/ios/NativeListMarketRenderer.swift +113 -18
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListModels.swift +42 -2
- package/ios/NativeListRendererRegistry.swift +1 -0
- package/ios/NativeListResolvedText.swift +2 -1
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +88 -0
- package/ios/RNCNativeListView.swift +1052 -58
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/icon.svg +1 -0
- package/ios/tests/NativeListAccessoryStackTests.swift +89 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
- package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
- package/ios/tests/NativeListLifecycleTests.swift +2789 -3
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/lib/module/NativeList.js +223 -36
- package/lib/module/NativeList.web.js +260 -33
- package/lib/module/index.js +1 -1
- package/lib/module/models.js +3 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +1386 -81
- package/lib/module/web/NativeListWebEngine.js +914 -80
- package/lib/module/web/templates/ActivityRowRenderer.js +487 -7
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +40 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +145 -5
- package/lib/module/web/templates/MarketRowRenderer.js +8 -3
- package/lib/module/web/templates/MarketTableRowRenderer.js +577 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
- package/lib/module/web/templates/MessageRowRenderer.js +18 -2
- package/lib/module/web/templates/RowContainerStyle.js +1 -0
- package/lib/module/web/templates/RowRendererRegistry.js +8 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +70 -3
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/lib/typescript/src/NativeList.d.ts +3 -3
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
- package/lib/typescript/src/NativeList.types.d.ts +29 -1
- package/lib/typescript/src/NativeList.web.d.ts +2 -2
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +196 -17
- package/lib/typescript/src/validation.d.ts +20 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +58 -1
- package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
- package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +10 -4
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/package.json +3 -3
- package/react-native-native-list.podspec +1 -0
- package/src/NativeList.nitro.ts +2 -0
- package/src/NativeList.tsx +418 -89
- package/src/NativeList.types.ts +34 -1
- package/src/NativeList.web.tsx +417 -66
- package/src/index.ts +2 -0
- package/src/models.ts +355 -143
- package/src/selection.ts +1 -0
- package/src/validation.ts +3315 -166
- package/src/web/NativeListWebEngine.ts +1473 -113
- package/src/web/templates/ActivityRowRenderer.ts +732 -8
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +217 -6
- package/src/web/templates/MarketRowRenderer.ts +19 -3
- package/src/web/templates/MarketTableRowRenderer.ts +755 -0
- package/src/web/templates/MediaTileRowRenderer.ts +313 -5
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +21 -6
- package/src/web/templates/SectionHeaderRowRenderer.ts +89 -5
|
@@ -17,19 +17,26 @@ final class NativeListLeadingVisual: UIView {
|
|
|
17
17
|
private let icon = UIImageView()
|
|
18
18
|
private let unread = UIView()
|
|
19
19
|
private let networkBackdrop = UIView()
|
|
20
|
+
// Ring under the secondary token of an Activity pair (SPEC "Activity leading pair").
|
|
21
|
+
private let pairBackdrop = UIView()
|
|
20
22
|
private let corner = UIImageView()
|
|
21
23
|
private let cornerBackdrop = UIView()
|
|
22
24
|
private var slots: [NativeListImageSlot] = []
|
|
23
25
|
private var overlaySlots: [NativeListImageSlot] = []
|
|
26
|
+
private var overlayFallbackIcons: [UIImageView] = []
|
|
24
27
|
private var overlays: [(UIView, [String: Any])] = []
|
|
25
28
|
private let dashedBorder = CAShapeLayer()
|
|
26
29
|
private var visual: [String: Any] = [:]
|
|
27
30
|
private var imageStyle: [String: Any] = [:]
|
|
28
31
|
private var sources: [([String: Any], String)] = []
|
|
32
|
+
// Roles inside `sources`: the token `networkImage` badge and the Activity
|
|
33
|
+
// `secondaryLeading` token; nil when absent.
|
|
34
|
+
private var networkIndex: Int?
|
|
35
|
+
private var pairIndex: Int?
|
|
29
36
|
|
|
30
37
|
override init(frame: CGRect) {
|
|
31
38
|
super.init(frame: frame)
|
|
32
|
-
[fallback, icon, networkBackdrop, cornerBackdrop, corner, unread].forEach(addSubview)
|
|
39
|
+
[fallback, icon, pairBackdrop, networkBackdrop, cornerBackdrop, corner, unread].forEach(addSubview)
|
|
33
40
|
fallback.textAlignment = .center
|
|
34
41
|
fallback.font = nativeListFont(ofSize: 13, weight: .bold, fonts: fonts)
|
|
35
42
|
icon.contentMode = .scaleAspectFit
|
|
@@ -56,11 +63,14 @@ final class NativeListLeadingVisual: UIView {
|
|
|
56
63
|
kind == "token"
|
|
57
64
|
? "token"
|
|
58
65
|
: kind == "network" ? "network" : ["account", "wallet"].contains(kind) ? "avatar" : "generic"
|
|
66
|
+
networkIndex = nil
|
|
67
|
+
pairIndex = nil
|
|
59
68
|
sources =
|
|
60
69
|
kind == "stackedImages"
|
|
61
70
|
? visual.dictionaries("images").prefix(3).map { ($0, "generic") }
|
|
62
71
|
: kind == "icon" ? [] : visual.dictionary("image").map { [($0, variant)] } ?? []
|
|
63
72
|
if kind == "token", !sources.isEmpty, let network = visual.dictionary("networkImage") {
|
|
73
|
+
networkIndex = sources.count
|
|
64
74
|
sources.append((network, "network"))
|
|
65
75
|
}
|
|
66
76
|
if let secondaryVisual {
|
|
@@ -70,6 +80,9 @@ final class NativeListLeadingVisual: UIView {
|
|
|
70
80
|
? secondaryVisual.dictionaries("images").first
|
|
71
81
|
: secondaryKind == "icon" ? nil : secondaryVisual.dictionary("image")
|
|
72
82
|
if let source {
|
|
83
|
+
// A second token forms a pair only next to a primary image; without one
|
|
84
|
+
// it simply takes the primary's place (OK-66071).
|
|
85
|
+
if kind == "token", !sources.isEmpty { pairIndex = sources.count }
|
|
73
86
|
sources.append(
|
|
74
87
|
(
|
|
75
88
|
source,
|
|
@@ -87,6 +100,7 @@ final class NativeListLeadingVisual: UIView {
|
|
|
87
100
|
}
|
|
88
101
|
let placeholder = theme?.string("strongBackground", default: "#0000000F") ?? "#0000000F"
|
|
89
102
|
let fallbackIcon = visual.dictionary("fallbackIcon")
|
|
103
|
+
let fallbackBackground = fallbackIcon?.string("backgroundColor", default: placeholder) ?? placeholder
|
|
90
104
|
let sourceFallback =
|
|
91
105
|
kind != "icon" && !sources.isEmpty
|
|
92
106
|
&& sources[0].0.string("loadingStrategy", default: "none") != "none"
|
|
@@ -95,7 +109,8 @@ final class NativeListLeadingVisual: UIView {
|
|
|
95
109
|
let restored = fallbackKey.map(NativeListSourceFallbackState.has) ?? false
|
|
96
110
|
let fallbackData = kind == "icon" ? visual : fallbackIcon
|
|
97
111
|
fallback.text = String(visual.string("fallbackText").prefix(2))
|
|
98
|
-
fallback.textColor = UIColor(
|
|
112
|
+
fallback.textColor = UIColor(
|
|
113
|
+
nativeListHex: visual.string("fallbackTextColor", default: "#8D8D8D"), fallback: .gray)
|
|
99
114
|
icon.image = fallbackData.map { nativeListIcon(named: $0.string("name")) } ?? nil
|
|
100
115
|
icon.tintColor = UIColor(
|
|
101
116
|
nativeListHex: fallbackData?.string("tintColor", default: "#646464") ?? "#646464",
|
|
@@ -106,7 +121,9 @@ final class NativeListLeadingVisual: UIView {
|
|
|
106
121
|
nativeListHex: visual.string(
|
|
107
122
|
"backgroundColor", default: sources.isEmpty ? placeholder : "#00000000"), fallback: .clear)
|
|
108
123
|
backgroundColor =
|
|
109
|
-
|
|
124
|
+
sources.isEmpty && fallbackIcon?["backgroundColor"] != nil || restored
|
|
125
|
+
? UIColor(nativeListHex: fallbackBackground, fallback: .clear)
|
|
126
|
+
: sourceFallback ? UIColor(nativeListHex: placeholder, fallback: .clear) : visualBackground
|
|
110
127
|
layer.borderWidth = kind == "icon" ? 1 / UIScreen.main.scale : 0
|
|
111
128
|
layer.borderColor = UIColor(nativeListHex: "#0000001F", fallback: .clear).cgColor
|
|
112
129
|
if bitmapBorderWidth > 0 {
|
|
@@ -121,12 +138,13 @@ final class NativeListLeadingVisual: UIView {
|
|
|
121
138
|
continue
|
|
122
139
|
}
|
|
123
140
|
let source = sources[index]
|
|
124
|
-
slot.view.isHidden = index > 0 ||
|
|
141
|
+
slot.view.isHidden = index > 0 || restored
|
|
125
142
|
slot.bind(
|
|
126
143
|
source.0, key: "\(key):leading:\(index)", variant: source.1,
|
|
127
144
|
fit: index == 0 ? style["contentFit"] as? String : nil, placeholder: placeholder
|
|
128
145
|
) { [weak self, weak slot] loaded in
|
|
129
146
|
slot?.view.isHidden = !loaded && (index > 0 || sourceFallback)
|
|
147
|
+
if let self, index == self.pairIndex { self.syncPairBackdrop() }
|
|
130
148
|
guard let self, index == 0, sourceFallback else { return }
|
|
131
149
|
if let fallbackKey {
|
|
132
150
|
if loaded {
|
|
@@ -136,13 +154,24 @@ final class NativeListLeadingVisual: UIView {
|
|
|
136
154
|
}
|
|
137
155
|
}
|
|
138
156
|
self.backgroundColor =
|
|
139
|
-
loaded ? visualBackground : UIColor(nativeListHex:
|
|
157
|
+
loaded ? visualBackground : UIColor(nativeListHex: fallbackBackground, fallback: .clear)
|
|
140
158
|
self.fallback.isHidden = loaded || fallbackIcon != nil
|
|
141
159
|
self.icon.isHidden = loaded || fallbackIcon == nil
|
|
142
160
|
}
|
|
143
161
|
}
|
|
144
|
-
networkBackdrop.isHidden =
|
|
162
|
+
networkBackdrop.isHidden = networkIndex == nil
|
|
145
163
|
networkBackdrop.backgroundColor = nativeListColor(theme, "rowBackground", "#FFFFFF")
|
|
164
|
+
pairBackdrop.backgroundColor = nativeListColor(theme, "rowBackground", "#FFFFFF")
|
|
165
|
+
syncPairBackdrop()
|
|
166
|
+
// Stacking order by role: primary, pair ring, secondary token, badge
|
|
167
|
+
// backdrop, badge, corner icon. Slots are reused across binds with
|
|
168
|
+
// different roles, so the order is restored on every bind.
|
|
169
|
+
bringSubviewToFront(pairBackdrop)
|
|
170
|
+
if let pairIndex { bringSubviewToFront(slots[pairIndex].view) }
|
|
171
|
+
bringSubviewToFront(networkBackdrop)
|
|
172
|
+
if let networkIndex { bringSubviewToFront(slots[networkIndex].view) }
|
|
173
|
+
bringSubviewToFront(cornerBackdrop)
|
|
174
|
+
bringSubviewToFront(corner)
|
|
146
175
|
let badge = visual.dictionary("cornerIcon")
|
|
147
176
|
corner.isHidden = badge == nil
|
|
148
177
|
cornerBackdrop.isHidden = badge == nil
|
|
@@ -158,8 +187,17 @@ final class NativeListLeadingVisual: UIView {
|
|
|
158
187
|
overlays.removeAll(keepingCapacity: true)
|
|
159
188
|
let descriptors = Array(visual.dictionaries("overlays").prefix(2))
|
|
160
189
|
while overlaySlots.count < descriptors.count { overlaySlots.append(NativeListImageSlot()) }
|
|
190
|
+
while overlayFallbackIcons.count < descriptors.count { overlayFallbackIcons.append(UIImageView()) }
|
|
161
191
|
for (index, data) in descriptors.enumerated() {
|
|
162
192
|
let frame = index < previousOverlays.count ? previousOverlays[index].0 : UIView()
|
|
193
|
+
let fallbackData = data.dictionary("fallbackIcon")
|
|
194
|
+
let fallbackGlyph = overlayFallbackIcons[index]
|
|
195
|
+
fallbackGlyph.image = fallbackData.flatMap { nativeListIcon(named: $0.string("name")) }
|
|
196
|
+
fallbackGlyph.tintColor = UIColor(
|
|
197
|
+
nativeListHex: fallbackData?.string("tintColor", default: "#646464") ?? "#646464",
|
|
198
|
+
fallback: .darkGray)
|
|
199
|
+
fallbackGlyph.contentMode = .scaleAspectFit
|
|
200
|
+
fallbackGlyph.isHidden = true
|
|
163
201
|
frame.clipsToBounds = true
|
|
164
202
|
frame.backgroundColor = UIColor(
|
|
165
203
|
nativeListHex: data.string(
|
|
@@ -172,7 +210,9 @@ final class NativeListLeadingVisual: UIView {
|
|
|
172
210
|
child = slot.view
|
|
173
211
|
child.isHidden = true
|
|
174
212
|
slot.bind(image, key: "\(key):overlay:\(index)", placeholder: placeholder) {
|
|
175
|
-
[weak child] loaded in
|
|
213
|
+
[weak child, weak fallbackGlyph] loaded in
|
|
214
|
+
child?.isHidden = !loaded
|
|
215
|
+
fallbackGlyph?.isHidden = loaded || fallbackData == nil
|
|
176
216
|
}
|
|
177
217
|
} else if !data.string("text").isEmpty {
|
|
178
218
|
overlaySlots[index].recycle()
|
|
@@ -181,7 +221,10 @@ final class NativeListLeadingVisual: UIView {
|
|
|
181
221
|
label.textAlignment = .center
|
|
182
222
|
// A line-height box is the legacy wallet text badge: regular weight, centered metrics.
|
|
183
223
|
label.font = nativeListFont(
|
|
184
|
-
ofSize: overlayTextFontSize,
|
|
224
|
+
ofSize: overlayTextFontSize,
|
|
225
|
+
weight: NativeListTextStyles.marketFontWeight(
|
|
226
|
+
data.string("fontWeight"),
|
|
227
|
+
fallback: overlayTextLineHeight == nil ? .medium : .regular),
|
|
185
228
|
fonts: fonts)
|
|
186
229
|
if let line = overlayTextLineHeight {
|
|
187
230
|
let paragraph = NSMutableParagraphStyle()
|
|
@@ -207,11 +250,10 @@ final class NativeListLeadingVisual: UIView {
|
|
|
207
250
|
nativeListHex: data.string("tintColor", default: "#646464"), fallback: .darkGray)
|
|
208
251
|
child = glyph
|
|
209
252
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
if frame.superview == nil { addSubview(frame) }
|
|
253
|
+
frame.subviews.forEach { $0.removeFromSuperview() }
|
|
254
|
+
frame.addSubview(child)
|
|
255
|
+
if data.dictionary("image") != nil && fallbackData != nil { frame.addSubview(fallbackGlyph) }
|
|
256
|
+
if frame.superview == nil { addSubview(frame) } else { bringSubviewToFront(frame) }
|
|
215
257
|
overlays.append((frame, data))
|
|
216
258
|
}
|
|
217
259
|
previousOverlays.dropFirst(descriptors.count).forEach { $0.0.removeFromSuperview() }
|
|
@@ -253,20 +295,35 @@ final class NativeListLeadingVisual: UIView {
|
|
|
253
295
|
}
|
|
254
296
|
fallback.frame = bounds
|
|
255
297
|
let fallbackIcon = visual.dictionary("fallbackIcon")
|
|
298
|
+
let explicitFallbackSize: CGFloat? = fallbackIcon.flatMap { data in
|
|
299
|
+
guard data["size"] != nil else { return nil }
|
|
300
|
+
let size = data.double("size")
|
|
301
|
+
return size > 0 ? CGFloat(size) : nil
|
|
302
|
+
}
|
|
256
303
|
let iconSize: CGFloat =
|
|
257
|
-
|
|
304
|
+
explicitFallbackSize
|
|
305
|
+
?? (!sources.isEmpty && fallbackIcon != nil
|
|
258
306
|
? min(bounds.width, bounds.height)
|
|
259
|
-
* (fallbackIcon?.string("name") == "GlobusOutline" ? 1.2 : 1) : glyphSize
|
|
307
|
+
* (fallbackIcon?.string("name") == "GlobusOutline" ? 1.2 : 1) : glyphSize)
|
|
260
308
|
icon.frame = CGRect(
|
|
261
309
|
x: (bounds.width - iconSize) / 2, y: (bounds.height - iconSize) / 2, width: iconSize,
|
|
262
310
|
height: iconSize)
|
|
263
|
-
|
|
311
|
+
// Same geometry as Android's `nativeListLeadingSlotFrame` (SPEC "Activity leading pair").
|
|
312
|
+
let pairMember = (bounds.height * 0.6).rounded()
|
|
313
|
+
let pairRing: CGFloat = 2
|
|
264
314
|
for (index, slot) in slots.prefix(sources.count).enumerated() {
|
|
265
315
|
let frame: CGRect
|
|
266
|
-
if
|
|
267
|
-
frame = bounds
|
|
268
|
-
} else if tokenPair {
|
|
316
|
+
if index == networkIndex {
|
|
269
317
|
frame = CGRect(x: bounds.width - 14, y: bounds.height - 14, width: 16, height: 16)
|
|
318
|
+
} else if pairIndex != nil {
|
|
319
|
+
frame =
|
|
320
|
+
index == pairIndex
|
|
321
|
+
? CGRect(
|
|
322
|
+
x: bounds.width - pairMember - pairRing, y: bounds.height - pairMember - pairRing,
|
|
323
|
+
width: pairMember, height: pairMember)
|
|
324
|
+
: CGRect(x: 0, y: 0, width: pairMember, height: pairMember)
|
|
325
|
+
} else if sources.count == 1 || networkIndex != nil {
|
|
326
|
+
frame = bounds
|
|
270
327
|
} else {
|
|
271
328
|
let side = bounds.height * 0.72
|
|
272
329
|
frame = CGRect(
|
|
@@ -278,10 +335,23 @@ final class NativeListLeadingVisual: UIView {
|
|
|
278
335
|
slot.view.clipsToBounds =
|
|
279
336
|
!(singleOuterMask && sources.count == 1 && overlays.isEmpty
|
|
280
337
|
&& visual.dictionary("cornerIcon") == nil)
|
|
338
|
+
let fillsFrame = index == 0 && pairIndex == nil && (sources.count == 1 || networkIndex != nil)
|
|
339
|
+
// Pair members keep the token shape at their own size (rounded NFTs use
|
|
340
|
+
// the box's 10pt rule scaled to the member).
|
|
341
|
+
let pairRadius: CGFloat = shape == "rounded" ? min(10, frame.height / 4) : frame.height / 2
|
|
281
342
|
slot.view.layer.cornerRadius =
|
|
282
343
|
index == 0 && singleOuterMask && sources.count == 1 && overlays.isEmpty
|
|
283
344
|
&& visual.dictionary("cornerIcon") == nil
|
|
284
|
-
? 0
|
|
345
|
+
? 0
|
|
346
|
+
: fillsFrame
|
|
347
|
+
? radius : pairIndex != nil && index != networkIndex ? pairRadius : frame.height / 2
|
|
348
|
+
}
|
|
349
|
+
if pairIndex != nil {
|
|
350
|
+
let box = pairMember + 2 * pairRing
|
|
351
|
+
pairBackdrop.frame = logical(
|
|
352
|
+
CGRect(x: bounds.width - box, y: bounds.height - box, width: box, height: box))
|
|
353
|
+
pairBackdrop.layer.cornerRadius =
|
|
354
|
+
shape == "rounded" ? min(10, pairMember / 4) + pairRing : box / 2
|
|
285
355
|
}
|
|
286
356
|
for (index, slot) in slots.enumerated() {
|
|
287
357
|
if index == 0 && bitmapBorderWidth > 0 {
|
|
@@ -306,7 +376,8 @@ final class NativeListLeadingVisual: UIView {
|
|
|
306
376
|
cornerBackdrop.frame = networkBackdrop.frame
|
|
307
377
|
corner.frame = cornerBackdrop.frame.insetBy(dx: 1, dy: 1)
|
|
308
378
|
unread.frame = logical(CGRect(x: bounds.width - 8, y: 0, width: 8, height: 8))
|
|
309
|
-
for (
|
|
379
|
+
for (index, overlay) in overlays.enumerated() {
|
|
380
|
+
let (frame, data) = overlay
|
|
310
381
|
let size = CGFloat(data.double("size", default: 20))
|
|
311
382
|
// Legacy wallet text badges size to their text (tabular 12pt + 4) at the line height.
|
|
312
383
|
let textBadgeLine =
|
|
@@ -331,9 +402,19 @@ final class NativeListLeadingVisual: UIView {
|
|
|
331
402
|
height: height))
|
|
332
403
|
frame.layer.cornerRadius = min(width, height) / 2
|
|
333
404
|
let inset = CGFloat(data.double("padding", default: 0))
|
|
334
|
-
|
|
405
|
+
let contentFrame = frame.bounds.insetBy(
|
|
335
406
|
dx: data["text"] != nil ? overlayTextHorizontalInset ?? inset : inset,
|
|
336
407
|
dy: data["text"] != nil && overlayTextHorizontalInset != nil ? 0 : inset)
|
|
408
|
+
frame.subviews.forEach { $0.frame = contentFrame }
|
|
409
|
+
let slot = overlaySlots[index].view
|
|
410
|
+
if data.dictionary("image") != nil {
|
|
411
|
+
let circularImage = inset > 0 && width == height
|
|
412
|
+
slot.layer.cornerRadius = circularImage ? min(contentFrame.width, contentFrame.height) / 2 : 0
|
|
413
|
+
slot.clipsToBounds = circularImage
|
|
414
|
+
} else {
|
|
415
|
+
slot.layer.cornerRadius = 0
|
|
416
|
+
slot.clipsToBounds = false
|
|
417
|
+
}
|
|
337
418
|
}
|
|
338
419
|
dashedBorder.isHidden = visual.string("borderStyle") != "dashed"
|
|
339
420
|
dashedBorder.strokeColor =
|
|
@@ -346,9 +427,22 @@ final class NativeListLeadingVisual: UIView {
|
|
|
346
427
|
UIBezierPath(ovalIn: bounds.insetBy(dx: dashedBorderWidth / 2, dy: dashedBorderWidth / 2))
|
|
347
428
|
.cgPath
|
|
348
429
|
}
|
|
430
|
+
/// The pair ring sits above the primary token, so it is shown only while the
|
|
431
|
+
/// secondary token image is actually displayed: hidden while that image loads,
|
|
432
|
+
/// after a failed load and once the slot is recycled, or it would cover the
|
|
433
|
+
/// primary's lower-right corner with a blank row-background disc.
|
|
434
|
+
private func syncPairBackdrop() {
|
|
435
|
+
guard let pairIndex, slots.indices.contains(pairIndex) else {
|
|
436
|
+
pairBackdrop.isHidden = true
|
|
437
|
+
return
|
|
438
|
+
}
|
|
439
|
+
pairBackdrop.isHidden = slots[pairIndex].view.isHidden
|
|
440
|
+
}
|
|
441
|
+
|
|
349
442
|
func recycle() {
|
|
350
443
|
slots.forEach { $0.recycle() }
|
|
351
444
|
overlaySlots.forEach { $0.recycle() }
|
|
445
|
+
pairBackdrop.isHidden = true
|
|
352
446
|
}
|
|
353
447
|
/// Empty slot (legacy leading container without a visual): no image, fallback, fill,
|
|
354
448
|
/// border or overlays from a previous binding.
|
|
@@ -364,6 +458,9 @@ final class NativeListLeadingVisual: UIView {
|
|
|
364
458
|
icon.image = nil
|
|
365
459
|
icon.isHidden = true
|
|
366
460
|
networkBackdrop.isHidden = true
|
|
461
|
+
pairBackdrop.isHidden = true
|
|
462
|
+
networkIndex = nil
|
|
463
|
+
pairIndex = nil
|
|
367
464
|
corner.isHidden = true
|
|
368
465
|
cornerBackdrop.isHidden = true
|
|
369
466
|
unread.isHidden = true
|
|
@@ -22,6 +22,15 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
22
22
|
private let marketSubtitleStack = UIStackView()
|
|
23
23
|
private let marketSubtitleSpacer = UIView()
|
|
24
24
|
private let trailingStack = UIStackView()
|
|
25
|
+
private let metricStacks = (0..<3).map { _ -> UIStackView in
|
|
26
|
+
let stack = UIStackView()
|
|
27
|
+
stack.axis = .vertical
|
|
28
|
+
stack.alignment = .fill
|
|
29
|
+
stack.spacing = 2
|
|
30
|
+
return stack
|
|
31
|
+
}
|
|
32
|
+
private let metricPrimaryLabels = (0..<3).map { _ in NativeListTextLabel() }
|
|
33
|
+
private let metricSecondaryLabels = (0..<3).map { _ in NativeListTextLabel() }
|
|
25
34
|
private let accessoryButtons = (0..<2).map { _ in NativeListAccessoryButton(type: .system) }
|
|
26
35
|
private let marketBadgeButtons = (0..<3).map { _ in NativeListAccessoryButton(type: .system) }
|
|
27
36
|
private let badgeSlots = (0..<3).map { _ in NativeListImageSlot() }
|
|
@@ -69,6 +78,10 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
69
78
|
trailingStack.setContentHuggingPriority(.required, for: .horizontal)
|
|
70
79
|
trailingStack.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
71
80
|
accessoryButtons.forEach(trailingStack.addArrangedSubview)
|
|
81
|
+
for index in metricStacks.indices {
|
|
82
|
+
metricStacks[index].addArrangedSubview(metricPrimaryLabels[index])
|
|
83
|
+
metricStacks[index].addArrangedSubview(metricSecondaryLabels[index])
|
|
84
|
+
}
|
|
72
85
|
visual.translatesAutoresizingMaskIntoConstraints = false
|
|
73
86
|
leadingWidth = visual.widthAnchor.constraint(equalToConstant: 32)
|
|
74
87
|
leadingHeight = visual.heightAnchor.constraint(equalToConstant: 32)
|
|
@@ -130,6 +143,14 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
130
143
|
}
|
|
131
144
|
}
|
|
132
145
|
accessoryButtons.forEach(resetButton)
|
|
146
|
+
for label in metricPrimaryLabels + metricSecondaryLabels {
|
|
147
|
+
label.attributedText = nil
|
|
148
|
+
label.text = nil
|
|
149
|
+
label.isHidden = true
|
|
150
|
+
label.numberOfLines = 1
|
|
151
|
+
label.lineBreakMode = .byTruncatingTail
|
|
152
|
+
label.textAlignment = .natural
|
|
153
|
+
}
|
|
133
154
|
bindMarket(item, theme: theme)
|
|
134
155
|
let style = item.data.dictionary("style")
|
|
135
156
|
for (label, descriptor) in [
|
|
@@ -166,20 +187,38 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
166
187
|
style.filter { ["lines", "truncate", "verticalAlignment", "offsetY"].contains($0.key) }
|
|
167
188
|
}
|
|
168
189
|
override func accessibilityText(_ item: NativeListItem) -> String {
|
|
169
|
-
item.data
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
190
|
+
if let label = item.data["accessibilityLabel"] as? String { return label }
|
|
191
|
+
var parts = [item.data.string("title"), item.data.string("subtitle")]
|
|
192
|
+
let metrics = item.data.dictionaries("metrics")
|
|
193
|
+
if metrics.count == 2 || metrics.count == 3 {
|
|
194
|
+
for index in metrics.indices {
|
|
195
|
+
for label in [metricPrimaryLabels[index], metricSecondaryLabels[index]] where !label.isHidden {
|
|
196
|
+
if let text = label.text { parts.append(text) }
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
parts.append(item.data.string("price"))
|
|
201
|
+
parts.append(item.data.dictionary("change")?.string("text") ?? "")
|
|
202
|
+
}
|
|
203
|
+
return parts.filter { !$0.isEmpty }.joined(separator: ", ")
|
|
175
204
|
}
|
|
176
205
|
override func updateMarketQuote(_ item: NativeListItem, theme: [String: Any]?) {
|
|
177
206
|
guard retainBoundItem(item) else { return }
|
|
178
|
-
|
|
207
|
+
let metrics = item.data.dictionaries("metrics")
|
|
208
|
+
if metrics.count == 2 || metrics.count == 3 {
|
|
209
|
+
updateMetricLabels(metrics, theme: theme)
|
|
210
|
+
} else {
|
|
211
|
+
bindQuote(item, theme: theme)
|
|
212
|
+
}
|
|
213
|
+
accessibilityLabel = accessibilityText(item)
|
|
179
214
|
}
|
|
180
215
|
override func recycleContent() {
|
|
181
216
|
visual.recycle()
|
|
182
217
|
badgeSlots.forEach { $0.recycle() }
|
|
218
|
+
for label in metricPrimaryLabels + metricSecondaryLabels {
|
|
219
|
+
label.attributedText = nil
|
|
220
|
+
label.text = nil
|
|
221
|
+
}
|
|
183
222
|
imageSignature = ""
|
|
184
223
|
}
|
|
185
224
|
@objc private func leadingPressed() {
|
|
@@ -256,6 +295,61 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
256
295
|
default: return .natural
|
|
257
296
|
}
|
|
258
297
|
}
|
|
298
|
+
private func metricColor(_ tone: String, theme: [String: Any]?) -> UIColor {
|
|
299
|
+
switch tone {
|
|
300
|
+
case "positive": return nativeListColor(theme, "positive", "#218358")
|
|
301
|
+
case "negative": return nativeListColor(theme, "negative", "#CE2C31")
|
|
302
|
+
case "secondary": return nativeListColor(theme, "secondaryText", "#646464")
|
|
303
|
+
default: return nativeListColor(theme, "primaryText", "#202020")
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
private func bindMetrics(
|
|
307
|
+
_ columns: [[String: Any]], theme: [String: Any]?, gap: CGFloat
|
|
308
|
+
) {
|
|
309
|
+
for (index, column) in columns.enumerated() {
|
|
310
|
+
let stack = metricStacks[index]
|
|
311
|
+
root.addArrangedSubview(stack)
|
|
312
|
+
root.setCustomSpacing(gap, after: stack)
|
|
313
|
+
let weight = max(1, min(3, column.int("weight", default: 1)))
|
|
314
|
+
let width = stack.widthAnchor.constraint(
|
|
315
|
+
equalTo: mainStack.widthAnchor, multiplier: CGFloat(weight) / 2)
|
|
316
|
+
width.isActive = true
|
|
317
|
+
selectorConstraints.append(width)
|
|
318
|
+
}
|
|
319
|
+
updateMetricLabels(columns, theme: theme)
|
|
320
|
+
}
|
|
321
|
+
private func updateMetricLabels(_ columns: [[String: Any]], theme: [String: Any]?) {
|
|
322
|
+
for (index, column) in columns.enumerated() {
|
|
323
|
+
let alignment = marketTextAlignment(column.string("alignment", default: "end"))
|
|
324
|
+
let primary = metricPrimaryLabels[index]
|
|
325
|
+
let primaryText = column.string("text")
|
|
326
|
+
show(primary, primaryText, lines: 1)
|
|
327
|
+
let primaryColor = metricColor(column.string("tone"), theme: theme)
|
|
328
|
+
applyMarketTextStyle(
|
|
329
|
+
primary, data: nil, theme: theme, defaultSize: 14, defaultLineHeight: 20,
|
|
330
|
+
defaultWeight: .medium, defaultColor: primaryColor, defaultAlignment: alignment)
|
|
331
|
+
if !column.dictionaries("textSegments").isEmpty {
|
|
332
|
+
primary.attributedText = marketAttributedText(
|
|
333
|
+
primaryText, segments: column.dictionaries("textSegments"), style: nil,
|
|
334
|
+
defaultSize: 14, defaultLineHeight: 20, defaultWeight: .medium,
|
|
335
|
+
color: primaryColor, defaultAlignment: alignment)
|
|
336
|
+
}
|
|
337
|
+
let secondary = metricSecondaryLabels[index]
|
|
338
|
+
let secondaryText = column.string("secondaryText")
|
|
339
|
+
show(secondary, secondaryText, lines: 1)
|
|
340
|
+
let secondaryColor = metricColor(
|
|
341
|
+
column.string("secondaryTone", default: "secondary"), theme: theme)
|
|
342
|
+
applyMarketTextStyle(
|
|
343
|
+
secondary, data: nil, theme: theme, defaultSize: 12, defaultLineHeight: 16,
|
|
344
|
+
defaultWeight: .regular, defaultColor: secondaryColor, defaultAlignment: alignment)
|
|
345
|
+
if !column.dictionaries("secondaryTextSegments").isEmpty {
|
|
346
|
+
secondary.attributedText = marketAttributedText(
|
|
347
|
+
secondaryText, segments: column.dictionaries("secondaryTextSegments"), style: nil,
|
|
348
|
+
defaultSize: 12, defaultLineHeight: 16, defaultWeight: .regular,
|
|
349
|
+
color: secondaryColor, defaultAlignment: alignment)
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
259
353
|
private func applyMarketTextStyle(
|
|
260
354
|
_ label: UILabel,
|
|
261
355
|
data: [String: Any]?,
|
|
@@ -623,11 +717,18 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
623
717
|
}
|
|
624
718
|
marketSubtitleStack.isHidden = tertiaryLabel.isHidden && subtitleLabel.isHidden
|
|
625
719
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
720
|
+
let metrics = item.data.dictionaries("metrics")
|
|
721
|
+
if metrics.count == 2 || metrics.count == 3 {
|
|
722
|
+
let metricGap = CGFloat(style?.double("trailingGap", default: 8) ?? 8)
|
|
723
|
+
root.setCustomSpacing(metricGap, after: mainStack)
|
|
724
|
+
bindMetrics(metrics, theme: theme, gap: metricGap)
|
|
725
|
+
} else {
|
|
726
|
+
root.addArrangedSubview(trailingStack)
|
|
727
|
+
trailingStack.axis = .horizontal
|
|
728
|
+
trailingStack.alignment = .center
|
|
729
|
+
trailingStack.spacing = CGFloat(style?.double("trailingGap", default: 8) ?? 8)
|
|
730
|
+
bindQuote(item, theme: theme)
|
|
731
|
+
}
|
|
631
732
|
}
|
|
632
733
|
private func bindQuote(_ item: NativeListItem, theme: [String: Any]?) {
|
|
633
734
|
NSLayoutConstraint.deactivate(accessorySizeConstraints)
|
|
@@ -696,11 +797,5 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
696
797
|
if let changeStyle = style?.dictionary("change"), !textLayoutStyle(changeStyle).isEmpty {
|
|
697
798
|
NativeListTextStyles.applyStyledButton(change, textLayoutStyle(changeStyle), fonts: fonts)
|
|
698
799
|
}
|
|
699
|
-
accessibilityLabel = item.data.string(
|
|
700
|
-
"accessibilityLabel",
|
|
701
|
-
default: [
|
|
702
|
-
item.data.string("title"), item.data.string("subtitle"), item.data.string("price"),
|
|
703
|
-
changeData.string("text"),
|
|
704
|
-
].filter { !$0.isEmpty }.joined(separator: ", "))
|
|
705
800
|
}
|
|
706
801
|
}
|
|
@@ -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),
|
|
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
|
-
|
|
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
|