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