@onekeyfe/react-native-native-list 3.0.179-alpha.304 → 3.0.179
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/README.md +3 -32
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +1 -22
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +8 -8
- package/android/src/main/java/com/onekey/nativelist/NativeListActionRenderer.kt +5 -5
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +4 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +6 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +1 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +11 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +20 -20
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +4 -5
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +7 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +5 -5
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +7 -8
- package/android/src/main/java/com/onekey/nativelist/NativeListMetricCardRenderer.kt +14 -14
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +15 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListRailRenderer.kt +4 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +3 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +4 -5
- package/android/src/main/java/com/onekey/nativelist/NativeListRowHost.kt +1 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +20 -20
- package/android/src/main/java/com/onekey/nativelist/NativeListSystemRenderer.kt +3 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +18 -104
- package/android/src/main/java/com/onekey/nativelist/NativeListWalletGroupRenderer.kt +5 -6
- package/common/fonts/Roobert-Bold.ttf +0 -0
- package/common/fonts/Roobert-Medium.ttf +0 -0
- package/common/fonts/Roobert-Regular.ttf +0 -0
- package/common/fonts/Roobert-SemiBold.ttf +0 -0
- package/docs/SPEC.md +0 -69
- package/docs/STYLE_SPEC.md +2 -12
- package/ios/HybridNativeList.swift +6 -18
- package/ios/NativeListAccessoryStack.swift +10 -14
- package/ios/NativeListActionRenderer.swift +4 -7
- package/ios/NativeListActivityDetailsView.swift +24 -63
- package/ios/NativeListActivityRenderer.swift +10 -19
- package/ios/NativeListDataRowRenderer.swift +19 -23
- package/ios/NativeListDesignAssets.swift +34 -43
- package/ios/NativeListIdentityRenderer.swift +19 -23
- package/ios/NativeListLeadingVisual.swift +4 -9
- package/ios/NativeListMarketRenderer.swift +11 -19
- package/ios/NativeListMediaTileRenderer.swift +7 -11
- package/ios/NativeListMessageRenderer.swift +10 -20
- package/ios/NativeListMetricCardRenderer.swift +12 -16
- package/ios/NativeListRailRenderer.swift +7 -9
- package/ios/NativeListRendererCell.swift +4 -6
- package/ios/NativeListRendererRegistry.swift +3 -8
- package/ios/NativeListResolvedText.swift +3 -3
- package/ios/NativeListRowHost.swift +2 -7
- package/ios/NativeListSectionHeaderRenderer.swift +19 -22
- package/ios/NativeListSystemRenderer.swift +16 -18
- package/ios/NativeListTextStyles.swift +12 -18
- package/ios/NativeListWalletGroupRenderer.swift +4 -6
- package/ios/RNCNativeListView.swift +5 -38
- package/ios/tests/NativeListActivityPresentationTests.swift +3 -5
- package/ios/tests/NativeListLifecycleTests.swift +2 -77
- package/lib/module/NativeList.js +0 -3
- package/lib/module/NativeList.web.js +1 -8
- package/lib/module/index.js +0 -1
- package/lib/module/web/NativeListWebEngine.js +24 -48
- package/lib/module/web/templates/ActionRowRenderer.js +1 -2
- package/lib/module/web/templates/IdentityRowRenderer.js +3 -4
- package/lib/module/web/templates/MarketRowRenderer.js +1 -2
- package/lib/module/web/templates/RowText.js +3 -13
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +2 -3
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +0 -9
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +0 -2
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +0 -5
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +0 -6
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +0 -7
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +0 -6
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +0 -1
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +0 -11
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +0 -2
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +0 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +0 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +0 -3
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +0 -1
- package/lib/typescript/src/NativeList.nitro.d.ts +0 -1
- package/lib/typescript/src/index.d.ts +0 -2
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +1 -4
- package/lib/typescript/src/web/templates/RowText.d.ts +0 -1
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +0 -9
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +0 -2
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +0 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +0 -6
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +0 -7
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +0 -6
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +0 -1
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +0 -11
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +0 -2
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +0 -2
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +0 -2
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +0 -3
- package/nitrogen/generated/shared/json/NativeListConfig.json +0 -1
- package/package.json +5 -4
- package/react-native-native-list.podspec +1 -0
- package/src/NativeList.nitro.ts +0 -1
- package/src/NativeList.tsx +0 -3
- package/src/NativeList.web.tsx +1 -10
- package/src/index.ts +0 -3
- package/src/web/NativeListWebEngine.ts +24 -53
- package/src/web/templates/ActionRowRenderer.ts +1 -2
- package/src/web/templates/IdentityRowRenderer.ts +3 -4
- package/src/web/templates/MarketRowRenderer.ts +2 -4
- package/src/web/templates/RowText.ts +3 -15
- package/src/web/templates/SectionHeaderRowRenderer.ts +3 -6
- package/LICENSE +0 -36
- package/lib/module/fonts.js +0 -44
- package/lib/typescript/src/fonts.d.ts +0 -10
- package/src/fonts.ts +0 -64
|
@@ -5,8 +5,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
5
5
|
!["walletSidebar", "networkSelector"].contains(item.data.string("presentation"))
|
|
6
6
|
}
|
|
7
7
|
override class func measure(
|
|
8
|
-
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
9
|
-
fonts: NativeListFontFamilies
|
|
8
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
10
9
|
) -> CGFloat? {
|
|
11
10
|
if item.data.string("presentation") == "walletSidebar" {
|
|
12
11
|
return item.data.dictionaries("badges").isEmpty ? 68 : 92
|
|
@@ -150,14 +149,14 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
150
149
|
text.rowVerticalAlignment = nil
|
|
151
150
|
}
|
|
152
151
|
}
|
|
153
|
-
titleLabel.font = nativeListFont(ofSize: 16, weight: .medium
|
|
152
|
+
titleLabel.font = nativeListFont(ofSize: 16, weight: .medium)
|
|
154
153
|
titleLabel.textColor = nativeListColor(theme, "primaryText", "#202020")
|
|
155
154
|
titleLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
156
|
-
subtitleLabel.font = nativeListFont(ofSize: 14
|
|
155
|
+
subtitleLabel.font = nativeListFont(ofSize: 14)
|
|
157
156
|
subtitleLabel.textColor = nativeListColor(theme, "secondaryText", "#646464")
|
|
158
|
-
tertiaryLabel.font = nativeListFont(ofSize: 14
|
|
157
|
+
tertiaryLabel.font = nativeListFont(ofSize: 14)
|
|
159
158
|
tertiaryLabel.textColor = subtitleLabel.textColor
|
|
160
|
-
badgeLabel.font = nativeListFont(ofSize: 12, weight: .medium
|
|
159
|
+
badgeLabel.font = nativeListFont(ofSize: 12, weight: .medium)
|
|
161
160
|
badgeLabel.horizontalInset = 0
|
|
162
161
|
badgeLabel.topInset = 0
|
|
163
162
|
badgeLabel.bottomInset = 0
|
|
@@ -166,7 +165,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
166
165
|
leadingHeight.constant = 40
|
|
167
166
|
visual.glyphSize = 18
|
|
168
167
|
fallbackLabel.attributedText = nil
|
|
169
|
-
fallbackLabel.font = nativeListFont(ofSize: 13, weight: .bold
|
|
168
|
+
fallbackLabel.font = nativeListFont(ofSize: 13, weight: .bold)
|
|
170
169
|
trailingStack.reset()
|
|
171
170
|
trailingStack.axis = .vertical
|
|
172
171
|
trailingStack.alignment = .trailing
|
|
@@ -207,7 +206,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
207
206
|
("badge", semanticBadgeLabels.isEmpty ? [badgeLabel] : semanticBadgeLabels),
|
|
208
207
|
] {
|
|
209
208
|
if let text = style.dictionary(slot) {
|
|
210
|
-
labels.forEach { NativeListTextStyles.applyStyledText($0, text
|
|
209
|
+
labels.forEach { NativeListTextStyles.applyStyledText($0, text) }
|
|
211
210
|
}
|
|
212
211
|
}
|
|
213
212
|
contentInsets = UIEdgeInsets(
|
|
@@ -239,7 +238,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
239
238
|
titleLabel.attributedText = text
|
|
240
239
|
}
|
|
241
240
|
if let style = item.data.dictionary("style")?.dictionary("title") {
|
|
242
|
-
NativeListTextStyles.applyStyledText(titleLabel, style
|
|
241
|
+
NativeListTextStyles.applyStyledText(titleLabel, style)
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
244
|
}
|
|
@@ -300,8 +299,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
300
299
|
? min(leadingWidth.constant, leadingHeight.constant)
|
|
301
300
|
* (fallback.string("name") == "GlobusOutline" ? 1.2 : 1) : 18
|
|
302
301
|
}
|
|
303
|
-
visual.bind(
|
|
304
|
-
descriptor, style: image, key: key, theme: currentTheme, isUnread: false, fonts: fonts)
|
|
302
|
+
visual.bind(descriptor, style: image, key: key, theme: currentTheme, isUnread: false)
|
|
305
303
|
}
|
|
306
304
|
private func bindIdentity(
|
|
307
305
|
_ item: NativeListItem,
|
|
@@ -322,9 +320,9 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
322
320
|
titleRowStack.setContentHuggingPriority(.required, for: .horizontal)
|
|
323
321
|
titleLabel.setContentHuggingPriority(.required, for: .horizontal)
|
|
324
322
|
titleLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
325
|
-
titleLabel.font = nativeListFont(ofSize: 12
|
|
323
|
+
titleLabel.font = nativeListFont(ofSize: 12)
|
|
326
324
|
titleLabel.textAlignment = .center
|
|
327
|
-
fallbackLabel.font = nativeListFont(ofSize: 28
|
|
325
|
+
fallbackLabel.font = nativeListFont(ofSize: 28)
|
|
328
326
|
addLeading(item.data.dictionary("leading"), key: item.key)
|
|
329
327
|
root.addArrangedSubview(mainStack)
|
|
330
328
|
// OneKey patch: activate width constraints only after both stacks share an ancestor.
|
|
@@ -357,7 +355,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
357
355
|
let label = NativeListInsetLabel()
|
|
358
356
|
let isSelector = item.hasExplicitHeight
|
|
359
357
|
let isWarning = badge.string("tone") == "warning"
|
|
360
|
-
label.font = nativeListFont(ofSize: isSelector ? 11 : 12
|
|
358
|
+
label.font = nativeListFont(ofSize: isSelector ? 11 : 12)
|
|
361
359
|
label.textColor = nativeListColor(
|
|
362
360
|
theme, isSelector && isWarning ? "caution" : "secondaryText",
|
|
363
361
|
isSelector && isWarning ? "#AB6400" : "#646464")
|
|
@@ -389,14 +387,14 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
389
387
|
trailingStack.bind(
|
|
390
388
|
item, descriptors: accessories, theme: theme,
|
|
391
389
|
style: item.data.dictionary("style") ?? [:], defaultSpacing: 8,
|
|
392
|
-
checkboxState: checkboxState
|
|
390
|
+
checkboxState: checkboxState)
|
|
393
391
|
}
|
|
394
392
|
return
|
|
395
393
|
}
|
|
396
394
|
if item.data.string("presentation") == "accountSelector" {
|
|
397
395
|
leadingWidth.constant = 32
|
|
398
396
|
leadingHeight.constant = 32
|
|
399
|
-
titleLabel.font = nativeListFont(ofSize: 16
|
|
397
|
+
titleLabel.font = nativeListFont(ofSize: 16)
|
|
400
398
|
}
|
|
401
399
|
if item.data.dictionary("leading")?.string("kind") == "network" {
|
|
402
400
|
leadingWidth.constant = 32
|
|
@@ -434,7 +432,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
434
432
|
let leading = item.data.dictionary("leading"), leading.dictionary("image") == nil,
|
|
435
433
|
leading.dictionary("fallbackIcon") == nil, !leading.string("fallbackText").isEmpty
|
|
436
434
|
{
|
|
437
|
-
fallbackLabel.font = nativeListFont(ofSize: 19, weight: .semibold
|
|
435
|
+
fallbackLabel.font = nativeListFont(ofSize: 19, weight: .semibold)
|
|
438
436
|
fallbackLabel.textColor = nativeListColor(theme, "inverseText", "#FCFCFC")
|
|
439
437
|
setLineHeight(fallbackLabel, text: leading.string("fallbackText"), lineHeight: 27)
|
|
440
438
|
}
|
|
@@ -479,7 +477,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
479
477
|
line.addArrangedSubview(gap)
|
|
480
478
|
}
|
|
481
479
|
let label = NativeListTextLabel()
|
|
482
|
-
label.font = nativeListFont(ofSize: 14
|
|
480
|
+
label.font = nativeListFont(ofSize: 14)
|
|
483
481
|
label.lineBreakMode = .byTruncatingTail
|
|
484
482
|
// Match V1: the balance may shrink, but keep the shortened address intact.
|
|
485
483
|
label.setContentCompressionResistancePriority(
|
|
@@ -501,12 +499,10 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
501
499
|
NSAttributedString(
|
|
502
500
|
string: run.string("text"),
|
|
503
501
|
attributes: [
|
|
504
|
-
.font: nativeListFont(
|
|
505
|
-
ofSize: run.string("style") == "subscript" ? 9 : 14, fonts: fonts),
|
|
502
|
+
.font: nativeListFont(ofSize: run.string("style") == "subscript" ? 9 : 14),
|
|
506
503
|
.foregroundColor: label.textColor as Any,
|
|
507
504
|
.paragraphStyle: paragraph,
|
|
508
|
-
.baselineOffset: max(
|
|
509
|
-
0, (20 - nativeListFont(ofSize: 14, fonts: fonts).lineHeight) / 2)
|
|
505
|
+
.baselineOffset: max(0, (20 - nativeListFont(ofSize: 14).lineHeight) / 2),
|
|
510
506
|
]))
|
|
511
507
|
}
|
|
512
508
|
label.attributedText = value
|
|
@@ -584,7 +580,7 @@ final class NativeListIdentityCell: NativeListRendererCell {
|
|
|
584
580
|
}
|
|
585
581
|
trailingStack.bind(
|
|
586
582
|
item, descriptors: accessories, theme: theme, style: item.data.dictionary("style") ?? [:],
|
|
587
|
-
defaultSpacing: trailingStack.spacing, checkboxState: checkboxState
|
|
583
|
+
defaultSpacing: trailingStack.spacing, checkboxState: checkboxState)
|
|
588
584
|
// Legacy kept the (possibly empty) trailing stack arranged, so the text column always
|
|
589
585
|
// ends 12 points before the trailing edge inset.
|
|
590
586
|
trailingStack.isHidden = false
|
|
@@ -3,7 +3,6 @@ import UIKit
|
|
|
3
3
|
// Bounded visual primitive: three source slots, two optional overlays. It knows
|
|
4
4
|
// visual descriptors and request lifetimes, never row types or business keys.
|
|
5
5
|
final class NativeListLeadingVisual: UIView {
|
|
6
|
-
var fonts = NativeListFontFamilies()
|
|
7
6
|
var glyphSize: CGFloat = 18
|
|
8
7
|
var bitmapBorderWidth: CGFloat = 0
|
|
9
8
|
private let fallback = NativeListTextLabel()
|
|
@@ -31,7 +30,7 @@ final class NativeListLeadingVisual: UIView {
|
|
|
31
30
|
super.init(frame: frame)
|
|
32
31
|
[fallback, icon, networkBackdrop, cornerBackdrop, corner, unread].forEach(addSubview)
|
|
33
32
|
fallback.textAlignment = .center
|
|
34
|
-
fallback.font = nativeListFont(ofSize: 13, weight: .bold
|
|
33
|
+
fallback.font = nativeListFont(ofSize: 13, weight: .bold)
|
|
35
34
|
icon.contentMode = .scaleAspectFit
|
|
36
35
|
corner.contentMode = .scaleAspectFit
|
|
37
36
|
unread.backgroundColor = UIColor(nativeListHex: "#E5484D", fallback: .red)
|
|
@@ -44,11 +43,8 @@ final class NativeListLeadingVisual: UIView {
|
|
|
44
43
|
|
|
45
44
|
func bind(
|
|
46
45
|
_ visual: [String: Any], style: [String: Any], key: String, theme: [String: Any]?,
|
|
47
|
-
isUnread: Bool, secondaryVisual: [String: Any]? = nil
|
|
48
|
-
fonts: NativeListFontFamilies
|
|
46
|
+
isUnread: Bool, secondaryVisual: [String: Any]? = nil
|
|
49
47
|
) {
|
|
50
|
-
self.fonts = fonts
|
|
51
|
-
fallback.font = nativeListFont(ofSize: 13, weight: .bold, fonts: fonts)
|
|
52
48
|
self.visual = visual
|
|
53
49
|
imageStyle = style
|
|
54
50
|
let kind = visual.string("kind")
|
|
@@ -181,8 +177,7 @@ final class NativeListLeadingVisual: UIView {
|
|
|
181
177
|
label.textAlignment = .center
|
|
182
178
|
// A line-height box is the legacy wallet text badge: regular weight, centered metrics.
|
|
183
179
|
label.font = nativeListFont(
|
|
184
|
-
ofSize: overlayTextFontSize, weight: overlayTextLineHeight == nil ? .medium : .regular
|
|
185
|
-
fonts: fonts)
|
|
180
|
+
ofSize: overlayTextFontSize, weight: overlayTextLineHeight == nil ? .medium : .regular)
|
|
186
181
|
if let line = overlayTextLineHeight {
|
|
187
182
|
let paragraph = NSMutableParagraphStyle()
|
|
188
183
|
paragraph.minimumLineHeight = line
|
|
@@ -315,7 +310,7 @@ final class NativeListLeadingVisual: UIView {
|
|
|
315
310
|
let naturalWidth = textBadgeLine.map { _ -> CGFloat in
|
|
316
311
|
let scale = max(1, window?.screen.scale ?? traitCollection.displayScale)
|
|
317
312
|
let textWidth = (data.string("text") as NSString).size(withAttributes: [
|
|
318
|
-
.font: nativeListTabularFont(ofSize: overlayTextFontSize
|
|
313
|
+
.font: nativeListTabularFont(ofSize: overlayTextFontSize), .kern: 0,
|
|
319
314
|
]).width
|
|
320
315
|
return ceil(textWidth * scale) / scale + 4
|
|
321
316
|
}
|
|
@@ -2,8 +2,7 @@ import UIKit
|
|
|
2
2
|
|
|
3
3
|
final class NativeListMarketCell: NativeListRendererCell {
|
|
4
4
|
override class func measure(
|
|
5
|
-
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
6
|
-
fonts: NativeListFontFamilies
|
|
5
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
7
6
|
) -> CGFloat? {
|
|
8
7
|
let style = item.data.dictionary("style")
|
|
9
8
|
let stock = item.data.string("variant") == "stock"
|
|
@@ -136,9 +135,7 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
136
135
|
(titleLabel, style?.dictionary("title")), (subtitleLabel, style?.dictionary("subtitle")),
|
|
137
136
|
(tertiaryLabel, item.data.dictionary("subtitlePrefix")?.dictionary("style")),
|
|
138
137
|
] {
|
|
139
|
-
if let descriptor {
|
|
140
|
-
NativeListTextStyles.applyStyledText(label, textLayoutStyle(descriptor), fonts: fonts)
|
|
141
|
-
}
|
|
138
|
+
if let descriptor { NativeListTextStyles.applyStyledText(label, textLayoutStyle(descriptor)) }
|
|
142
139
|
}
|
|
143
140
|
root.alignment =
|
|
144
141
|
style?.dictionary("container")?.string("contentVerticalAlignment") == "top"
|
|
@@ -272,8 +269,7 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
272
269
|
data?.double("lineHeight", default: Double(defaultLineHeight)) ?? Double(defaultLineHeight))
|
|
273
270
|
label.font = nativeListTabularFont(
|
|
274
271
|
ofSize: size,
|
|
275
|
-
weight: marketFontWeight(data?.string("fontWeight") ?? "", fallback: defaultWeight)
|
|
276
|
-
fonts: fonts)
|
|
272
|
+
weight: marketFontWeight(data?.string("fontWeight") ?? "", fallback: defaultWeight))
|
|
277
273
|
label.textColor =
|
|
278
274
|
data?["color"].flatMap { $0 as? String }.map {
|
|
279
275
|
UIColor(nativeListHex: $0, fallback: defaultColor)
|
|
@@ -303,8 +299,7 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
303
299
|
text: button.title(for: .normal) ?? "",
|
|
304
300
|
font: nativeListTabularFont(
|
|
305
301
|
ofSize: size,
|
|
306
|
-
weight: marketFontWeight(data?.string("fontWeight") ?? "", fallback: defaultWeight),
|
|
307
|
-
fonts: fonts),
|
|
302
|
+
weight: marketFontWeight(data?.string("fontWeight") ?? "", fallback: defaultWeight)),
|
|
308
303
|
color: data?["color"].flatMap { $0 as? String }.map {
|
|
309
304
|
UIColor(nativeListHex: $0, fallback: color)
|
|
310
305
|
} ?? color,
|
|
@@ -354,14 +349,12 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
354
349
|
NSAttributedString(
|
|
355
350
|
string: segment.string("text"),
|
|
356
351
|
attributes: [
|
|
357
|
-
.font: nativeListTabularFont(ofSize: segmentSize, weight: weight
|
|
352
|
+
.font: nativeListTabularFont(ofSize: segmentSize, weight: weight),
|
|
358
353
|
.foregroundColor: resolvedColor,
|
|
359
354
|
.kern: 0,
|
|
360
355
|
.paragraphStyle: paragraph,
|
|
361
356
|
.baselineOffset: max(
|
|
362
|
-
0,
|
|
363
|
-
(lineHeight
|
|
364
|
-
- nativeListTabularFont(ofSize: size, weight: weight, fonts: fonts).lineHeight) / 2)
|
|
357
|
+
0, (lineHeight - nativeListTabularFont(ofSize: size, weight: weight).lineHeight) / 2),
|
|
365
358
|
]))
|
|
366
359
|
}
|
|
367
360
|
return result
|
|
@@ -432,8 +425,7 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
432
425
|
? 8 : Double(min(imageWidth, imageHeight) / 2))
|
|
433
426
|
?? Double(min(imageWidth, imageHeight) / 2)
|
|
434
427
|
visual.bitmapBorderWidth = descriptor.string("borderColor").isEmpty ? 0 : 1
|
|
435
|
-
visual.bind(
|
|
436
|
-
descriptor, style: resolved, key: item.key, theme: theme, isUnread: false, fonts: fonts)
|
|
428
|
+
visual.bind(descriptor, style: resolved, key: item.key, theme: theme, isUnread: false)
|
|
437
429
|
root.addArrangedSubview(visual)
|
|
438
430
|
let signature = NativeListImageSlot.signature([
|
|
439
431
|
"key": item.key, "visual": descriptor, "fit": resolved["contentFit"] ?? NSNull(),
|
|
@@ -480,8 +472,8 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
480
472
|
// OneKey patch: SizableText supplies tabular numerals for explicit Market metrics.
|
|
481
473
|
let badgeFont =
|
|
482
474
|
badgeStyle == nil
|
|
483
|
-
? nativeListFont(ofSize: badgeFontSize, weight: badgeFontWeight
|
|
484
|
-
: nativeListTabularFont(ofSize: badgeFontSize, weight: badgeFontWeight
|
|
475
|
+
? nativeListFont(ofSize: badgeFontSize, weight: badgeFontWeight)
|
|
476
|
+
: nativeListTabularFont(ofSize: badgeFontSize, weight: badgeFontWeight)
|
|
485
477
|
let hasBuiltInIcon = badge.string("iconName") == "verified"
|
|
486
478
|
let hasRemoteIcon = badge.dictionary("icon") != nil
|
|
487
479
|
let hasIcon = hasBuiltInIcon || hasRemoteIcon
|
|
@@ -691,10 +683,10 @@ final class NativeListMarketCell: NativeListRendererCell {
|
|
|
691
683
|
height.isActive = true
|
|
692
684
|
accessorySizeConstraints.append(contentsOf: [width, height])
|
|
693
685
|
if let priceStyle = style?.dictionary("price"), !textLayoutStyle(priceStyle).isEmpty {
|
|
694
|
-
NativeListTextStyles.applyStyledButton(price, textLayoutStyle(priceStyle)
|
|
686
|
+
NativeListTextStyles.applyStyledButton(price, textLayoutStyle(priceStyle))
|
|
695
687
|
}
|
|
696
688
|
if let changeStyle = style?.dictionary("change"), !textLayoutStyle(changeStyle).isEmpty {
|
|
697
|
-
NativeListTextStyles.applyStyledButton(change, textLayoutStyle(changeStyle)
|
|
689
|
+
NativeListTextStyles.applyStyledButton(change, textLayoutStyle(changeStyle))
|
|
698
690
|
}
|
|
699
691
|
accessibilityLabel = item.data.string(
|
|
700
692
|
"accessibilityLabel",
|
|
@@ -2,8 +2,7 @@ import UIKit
|
|
|
2
2
|
|
|
3
3
|
final class NativeListMediaTileCell: NativeListRendererCell {
|
|
4
4
|
override class func measure(
|
|
5
|
-
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
6
|
-
fonts: NativeListFontFamilies
|
|
5
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
7
6
|
) -> CGFloat? {
|
|
8
7
|
return 244
|
|
9
8
|
}
|
|
@@ -98,23 +97,20 @@ final class NativeListMediaTileCell: NativeListRendererCell {
|
|
|
98
97
|
NativeListResolvedText(
|
|
99
98
|
item.data.string("title"), style: style.dictionary("title"), size: 16,
|
|
100
99
|
weight: .medium, color: nativeListColor(theme, "primaryText", "#202020"),
|
|
101
|
-
lineHeight: nativeListFont(ofSize: 16, weight: .medium
|
|
102
|
-
lines: 1, preservesBreakMode: true
|
|
103
|
-
fonts: fonts
|
|
100
|
+
lineHeight: nativeListFont(ofSize: 16, weight: .medium).lineHeight,
|
|
101
|
+
lines: 1, preservesBreakMode: true
|
|
104
102
|
).bind(title)
|
|
105
103
|
NativeListResolvedText(
|
|
106
104
|
item.data.string("subtitle"), style: style.dictionary("subtitle"), size: 12,
|
|
107
105
|
color: nativeListColor(theme, "secondaryText", "#646464"),
|
|
108
|
-
lineHeight: nativeListFont(ofSize: 12
|
|
109
|
-
preservesBreakMode: true, fonts: fonts
|
|
106
|
+
lineHeight: nativeListFont(ofSize: 12).lineHeight, lines: 1, preservesBreakMode: true
|
|
110
107
|
).bind(subtitle)
|
|
111
108
|
let badgeText = item.data.dictionary("badge")?.string("text") ?? ""
|
|
112
109
|
NativeListResolvedText(
|
|
113
110
|
badgeText.isEmpty ? "" : " \(badgeText) ", style: style.dictionary("badge"), size: 14,
|
|
114
111
|
weight: .medium, color: nativeListColor(theme, "inverseText", "#FCFCFC"),
|
|
115
|
-
lineHeight: nativeListFont(ofSize: 14, weight: .medium
|
|
116
|
-
lines: 1, preservesBreakMode: true
|
|
117
|
-
fonts: fonts
|
|
112
|
+
lineHeight: nativeListFont(ofSize: 14, weight: .medium).lineHeight,
|
|
113
|
+
lines: 1, preservesBreakMode: true
|
|
118
114
|
).bind(badge)
|
|
119
115
|
if style.dictionary("badge")?["alignment"] == nil { badge.textAlignment = .center }
|
|
120
116
|
badge.backgroundColor = nativeListColor(theme, "inverseBackground", "#202020")
|
|
@@ -162,7 +158,7 @@ final class NativeListMediaTileCell: NativeListRendererCell {
|
|
|
162
158
|
closeKey = item.data.string("closeActionKey")
|
|
163
159
|
closeStack.isHidden = closeKey.isEmpty
|
|
164
160
|
close.setTitle("×", for: .normal)
|
|
165
|
-
close.titleLabel?.font = nativeListFont(ofSize: 16, weight: .medium
|
|
161
|
+
close.titleLabel?.font = nativeListFont(ofSize: 16, weight: .medium)
|
|
166
162
|
close.setTitleColor(nativeListColor(theme, "primaryText", "#202020"), for: .normal)
|
|
167
163
|
}
|
|
168
164
|
override func layoutSubviews() {
|
|
@@ -18,22 +18,19 @@ enum NativeListMessageRenderer {
|
|
|
18
18
|
let unread: Bool
|
|
19
19
|
let alignment: UIStackView.Alignment
|
|
20
20
|
|
|
21
|
-
init(
|
|
22
|
-
_ item: NativeListItem, theme: [String: Any]?, layout: String, fonts: NativeListFontFamilies
|
|
23
|
-
) {
|
|
21
|
+
init(_ item: NativeListItem, theme: [String: Any]?, layout: String) {
|
|
24
22
|
let style = item.data.dictionary("style") ?? [:]
|
|
25
23
|
title = NativeListResolvedText(
|
|
26
24
|
item.data.string("title"), style: style.dictionary("title"), size: 14, weight: .semibold,
|
|
27
|
-
color: nativeListColor(theme, "primaryText", "#202020"), lineHeight: 20, lines: 2
|
|
28
|
-
fonts: fonts)
|
|
25
|
+
color: nativeListColor(theme, "primaryText", "#202020"), lineHeight: 20, lines: 2)
|
|
29
26
|
body = NativeListResolvedText(
|
|
30
27
|
item.data.string("body"), style: style.dictionary("body"), size: 14,
|
|
31
28
|
color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 20,
|
|
32
|
-
lines: item.data.int("bodyLines", default: 3)
|
|
29
|
+
lines: item.data.int("bodyLines", default: 3))
|
|
33
30
|
time = NativeListResolvedText(
|
|
34
31
|
item.data.string("time"), style: style.dictionary("time"), size: 12,
|
|
35
32
|
color: nativeListColor(theme, "disabledText", "#8D8D8D"), lineHeight: 16, lines: 1,
|
|
36
|
-
breakMode: .byWordWrapping
|
|
33
|
+
breakMode: .byWordWrapping)
|
|
37
34
|
horizontalPadding = CGFloat(
|
|
38
35
|
style.double("horizontalPadding", default: layout == "table" ? 16 : 12))
|
|
39
36
|
verticalPadding = CGFloat(style.double("verticalPadding", default: 16))
|
|
@@ -90,10 +87,7 @@ enum NativeListMessageRenderer {
|
|
|
90
87
|
root.addArrangedSubview(column)
|
|
91
88
|
}
|
|
92
89
|
|
|
93
|
-
func bind(
|
|
94
|
-
_ resolved: Resolved, item: NativeListItem, theme: [String: Any]?,
|
|
95
|
-
fonts: NativeListFontFamilies
|
|
96
|
-
) {
|
|
90
|
+
func bind(_ resolved: Resolved, item: NativeListItem, theme: [String: Any]?) {
|
|
97
91
|
resolved.title.bind(title)
|
|
98
92
|
resolved.body.bind(body)
|
|
99
93
|
resolved.time.bind(time)
|
|
@@ -108,8 +102,7 @@ enum NativeListMessageRenderer {
|
|
|
108
102
|
leading = visual
|
|
109
103
|
if visual.superview == nil { root.insertArrangedSubview(visual, at: 0) }
|
|
110
104
|
visual.bind(
|
|
111
|
-
data, style: resolved.imageStyle, key: item.key, theme: theme, isUnread: resolved.unread
|
|
112
|
-
fonts: fonts)
|
|
105
|
+
data, style: resolved.imageStyle, key: item.key, theme: theme, isUnread: resolved.unread)
|
|
113
106
|
root.setCustomSpacing(resolved.leadingGap, after: visual)
|
|
114
107
|
sizeConstraints += [
|
|
115
108
|
visual.widthAnchor.constraint(equalToConstant: resolved.imageWidth),
|
|
@@ -151,11 +144,9 @@ enum NativeListMessageRenderer {
|
|
|
151
144
|
|
|
152
145
|
final class NativeListMessageCell: NativeListRendererCell {
|
|
153
146
|
override class func measure(
|
|
154
|
-
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
155
|
-
fonts: NativeListFontFamilies
|
|
147
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
156
148
|
) -> CGFloat? {
|
|
157
|
-
return NativeListMessageRenderer.Resolved(item, theme: theme, layout: layout
|
|
158
|
-
.measure(
|
|
149
|
+
return NativeListMessageRenderer.Resolved(item, theme: theme, layout: layout).measure(
|
|
159
150
|
width: width)
|
|
160
151
|
}
|
|
161
152
|
|
|
@@ -167,9 +158,8 @@ final class NativeListMessageCell: NativeListRendererCell {
|
|
|
167
158
|
_ item: NativeListItem, theme: [String: Any]?, layout: String,
|
|
168
159
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
169
160
|
) {
|
|
170
|
-
let resolved = NativeListMessageRenderer.Resolved(
|
|
171
|
-
|
|
172
|
-
views.bind(resolved, item: item, theme: theme, fonts: fonts)
|
|
161
|
+
let resolved = NativeListMessageRenderer.Resolved(item, theme: theme, layout: layout)
|
|
162
|
+
views.bind(resolved, item: item, theme: theme)
|
|
173
163
|
contentInsets = UIEdgeInsets(
|
|
174
164
|
top: resolved.verticalPadding, left: resolved.horizontalPadding,
|
|
175
165
|
bottom: resolved.verticalPadding, right: resolved.horizontalPadding)
|
|
@@ -2,8 +2,7 @@ import UIKit
|
|
|
2
2
|
|
|
3
3
|
final class NativeListMetricCardCell: NativeListRendererCell {
|
|
4
4
|
override class func measure(
|
|
5
|
-
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
6
|
-
fonts: NativeListFontFamilies
|
|
5
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
7
6
|
) -> CGFloat? {
|
|
8
7
|
return item.data.string("variant") == "activity"
|
|
9
8
|
? 160 + 1 / UIScreen.main.scale : item.data.string("variant") == "performance" ? 178 : 132
|
|
@@ -92,11 +91,11 @@ final class NativeListMetricCardCell: NativeListRendererCell {
|
|
|
92
91
|
label.transform = .identity
|
|
93
92
|
}
|
|
94
93
|
titleLabel.font = nativeListFont(
|
|
95
|
-
ofSize: data.string("size") == "large" ? 24 : 18, weight: .semibold
|
|
96
|
-
subtitleLabel.font = nativeListFont(ofSize: 11
|
|
97
|
-
statusLabel.font = nativeListFont(ofSize: 12
|
|
98
|
-
detailLabel.font = nativeListFont(ofSize: 12
|
|
99
|
-
badgeLabel.font = nativeListFont(ofSize: 12, weight: .medium
|
|
94
|
+
ofSize: data.string("size") == "large" ? 24 : 18, weight: .semibold)
|
|
95
|
+
subtitleLabel.font = nativeListFont(ofSize: 11)
|
|
96
|
+
statusLabel.font = nativeListFont(ofSize: 12)
|
|
97
|
+
detailLabel.font = nativeListFont(ofSize: 12)
|
|
98
|
+
badgeLabel.font = nativeListFont(ofSize: 12, weight: .medium)
|
|
100
99
|
titleLabel.textColor = nativeListColor(theme, "primaryText", "#202020")
|
|
101
100
|
subtitleLabel.textColor = nativeListColor(theme, "disabledText", "#8D8D8D")
|
|
102
101
|
[statusLabel, detailLabel].forEach {
|
|
@@ -119,12 +118,11 @@ final class NativeListMetricCardCell: NativeListRendererCell {
|
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
if let text = style.dictionary("title") {
|
|
122
|
-
NativeListTextStyles.applyStyledText(titleLabel, text
|
|
121
|
+
NativeListTextStyles.applyStyledText(titleLabel, text)
|
|
123
122
|
}
|
|
124
123
|
} else {
|
|
125
124
|
if let descriptor = data.dictionary("visual") {
|
|
126
|
-
visual.bind(
|
|
127
|
-
descriptor, style: image, key: item.key, theme: theme, isUnread: false, fonts: fonts)
|
|
125
|
+
visual.bind(descriptor, style: image, key: item.key, theme: theme, isUnread: false)
|
|
128
126
|
root.addArrangedSubview(visual)
|
|
129
127
|
dimensions = [
|
|
130
128
|
visual.widthAnchor.constraint(
|
|
@@ -152,9 +150,7 @@ final class NativeListMetricCardCell: NativeListRendererCell {
|
|
|
152
150
|
("title", subtitleLabel), ("value", titleLabel), ("subtitle", detailLabel),
|
|
153
151
|
("trend", statusLabel),
|
|
154
152
|
] {
|
|
155
|
-
if let text = style.dictionary(slot) {
|
|
156
|
-
NativeListTextStyles.applyStyledText(label, text, fonts: fonts)
|
|
157
|
-
}
|
|
153
|
+
if let text = style.dictionary(slot) { NativeListTextStyles.applyStyledText(label, text) }
|
|
158
154
|
}
|
|
159
155
|
root.addArrangedSubview(mainStack)
|
|
160
156
|
}
|
|
@@ -206,7 +202,7 @@ final class NativeListMetricCardCell: NativeListRendererCell {
|
|
|
206
202
|
) {
|
|
207
203
|
root.alignment = .fill
|
|
208
204
|
show(titleLabel, item.data.string("title"), lines: 1)
|
|
209
|
-
titleLabel.font = nativeListFont(ofSize: 11
|
|
205
|
+
titleLabel.font = nativeListFont(ofSize: 11)
|
|
210
206
|
titleLabel.textColor = nativeListColor(theme, "disabledText", "#8D8D8D")
|
|
211
207
|
setLineHeight(
|
|
212
208
|
titleLabel,
|
|
@@ -314,7 +310,7 @@ final class NativeListMetricCardCell: NativeListRendererCell {
|
|
|
314
310
|
column.layer.cornerRadius = 8
|
|
315
311
|
}
|
|
316
312
|
let label = UILabel()
|
|
317
|
-
label.font = nativeListFont(ofSize: 11
|
|
313
|
+
label.font = nativeListFont(ofSize: 11)
|
|
318
314
|
label.textColor = nativeListColor(theme, "disabledText", "#8D8D8D")
|
|
319
315
|
setLineHeight(label, text: metric.string("label"), lineHeight: 14)
|
|
320
316
|
let value = UILabel()
|
|
@@ -339,7 +335,7 @@ final class NativeListMetricCardCell: NativeListRendererCell {
|
|
|
339
335
|
valueLineHeight = 20
|
|
340
336
|
valueWeight = .medium
|
|
341
337
|
}
|
|
342
|
-
value.font = nativeListTabularFont(ofSize: valueSize, weight: valueWeight
|
|
338
|
+
value.font = nativeListTabularFont(ofSize: valueSize, weight: valueWeight)
|
|
343
339
|
value.textColor = dataTextColor(metric.string("tone"), theme: theme)
|
|
344
340
|
setLineHeight(value, text: metric.string("value"), lineHeight: valueLineHeight)
|
|
345
341
|
column.addArrangedSubview(label)
|
|
@@ -16,13 +16,13 @@ enum NativeListRailRenderer {
|
|
|
16
16
|
let visual: [String: Any]?
|
|
17
17
|
let alignment: UIStackView.Alignment
|
|
18
18
|
|
|
19
|
-
init(_ item: NativeListItem, theme: [String: Any]
|
|
19
|
+
init(_ item: NativeListItem, theme: [String: Any]?) {
|
|
20
20
|
let style = item.data.dictionary("style") ?? [:]
|
|
21
21
|
let badge = item.data.dictionary("badge") ?? [:]
|
|
22
22
|
title = NativeListResolvedText(
|
|
23
23
|
item.data.string("title"), style: style.dictionary("title"),
|
|
24
24
|
size: 12, weight: .medium, color: nativeListColor(theme, "primaryText", "#202020"),
|
|
25
|
-
lineHeight: 16, lines: 1
|
|
25
|
+
lineHeight: 16, lines: 1)
|
|
26
26
|
self.badge = NativeListResolvedText(
|
|
27
27
|
badge.string("text"), style: style.dictionary("badge"),
|
|
28
28
|
size: 12, weight: .medium,
|
|
@@ -32,12 +32,12 @@ enum NativeListRailRenderer {
|
|
|
32
32
|
? "positive" : badge.string("tone") == "danger" ? "negative" : "secondaryText",
|
|
33
33
|
badge.string("tone") == "success"
|
|
34
34
|
? "#218358" : badge.string("tone") == "danger" ? "#CE2C31" : "#646464"), lineHeight: 16,
|
|
35
|
-
lines: 1, tabular: true
|
|
35
|
+
lines: 1, tabular: true)
|
|
36
36
|
let status = item.data.string("status")
|
|
37
37
|
self.status = NativeListResolvedText(
|
|
38
38
|
status == "none" ? "" : status, style: style.dictionary("status"),
|
|
39
39
|
size: 12, color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 16,
|
|
40
|
-
lines: 1, tabular: true
|
|
40
|
+
lines: 1, tabular: true)
|
|
41
41
|
horizontalPadding = CGFloat(style.double("horizontalPadding", default: 4))
|
|
42
42
|
verticalPadding = CGFloat(style.double("verticalPadding", default: 4))
|
|
43
43
|
leadingGap = CGFloat(style.double("leadingGap", default: 6))
|
|
@@ -75,8 +75,7 @@ enum NativeListRailRenderer {
|
|
|
75
75
|
|
|
76
76
|
final class NativeListRailCell: NativeListRendererCell {
|
|
77
77
|
override class func measure(
|
|
78
|
-
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
79
|
-
fonts: NativeListFontFamilies
|
|
78
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
80
79
|
) -> CGFloat? {
|
|
81
80
|
return 40
|
|
82
81
|
}
|
|
@@ -117,7 +116,7 @@ final class NativeListRailCell: NativeListRendererCell {
|
|
|
117
116
|
_ item: NativeListItem, theme: [String: Any]?, layout: String,
|
|
118
117
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
119
118
|
) {
|
|
120
|
-
let r = NativeListRailRenderer.Resolved(item, theme: theme
|
|
119
|
+
let r = NativeListRailRenderer.Resolved(item, theme: theme)
|
|
121
120
|
r.title.bind(title)
|
|
122
121
|
r.badge.bind(badge)
|
|
123
122
|
r.status.bind(status)
|
|
@@ -137,8 +136,7 @@ final class NativeListRailCell: NativeListRendererCell {
|
|
|
137
136
|
let view = visual ?? NativeListLeadingVisual(frame: .zero)
|
|
138
137
|
visual = view
|
|
139
138
|
if view.superview == nil { root.insertArrangedSubview(view, at: 0) }
|
|
140
|
-
view.bind(
|
|
141
|
-
source, style: r.imageStyle, key: item.key, theme: theme, isUnread: false, fonts: fonts)
|
|
139
|
+
view.bind(source, style: r.imageStyle, key: item.key, theme: theme, isUnread: false)
|
|
142
140
|
dimensions = [
|
|
143
141
|
view.widthAnchor.constraint(equalToConstant: r.imageWidth),
|
|
144
142
|
view.heightAnchor.constraint(equalToConstant: r.imageHeight),
|
|
@@ -60,7 +60,7 @@ class NativeListRendererCell: NativeListRowHost {
|
|
|
60
60
|
// The layout direction is an input because renderers resolve start/end alignment at bind.
|
|
61
61
|
private var boundInputs:
|
|
62
62
|
(
|
|
63
|
-
theme: NSDictionary?, layout: String, listStyle: NSDictionary?,
|
|
63
|
+
theme: NSDictionary?, layout: String, listStyle: NSDictionary?,
|
|
64
64
|
direction: UIUserInterfaceLayoutDirection
|
|
65
65
|
)?
|
|
66
66
|
|
|
@@ -90,20 +90,18 @@ class NativeListRendererCell: NativeListRowHost {
|
|
|
90
90
|
|
|
91
91
|
override func bind(
|
|
92
92
|
item: NativeListItem, theme: [String: Any]?, layout: String, itemIndex: Int? = nil,
|
|
93
|
-
selected: Bool, checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
94
|
-
fonts: NativeListFontFamilies
|
|
93
|
+
selected: Bool, checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
95
94
|
) {
|
|
96
|
-
self.fonts = fonts
|
|
97
95
|
let update = update(from: self.item, to: item)
|
|
98
96
|
let inputs = (
|
|
99
97
|
theme: theme.map { $0 as NSDictionary }, layout: layout,
|
|
100
|
-
listStyle: listStyle.map { $0 as NSDictionary },
|
|
98
|
+
listStyle: listStyle.map { $0 as NSDictionary },
|
|
101
99
|
direction: effectiveUserInterfaceLayoutDirection
|
|
102
100
|
)
|
|
103
101
|
let inputsChanged =
|
|
104
102
|
boundInputs.map {
|
|
105
103
|
// A missing theme/listStyle is the empty object, as in the former `?? [:]` JSON digest.
|
|
106
|
-
$0.
|
|
104
|
+
$0.layout != inputs.layout || $0.direction != inputs.direction
|
|
107
105
|
|| !nativeListValuesEqual($0.theme ?? [:], inputs.theme ?? [:])
|
|
108
106
|
|| !nativeListValuesEqual($0.listStyle ?? [:], inputs.listStyle ?? [:])
|
|
109
107
|
} ?? true
|
|
@@ -34,14 +34,10 @@ enum NativeListRendererRegistry {
|
|
|
34
34
|
static func appliesSizePreset(_ item: NativeListItem) -> Bool {
|
|
35
35
|
hosts[item.rendererKey]!.type.appliesSizePreset(item)
|
|
36
36
|
}
|
|
37
|
-
static func measure(
|
|
38
|
-
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String,
|
|
39
|
-
fonts: NativeListFontFamilies
|
|
40
|
-
)
|
|
37
|
+
static func measure(_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String)
|
|
41
38
|
-> CGFloat?
|
|
42
39
|
{
|
|
43
|
-
hosts[item.rendererKey]!.type.measure(
|
|
44
|
-
item, width: width, theme: theme, layout: layout, fonts: fonts)
|
|
40
|
+
hosts[item.rendererKey]!.type.measure(item, width: width, theme: theme, layout: layout)
|
|
45
41
|
}
|
|
46
42
|
}
|
|
47
43
|
|
|
@@ -49,7 +45,6 @@ enum NativeListRendererRegistry {
|
|
|
49
45
|
/// (plus the size preset), no template content.
|
|
50
46
|
final class NativeListUnsupportedCell: NativeListRendererCell {
|
|
51
47
|
override class func measure(
|
|
52
|
-
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
53
|
-
fonts: NativeListFontFamilies
|
|
48
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
54
49
|
) -> CGFloat? { 56 }
|
|
55
50
|
}
|
|
@@ -21,7 +21,7 @@ struct NativeListResolvedText {
|
|
|
21
21
|
init(
|
|
22
22
|
_ value: String, style: [String: Any]?, size: CGFloat, weight: NativeListFontWeight = .regular,
|
|
23
23
|
color: UIColor, lineHeight: CGFloat, lines: Int, breakMode: NSLineBreakMode = .byTruncatingTail,
|
|
24
|
-
tabular: Bool = false, preservesBreakMode: Bool = false
|
|
24
|
+
tabular: Bool = false, preservesBreakMode: Bool = false
|
|
25
25
|
) {
|
|
26
26
|
let style = style ?? [:]
|
|
27
27
|
self.tabular = tabular
|
|
@@ -43,8 +43,8 @@ struct NativeListResolvedText {
|
|
|
43
43
|
let resolvedSize = CGFloat(style.double("fontSize", default: Double(size)))
|
|
44
44
|
font =
|
|
45
45
|
tabular
|
|
46
|
-
? nativeListTabularFont(ofSize: resolvedSize, weight: resolvedWeight
|
|
47
|
-
: nativeListFont(ofSize: resolvedSize, weight: resolvedWeight
|
|
46
|
+
? nativeListTabularFont(ofSize: resolvedSize, weight: resolvedWeight)
|
|
47
|
+
: nativeListFont(ofSize: resolvedSize, weight: resolvedWeight)
|
|
48
48
|
self.color =
|
|
49
49
|
(style["color"] as? String).map { UIColor(nativeListHex: $0, fallback: color) } ?? color
|
|
50
50
|
self.lineHeight = CGFloat(style.double("lineHeight", default: Double(lineHeight)))
|
|
@@ -29,15 +29,11 @@ final class NativeListActionOrigin {
|
|
|
29
29
|
|
|
30
30
|
// Common list-facing lifecycle; each renderer owns its view allocation and reset.
|
|
31
31
|
class NativeListRowHost: UICollectionViewCell {
|
|
32
|
-
class func measure(
|
|
33
|
-
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String,
|
|
34
|
-
fonts: NativeListFontFamilies
|
|
35
|
-
)
|
|
32
|
+
class func measure(_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String)
|
|
36
33
|
-> CGFloat?
|
|
37
34
|
{ nil }
|
|
38
35
|
class func appliesSizePreset(_ item: NativeListItem) -> Bool { true }
|
|
39
36
|
|
|
40
|
-
var fonts = NativeListFontFamilies()
|
|
41
37
|
var bindingEpoch = 0
|
|
42
38
|
var listStyle: [String: Any]?
|
|
43
39
|
var onAction: ((NativeListItem, String, NativeSelectionTarget?, NativeListActionOrigin?) -> Void)?
|
|
@@ -45,8 +41,7 @@ class NativeListRowHost: UICollectionViewCell {
|
|
|
45
41
|
|
|
46
42
|
func bind(
|
|
47
43
|
item: NativeListItem, theme: [String: Any]?, layout: String, itemIndex: Int? = nil,
|
|
48
|
-
selected: Bool, checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
49
|
-
fonts: NativeListFontFamilies
|
|
44
|
+
selected: Bool, checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
50
45
|
) {
|
|
51
46
|
preconditionFailure("A row host must implement binding")
|
|
52
47
|
}
|