@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
|
@@ -94,8 +94,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
94
94
|
!["summary", "gallery"].contains(item.data.string("variant"))
|
|
95
95
|
}
|
|
96
96
|
override class func measure(
|
|
97
|
-
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
98
|
-
fonts: NativeListFontFamilies
|
|
97
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
99
98
|
) -> CGFloat? {
|
|
100
99
|
if layout == "table" { return 28 }
|
|
101
100
|
if item.data.string("presentation") == "networkSelector" { return 47 }
|
|
@@ -211,7 +210,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
211
210
|
label.rowVerticalAlignment = nil
|
|
212
211
|
}
|
|
213
212
|
titleLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
|
214
|
-
subtitleLabel.font = nativeListFont(ofSize: 14
|
|
213
|
+
subtitleLabel.font = nativeListFont(ofSize: 14)
|
|
215
214
|
subtitleLabel.textColor = nativeListColor(theme, "secondaryText", "#646464")
|
|
216
215
|
mainStack.alignment = .fill
|
|
217
216
|
mainStack.spacing = 2
|
|
@@ -222,7 +221,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
222
221
|
let value = accessoryButtons[0]
|
|
223
222
|
value.setTitle(nil, for: .normal)
|
|
224
223
|
value.setAttributedTitle(nil, for: .normal)
|
|
225
|
-
value.titleLabel?.font = nativeListFont(ofSize: 16, weight: .medium
|
|
224
|
+
value.titleLabel?.font = nativeListFont(ofSize: 16, weight: .medium)
|
|
226
225
|
value.titleLabel?.numberOfLines = 1
|
|
227
226
|
value.titleLabel?.lineBreakMode = .byTruncatingTail
|
|
228
227
|
value.contentHorizontalAlignment = .center
|
|
@@ -276,13 +275,13 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
276
275
|
private func applyTextStyle(_ item: NativeListItem) {
|
|
277
276
|
let style = item.data.dictionary("style") ?? [:]
|
|
278
277
|
if let title = style.dictionary("title") {
|
|
279
|
-
NativeListTextStyles.applyStyledText(titleLabel, title
|
|
278
|
+
NativeListTextStyles.applyStyledText(titleLabel, title)
|
|
280
279
|
}
|
|
281
280
|
if let subtitle = style.dictionary("subtitle") {
|
|
282
|
-
NativeListTextStyles.applyStyledText(subtitleLabel, subtitle
|
|
281
|
+
NativeListTextStyles.applyStyledText(subtitleLabel, subtitle)
|
|
283
282
|
}
|
|
284
283
|
if let value = style.dictionary("value") {
|
|
285
|
-
NativeListTextStyles.applyStyledButton(accessoryButtons[0], value
|
|
284
|
+
NativeListTextStyles.applyStyledButton(accessoryButtons[0], value)
|
|
286
285
|
}
|
|
287
286
|
}
|
|
288
287
|
override func bindSelectionContent(
|
|
@@ -306,8 +305,8 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
306
305
|
_ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
307
306
|
) {
|
|
308
307
|
checkboxControl.bind(
|
|
309
|
-
item, descriptors: [descriptor], theme: currentTheme, style: [:], checkboxState: checkboxState
|
|
310
|
-
|
|
308
|
+
item, descriptors: [descriptor], theme: currentTheme, style: [:], checkboxState: checkboxState
|
|
309
|
+
)
|
|
311
310
|
}
|
|
312
311
|
override func recycleContent() {
|
|
313
312
|
checkboxControl.reset()
|
|
@@ -383,8 +382,8 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
383
382
|
: isGallery || layout == "sectioned" ? .semibold : .regular
|
|
384
383
|
titleLabel.font = nativeListFont(
|
|
385
384
|
ofSize: isGallery ? 18 : isSummary ? 16 : isTable ? 11 : isHistory ? 12 : 14,
|
|
386
|
-
weight: isHistory ? .semibold : headerWeight
|
|
387
|
-
|
|
385
|
+
weight: isHistory ? .semibold : headerWeight
|
|
386
|
+
)
|
|
388
387
|
titleLabel.textColor = nativeListColor(
|
|
389
388
|
theme,
|
|
390
389
|
isSummary || isGallery ? "primaryText" : "secondaryText",
|
|
@@ -422,7 +421,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
422
421
|
if layout == "linear" {
|
|
423
422
|
// TokenManager's section title is a plain body label with mt=10,
|
|
424
423
|
// unlike the reusable 36-point SectionHeader used by sectioned lists.
|
|
425
|
-
titleLabel.font = nativeListFont(ofSize: 14
|
|
424
|
+
titleLabel.font = nativeListFont(ofSize: 14)
|
|
426
425
|
topInset = 10
|
|
427
426
|
bottomInset = 0
|
|
428
427
|
}
|
|
@@ -483,12 +482,11 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
483
482
|
color: nativeListColor(theme, "secondaryText", "#646464")
|
|
484
483
|
)
|
|
485
484
|
accessoryButtons[0].titleLabel?.font = nativeListFont(
|
|
486
|
-
ofSize: 16, weight: isExplicitNetworkHeader ? .medium : .regular
|
|
485
|
+
ofSize: 16, weight: isExplicitNetworkHeader ? .medium : .regular)
|
|
487
486
|
setButtonLine(
|
|
488
487
|
accessoryButtons[0],
|
|
489
488
|
text: item.data.string("value"),
|
|
490
|
-
font: nativeListFont(
|
|
491
|
-
ofSize: 16, weight: isExplicitNetworkHeader ? .medium : .regular, fonts: fonts),
|
|
489
|
+
font: nativeListFont(ofSize: 16, weight: isExplicitNetworkHeader ? .medium : .regular),
|
|
492
490
|
color: nativeListColor(theme, "secondaryText", "#646464"),
|
|
493
491
|
lineHeight: 24
|
|
494
492
|
)
|
|
@@ -499,7 +497,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
499
497
|
trailingStack.axis = .horizontal
|
|
500
498
|
trailingStack.alignment = .center
|
|
501
499
|
trailingStack.spacing = 4
|
|
502
|
-
accessoryButtons[0].titleLabel?.font = nativeListFont(ofSize: 11
|
|
500
|
+
accessoryButtons[0].titleLabel?.font = nativeListFont(ofSize: 11)
|
|
503
501
|
accessoryButtons[0].setTitleColor(
|
|
504
502
|
nativeListColor(theme, "secondaryText", "#646464"),
|
|
505
503
|
for: .normal
|
|
@@ -537,12 +535,12 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
537
535
|
bottomInset = -8
|
|
538
536
|
accessoryButtons[0].titleLabel?.font = nativeListTabularFont(
|
|
539
537
|
ofSize: 16,
|
|
540
|
-
weight: .medium
|
|
541
|
-
|
|
538
|
+
weight: .medium
|
|
539
|
+
)
|
|
542
540
|
setButtonLine(
|
|
543
541
|
accessoryButtons[0],
|
|
544
542
|
text: item.data.string("value"),
|
|
545
|
-
font: nativeListTabularFont(ofSize: 16, weight: .medium
|
|
543
|
+
font: nativeListTabularFont(ofSize: 16, weight: .medium),
|
|
546
544
|
color: nativeListColor(theme, "primaryText", "#202020"),
|
|
547
545
|
lineHeight: 24
|
|
548
546
|
)
|
|
@@ -643,7 +641,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
643
641
|
}
|
|
644
642
|
for segment in segments {
|
|
645
643
|
attributes[.font] = nativeListTabularFont(
|
|
646
|
-
ofSize: segment.string("style") == "subscript" ? 10 : 16, weight: .medium
|
|
644
|
+
ofSize: segment.string("style") == "subscript" ? 10 : 16, weight: .medium)
|
|
647
645
|
value.append(NSAttributedString(string: segment.string("text"), attributes: attributes))
|
|
648
646
|
}
|
|
649
647
|
button.setAttributedTitle(value, for: .normal)
|
|
@@ -681,8 +679,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
681
679
|
setButtonLine(
|
|
682
680
|
valueButton,
|
|
683
681
|
text: value,
|
|
684
|
-
font: nativeListFont(
|
|
685
|
-
ofSize: 16, weight: isExplicitNetworkHeader ? .medium : .regular, fonts: fonts),
|
|
682
|
+
font: nativeListFont(ofSize: 16, weight: isExplicitNetworkHeader ? .medium : .regular),
|
|
686
683
|
color: nativeListColor(currentTheme, "secondaryText", "#646464"),
|
|
687
684
|
lineHeight: 24
|
|
688
685
|
)
|
|
@@ -2,10 +2,9 @@ import UIKit
|
|
|
2
2
|
|
|
3
3
|
final class NativeListSystemCell: 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
|
-
return NativeListSystemRenderer.measure(item, width: width
|
|
7
|
+
return NativeListSystemRenderer.measure(item, width: width)
|
|
9
8
|
}
|
|
10
9
|
override class func appliesSizePreset(_ item: NativeListItem) -> Bool {
|
|
11
10
|
NativeListSystemRenderer.appliesSizePreset(item)
|
|
@@ -76,8 +75,7 @@ final class NativeListSystemCell: NativeListRendererCell {
|
|
|
76
75
|
label.text = nil
|
|
77
76
|
label.isHidden = true
|
|
78
77
|
label.font = nativeListFont(
|
|
79
|
-
ofSize: label === titleLabel ? 16 : 14, weight: label === titleLabel ? .medium : .regular
|
|
80
|
-
fonts: fonts)
|
|
78
|
+
ofSize: label === titleLabel ? 16 : 14, weight: label === titleLabel ? .medium : .regular)
|
|
81
79
|
label.textColor = nativeListColor(
|
|
82
80
|
theme, label === titleLabel ? "primaryText" : "secondaryText",
|
|
83
81
|
label === titleLabel ? "#202020" : "#646464")
|
|
@@ -92,7 +90,7 @@ final class NativeListSystemCell: NativeListRendererCell {
|
|
|
92
90
|
button.setAttributedTitle(nil, for: .normal)
|
|
93
91
|
button.setTitle(nil, for: .normal)
|
|
94
92
|
button.isHidden = true
|
|
95
|
-
button.titleLabel?.font = nativeListFont(ofSize: 16, weight: .medium
|
|
93
|
+
button.titleLabel?.font = nativeListFont(ofSize: 16, weight: .medium)
|
|
96
94
|
button.titleLabel?.numberOfLines = 1
|
|
97
95
|
button.contentEdgeInsets = .zero
|
|
98
96
|
button.contentHorizontalAlignment = .center
|
|
@@ -118,13 +116,13 @@ final class NativeListSystemCell: NativeListRendererCell {
|
|
|
118
116
|
if style["trailingGap"] != nil { trailingStack.spacing = CGFloat(style.double("trailingGap")) }
|
|
119
117
|
let warning = item.data.string("variant") == "warning"
|
|
120
118
|
if warning, let text = style.dictionary("title") {
|
|
121
|
-
NativeListTextStyles.applyStyledText(titleLabel, text
|
|
119
|
+
NativeListTextStyles.applyStyledText(titleLabel, text)
|
|
122
120
|
}
|
|
123
121
|
if let text = style.dictionary("message") {
|
|
124
|
-
NativeListTextStyles.applyStyledText(warning ? subtitleLabel : titleLabel, text
|
|
122
|
+
NativeListTextStyles.applyStyledText(warning ? subtitleLabel : titleLabel, text)
|
|
125
123
|
}
|
|
126
124
|
if let text = style.dictionary("actionText") {
|
|
127
|
-
NativeListTextStyles.applyStyledButton(button, text
|
|
125
|
+
NativeListTextStyles.applyStyledButton(button, text)
|
|
128
126
|
}
|
|
129
127
|
contentInsets = UIEdgeInsets(
|
|
130
128
|
top: topInset, left: leftInset, bottom: -bottomInset, right: -rightInset)
|
|
@@ -231,7 +229,7 @@ final class NativeListSystemCell: NativeListRendererCell {
|
|
|
231
229
|
bottomInset = -(height - top - (message.isEmpty ? 30 : 61))
|
|
232
230
|
if !message.isEmpty {
|
|
233
231
|
show(titleLabel, message, lines: 2)
|
|
234
|
-
titleLabel.font = nativeListTabularFont(ofSize: 16
|
|
232
|
+
titleLabel.font = nativeListTabularFont(ofSize: 16)
|
|
235
233
|
titleLabel.textColor = nativeListColor(theme, "secondaryText", "#646464")
|
|
236
234
|
titleLabel.textAlignment = .center
|
|
237
235
|
setLineHeight(titleLabel, text: message, lineHeight: 24)
|
|
@@ -242,7 +240,7 @@ final class NativeListSystemCell: NativeListRendererCell {
|
|
|
242
240
|
button.backgroundColor = .clear
|
|
243
241
|
button.layer.cornerRadius = 15
|
|
244
242
|
setButtonLine(
|
|
245
|
-
button, text: text, font: nativeListTabularFont(ofSize: 14, weight: .medium
|
|
243
|
+
button, text: text, font: nativeListTabularFont(ofSize: 14, weight: .medium),
|
|
246
244
|
color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 20)
|
|
247
245
|
let textWidth = button.intrinsicContentSize.width
|
|
248
246
|
selectorConstraints.append(contentsOf: [
|
|
@@ -286,7 +284,7 @@ final class NativeListSystemCell: NativeListRendererCell {
|
|
|
286
284
|
root.addArrangedSubview(mainStack)
|
|
287
285
|
mainStack.alignment = .center
|
|
288
286
|
mainStack.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
|
289
|
-
titleLabel.font = nativeListTabularFont(ofSize: 16
|
|
287
|
+
titleLabel.font = nativeListTabularFont(ofSize: 16)
|
|
290
288
|
titleLabel.textColor = nativeListColor(theme, "secondaryText", "#646464")
|
|
291
289
|
titleLabel.textAlignment = .center
|
|
292
290
|
show(titleLabel, item.data.string("message"), lines: 1)
|
|
@@ -326,9 +324,9 @@ final class NativeListSystemCell: NativeListRendererCell {
|
|
|
326
324
|
topInset = 14
|
|
327
325
|
bottomInset = -14
|
|
328
326
|
mainStack.spacing = 4
|
|
329
|
-
titleLabel.font = nativeListFont(ofSize: 14, weight: .medium
|
|
327
|
+
titleLabel.font = nativeListFont(ofSize: 14, weight: .medium)
|
|
330
328
|
titleLabel.numberOfLines = 0
|
|
331
|
-
subtitleLabel.font = nativeListFont(ofSize: 14
|
|
329
|
+
subtitleLabel.font = nativeListFont(ofSize: 14)
|
|
332
330
|
subtitleLabel.numberOfLines = 0
|
|
333
331
|
show(titleLabel, item.data.string("title"), lines: 0)
|
|
334
332
|
show(subtitleLabel, item.data.string("message"), lines: 0)
|
|
@@ -377,7 +375,7 @@ final class NativeListSystemCell: NativeListRendererCell {
|
|
|
377
375
|
mainStack.alignment = variant == "loading" || alignsToStart ? .leading : .center
|
|
378
376
|
if alignsToStart {
|
|
379
377
|
mainStack.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
|
380
|
-
titleLabel.font = nativeListFont(ofSize: 14
|
|
378
|
+
titleLabel.font = nativeListFont(ofSize: 14)
|
|
381
379
|
titleLabel.textColor = nativeListColor(theme, "secondaryText", "#646464")
|
|
382
380
|
setLineHeight(titleLabel, text: titleLabel.text ?? "", lineHeight: 20)
|
|
383
381
|
}
|
|
@@ -390,7 +388,7 @@ final class NativeListSystemCell: NativeListRendererCell {
|
|
|
390
388
|
setButtonLine(
|
|
391
389
|
accessoryButtons[0],
|
|
392
390
|
text: "Retry",
|
|
393
|
-
font: nativeListFont(ofSize: 14, weight: .medium
|
|
391
|
+
font: nativeListFont(ofSize: 14, weight: .medium),
|
|
394
392
|
color: nativeListColor(theme, "primaryText", "#202020"),
|
|
395
393
|
lineHeight: 20
|
|
396
394
|
)
|
|
@@ -514,7 +512,7 @@ enum NativeListSystemRenderer {
|
|
|
514
512
|
static func appliesSizePreset(_ item: NativeListItem) -> Bool {
|
|
515
513
|
!["warning", "spacer"].contains(item.data.string("variant"))
|
|
516
514
|
}
|
|
517
|
-
static func measure(_ item: NativeListItem, width: CGFloat
|
|
515
|
+
static func measure(_ item: NativeListItem, width: CGFloat) -> CGFloat {
|
|
518
516
|
if item.type == "system", item.data.string("variant") == "spacer" {
|
|
519
517
|
return CGFloat(item.data.int("height"))
|
|
520
518
|
}
|
|
@@ -538,7 +536,7 @@ enum NativeListSystemRenderer {
|
|
|
538
536
|
.font: nativeListFont(
|
|
539
537
|
ofSize: fontSize,
|
|
540
538
|
weight: NativeListTextStyles.marketFontWeight(
|
|
541
|
-
textStyle?.string("fontWeight") ?? "", fallback: weight)
|
|
539
|
+
textStyle?.string("fontWeight") ?? "", fallback: weight)),
|
|
542
540
|
.paragraphStyle: paragraph,
|
|
543
541
|
], context: nil
|
|
544
542
|
).height / lineHeight)
|
|
@@ -3,23 +3,21 @@ import UIKit
|
|
|
3
3
|
|
|
4
4
|
// Apply semantic overrides after a renderer has restored its resolved defaults.
|
|
5
5
|
enum NativeListTextStyles {
|
|
6
|
-
static func applyStyledText(
|
|
7
|
-
_ label: UILabel, _ style: [String: Any], fonts: NativeListFontFamilies
|
|
8
|
-
) {
|
|
6
|
+
static func applyStyledText(_ label: UILabel, _ style: [String: Any]) {
|
|
9
7
|
let text = label.attributedText?.string ?? label.text ?? ""
|
|
10
8
|
guard !text.isEmpty, !style.isEmpty else { return }
|
|
11
9
|
let originalText = label.attributedText
|
|
12
10
|
let textLabel = label as? NativeListTextLabel
|
|
13
11
|
let baseFont =
|
|
14
12
|
(originalText?.attribute(.font, at: 0, effectiveRange: nil) as? UIFont) ?? label.font
|
|
15
|
-
?? nativeListFont(ofSize: 14
|
|
13
|
+
?? nativeListFont(ofSize: 14)
|
|
16
14
|
let size = CGFloat(style.double("fontSize", default: Double(baseFont.pointSize)))
|
|
17
15
|
let font: UIFont
|
|
18
16
|
if let weightName = style["fontWeight"] as? String {
|
|
19
17
|
font = nativeListFont(
|
|
20
18
|
ofSize: size,
|
|
21
|
-
weight: marketFontWeight(weightName, fallback: .regular)
|
|
22
|
-
|
|
19
|
+
weight: marketFontWeight(weightName, fallback: .regular)
|
|
20
|
+
)
|
|
23
21
|
} else {
|
|
24
22
|
font = baseFont.withSize(size)
|
|
25
23
|
}
|
|
@@ -55,7 +53,7 @@ enum NativeListTextStyles {
|
|
|
55
53
|
paragraph.lineBreakMode = label.lineBreakMode
|
|
56
54
|
}
|
|
57
55
|
var attributes: [NSAttributedString.Key: Any] = [:]
|
|
58
|
-
applyStyledFont(attributed, style, fallback: baseFont
|
|
56
|
+
applyStyledFont(attributed, style, fallback: baseFont)
|
|
59
57
|
if style["color"] != nil { attributes[.foregroundColor] = color }
|
|
60
58
|
if style["alignment"] != nil || style["lines"] != nil || style["truncate"] != nil
|
|
61
59
|
|| style["lineHeight"] != nil
|
|
@@ -76,9 +74,7 @@ enum NativeListTextStyles {
|
|
|
76
74
|
label.attributedText = attributed
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
static func applyStyledButton(
|
|
80
|
-
_ button: UIButton, _ style: [String: Any], fonts: NativeListFontFamilies
|
|
81
|
-
) {
|
|
77
|
+
static func applyStyledButton(_ button: UIButton, _ style: [String: Any]) {
|
|
82
78
|
let text =
|
|
83
79
|
button.attributedTitle(for: .normal)?.string
|
|
84
80
|
?? button.title(for: .normal)
|
|
@@ -88,14 +84,14 @@ enum NativeListTextStyles {
|
|
|
88
84
|
let accessory = button as? NativeListAccessoryButton
|
|
89
85
|
let baseFont =
|
|
90
86
|
(originalText?.attribute(.font, at: 0, effectiveRange: nil) as? UIFont) ?? button.titleLabel?
|
|
91
|
-
.font ?? nativeListFont(ofSize: 14
|
|
87
|
+
.font ?? nativeListFont(ofSize: 14)
|
|
92
88
|
let size = CGFloat(style.double("fontSize", default: Double(baseFont.pointSize)))
|
|
93
89
|
let font: UIFont
|
|
94
90
|
if let weightName = style["fontWeight"] as? String {
|
|
95
91
|
font = nativeListFont(
|
|
96
92
|
ofSize: size,
|
|
97
|
-
weight: marketFontWeight(weightName, fallback: .regular)
|
|
98
|
-
|
|
93
|
+
weight: marketFontWeight(weightName, fallback: .regular)
|
|
94
|
+
)
|
|
99
95
|
} else {
|
|
100
96
|
font = baseFont.withSize(size)
|
|
101
97
|
}
|
|
@@ -120,7 +116,7 @@ enum NativeListTextStyles {
|
|
|
120
116
|
: alignmentName == "end" ? .trailing : .center
|
|
121
117
|
}
|
|
122
118
|
var attributes: [NSAttributedString.Key: Any] = [:]
|
|
123
|
-
applyStyledFont(attributed, style, fallback: baseFont
|
|
119
|
+
applyStyledFont(attributed, style, fallback: baseFont)
|
|
124
120
|
if style["color"] != nil { attributes[.foregroundColor] = color }
|
|
125
121
|
if style["alignment"] != nil || style["lineHeight"] != nil || style["lines"] != nil
|
|
126
122
|
|| style["truncate"] != nil
|
|
@@ -157,8 +153,7 @@ enum NativeListTextStyles {
|
|
|
157
153
|
}
|
|
158
154
|
|
|
159
155
|
static func applyStyledFont(
|
|
160
|
-
_ text: NSMutableAttributedString, _ style: [String: Any], fallback: UIFont
|
|
161
|
-
fonts: NativeListFontFamilies
|
|
156
|
+
_ text: NSMutableAttributedString, _ style: [String: Any], fallback: UIFont
|
|
162
157
|
) {
|
|
163
158
|
guard style["fontSize"] != nil || style["fontWeight"] != nil else { return }
|
|
164
159
|
text.enumerateAttribute(.font, in: NSRange(location: 0, length: text.length)) {
|
|
@@ -169,8 +164,7 @@ enum NativeListTextStyles {
|
|
|
169
164
|
style["fontWeight"] == nil
|
|
170
165
|
? original.withSize(size)
|
|
171
166
|
: nativeListFont(
|
|
172
|
-
ofSize: size, weight: marketFontWeight(style.string("fontWeight"), fallback: .regular)
|
|
173
|
-
fonts: fonts)
|
|
167
|
+
ofSize: size, weight: marketFontWeight(style.string("fontWeight"), fallback: .regular))
|
|
174
168
|
text.addAttribute(.font, value: font, range: range)
|
|
175
169
|
}
|
|
176
170
|
}
|
|
@@ -55,8 +55,7 @@ final class NativeListWalletGroupCell: NativeListRendererCell, UIGestureRecogniz
|
|
|
55
55
|
}
|
|
56
56
|
override class func appliesSizePreset(_ item: NativeListItem) -> Bool { false }
|
|
57
57
|
override class func measure(
|
|
58
|
-
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
59
|
-
fonts: NativeListFontFamilies
|
|
58
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
|
|
60
59
|
) -> CGFloat? {
|
|
61
60
|
let members = memberItems(item)
|
|
62
61
|
return members.reduce(
|
|
@@ -77,7 +76,7 @@ final class NativeListWalletGroupCell: NativeListRendererCell, UIGestureRecogniz
|
|
|
77
76
|
dragBadge.translatesAutoresizingMaskIntoConstraints = false
|
|
78
77
|
dragBadge.horizontalInset = 6
|
|
79
78
|
dragBadge.textAlignment = .center
|
|
80
|
-
dragBadge.font = nativeListTabularFont(ofSize: 12, weight: .semibold
|
|
79
|
+
dragBadge.font = nativeListTabularFont(ofSize: 12, weight: .semibold)
|
|
81
80
|
dragBadge.layer.cornerRadius = 12
|
|
82
81
|
dragBadge.layer.masksToBounds = true
|
|
83
82
|
dragBadge.layer.borderWidth = 1
|
|
@@ -102,7 +101,6 @@ final class NativeListWalletGroupCell: NativeListRendererCell, UIGestureRecogniz
|
|
|
102
101
|
_ item: NativeListItem, theme: [String: Any]?, layout: String,
|
|
103
102
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
104
103
|
) {
|
|
105
|
-
dragBadge.font = nativeListTabularFont(ofSize: 12, weight: .semibold, fonts: fonts)
|
|
106
104
|
members = Self.memberItems(item)
|
|
107
105
|
let keys = Set(members.map(\.key))
|
|
108
106
|
for key in Array(memberViews.keys) where !keys.contains(key) {
|
|
@@ -136,7 +134,7 @@ final class NativeListWalletGroupCell: NativeListRendererCell, UIGestureRecogniz
|
|
|
136
134
|
view.cell.listStyle = listStyle
|
|
137
135
|
view.cell.bind(
|
|
138
136
|
item: member, theme: theme, layout: layout, selected: member.data.bool("selected"),
|
|
139
|
-
checkboxState: checkboxState
|
|
137
|
+
checkboxState: checkboxState)
|
|
140
138
|
root.insertArrangedSubview(view.cell, at: index)
|
|
141
139
|
}
|
|
142
140
|
if let parent = members.first {
|
|
@@ -155,7 +153,7 @@ final class NativeListWalletGroupCell: NativeListRendererCell, UIGestureRecogniz
|
|
|
155
153
|
compactCell?.listStyle = listStyle
|
|
156
154
|
compactCell?.bind(
|
|
157
155
|
item: parent, theme: theme, layout: layout, selected: parent.data.bool("selected"),
|
|
158
|
-
checkboxState: checkboxState
|
|
156
|
+
checkboxState: checkboxState)
|
|
159
157
|
}
|
|
160
158
|
let count = members.dropFirst().filter { ($0.data["draggable"] as? Bool) != false }.count
|
|
161
159
|
dragBadge.text = count > 0 ? "+\(count)" : nil
|
|
@@ -4,26 +4,6 @@ import UIKit
|
|
|
4
4
|
import UniformTypeIdentifiers
|
|
5
5
|
|
|
6
6
|
final class NativeListView: UIView {
|
|
7
|
-
private var fonts = NativeListFontFamilies()
|
|
8
|
-
|
|
9
|
-
func setFontFamiliesJson(_ json: String) {
|
|
10
|
-
guard let next = NativeListFontFamilies(json: json), next != fonts else { return }
|
|
11
|
-
fonts = next
|
|
12
|
-
if interactiveReorderSource != nil { cancelInteractiveReorderForStructuralUpdate() }
|
|
13
|
-
sectionIndexView.refreshFonts(fonts)
|
|
14
|
-
sectionIndexPreview.refreshFonts(fonts)
|
|
15
|
-
invalidateActionAnchor(reason: "layout")
|
|
16
|
-
configureFooterIfPresent()
|
|
17
|
-
var snapshot = dataSource.snapshot()
|
|
18
|
-
snapshot.reconfigureItems(snapshot.itemIdentifiers)
|
|
19
|
-
dataSource.apply(snapshot, animatingDifferences: false)
|
|
20
|
-
flowLayout.invalidateLayout()
|
|
21
|
-
setNeedsLayout()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
private func configureFooterIfPresent() {
|
|
25
|
-
if let config { configureFooter(config) }
|
|
26
|
-
}
|
|
27
7
|
private var refreshEmittedForDrag = false
|
|
28
8
|
private var minimumDragOffset: CGFloat = 0
|
|
29
9
|
private var containerSlotHeights: [CGFloat] = [0, 0, 0]
|
|
@@ -1686,8 +1666,7 @@ final class NativeListView: UIView {
|
|
|
1686
1666
|
selected: item.data.bool("selected") || config.selectedKeys.contains(item.key),
|
|
1687
1667
|
checkboxState: { [weak self] item, target, fallback in
|
|
1688
1668
|
self?.resolveCheckboxState(item: item, target: target, fallback: fallback) ?? fallback
|
|
1689
|
-
}
|
|
1690
|
-
fonts: fonts
|
|
1669
|
+
}
|
|
1691
1670
|
)
|
|
1692
1671
|
if item.key == interactiveReorderCompactKey {
|
|
1693
1672
|
cell.setWalletGroupReorderCompact(true)
|
|
@@ -2050,9 +2029,7 @@ final class NativeListView: UIView {
|
|
|
2050
2029
|
? floor((availableWidth - CGFloat((config?.gridColumns ?? 2) - 1) * (config?.itemSpacing ?? 0)) / CGFloat(config?.gridColumns ?? 2))
|
|
2051
2030
|
: availableWidth
|
|
2052
2031
|
let rowWidth = allocatedWidth ?? (config?.orientation == "horizontal" ? 280 : columnWidth)
|
|
2053
|
-
if let height = NativeListRendererRegistry.measure(
|
|
2054
|
-
item, width: rowWidth, theme: config?.theme, layout: config?.layout ?? "linear", fonts: fonts)
|
|
2055
|
-
{
|
|
2032
|
+
if let height = NativeListRendererRegistry.measure(item, width: rowWidth, theme: config?.theme, layout: config?.layout ?? "linear") {
|
|
2056
2033
|
return max(0, height + (NativeListRendererRegistry.appliesSizePreset(item) ? (item.data.string("size") == "small" ? -8 : item.data.string("size") == "large" ? 12 : 0) : 0))
|
|
2057
2034
|
}
|
|
2058
2035
|
return 56
|
|
@@ -2434,7 +2411,7 @@ extension NativeListView: UICollectionViewDelegateFlowLayout {
|
|
|
2434
2411
|
}
|
|
2435
2412
|
|
|
2436
2413
|
private func railWidth(_ item: NativeListItem) -> CGFloat {
|
|
2437
|
-
NativeListRailRenderer.Resolved(item, theme: config?.theme
|
|
2414
|
+
NativeListRailRenderer.Resolved(item, theme: config?.theme).horizontalWidth
|
|
2438
2415
|
}
|
|
2439
2416
|
|
|
2440
2417
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
@@ -2687,11 +2664,6 @@ private struct NativeListSectionIndexEntry {
|
|
|
2687
2664
|
}
|
|
2688
2665
|
|
|
2689
2666
|
private final class NativeListSectionIndexPreviewView: UIView {
|
|
2690
|
-
private var fonts = NativeListFontFamilies()
|
|
2691
|
-
func refreshFonts(_ fonts: NativeListFontFamilies) {
|
|
2692
|
-
self.fonts = fonts
|
|
2693
|
-
label.font = nativeListFont(ofSize: 30, fonts: fonts)
|
|
2694
|
-
}
|
|
2695
2667
|
private let shapeLayer = CAShapeLayer()
|
|
2696
2668
|
private let label = UILabel()
|
|
2697
2669
|
|
|
@@ -2707,7 +2679,7 @@ private final class NativeListSectionIndexPreviewView: UIView {
|
|
|
2707
2679
|
layer.addSublayer(shapeLayer)
|
|
2708
2680
|
label.textAlignment = .center
|
|
2709
2681
|
label.adjustsFontForContentSizeCategory = true
|
|
2710
|
-
label.font = nativeListFont(ofSize: 30
|
|
2682
|
+
label.font = nativeListFont(ofSize: 30)
|
|
2711
2683
|
label.isAccessibilityElement = false
|
|
2712
2684
|
addSubview(label)
|
|
2713
2685
|
}
|
|
@@ -2762,11 +2734,6 @@ private final class NativeListSectionIndexPreviewView: UIView {
|
|
|
2762
2734
|
// OneKey patch: arbitrate index scrubbing against ancestor dismissal gestures.
|
|
2763
2735
|
// private final class NativeListSectionIndexView: UIControl {
|
|
2764
2736
|
private final class NativeListSectionIndexView: UIControl, UIGestureRecognizerDelegate {
|
|
2765
|
-
private var fonts = NativeListFontFamilies()
|
|
2766
|
-
func refreshFonts(_ fonts: NativeListFontFamilies) {
|
|
2767
|
-
self.fonts = fonts
|
|
2768
|
-
updateLabelStyles()
|
|
2769
|
-
}
|
|
2770
2737
|
private static let edgePadding: CGFloat = 8
|
|
2771
2738
|
private static let labelSize: CGFloat = 14
|
|
2772
2739
|
private static let labelSpacing: CGFloat = 16
|
|
@@ -2984,7 +2951,7 @@ private final class NativeListSectionIndexView: UIControl, UIGestureRecognizerDe
|
|
|
2984
2951
|
label.backgroundColor = active ? activeColor : .clear
|
|
2985
2952
|
label.layer.cornerRadius = Self.labelSize / 2
|
|
2986
2953
|
label.layer.masksToBounds = active
|
|
2987
|
-
label.font = nativeListFont(ofSize: 10, weight: active ? .medium : .regular
|
|
2954
|
+
label.font = nativeListFont(ofSize: 10, weight: active ? .medium : .regular)
|
|
2988
2955
|
}
|
|
2989
2956
|
}
|
|
2990
2957
|
}
|
|
@@ -21,7 +21,7 @@ final class NativeListActivityPresentationTests: XCTestCase {
|
|
|
21
21
|
],
|
|
22
22
|
])
|
|
23
23
|
let view = NativeListActivityDetailsView()
|
|
24
|
-
view.bind(item, theme: nil
|
|
24
|
+
view.bind(item, theme: nil)
|
|
25
25
|
func labels(in view: UIView) -> [UILabel] {
|
|
26
26
|
(view as? UILabel).map { [$0] } ?? view.subviews.flatMap { labels(in: $0) }
|
|
27
27
|
}
|
|
@@ -87,13 +87,11 @@ final class NativeListActivityPresentationTests: XCTestCase {
|
|
|
87
87
|
view.trailingAnchor.constraint(equalTo: container.trailingAnchor),
|
|
88
88
|
view.topAnchor.constraint(equalTo: container.topAnchor),
|
|
89
89
|
])
|
|
90
|
-
view.bind(item, theme: nil
|
|
90
|
+
view.bind(item, theme: nil)
|
|
91
91
|
container.layoutIfNeeded()
|
|
92
92
|
container.layoutIfNeeded()
|
|
93
93
|
let rendered = ceil(view.frame.height) + vertical * 2
|
|
94
|
-
XCTAssertEqual(
|
|
95
|
-
NativeListActivityDetailsView.measure(data, width: width, fonts: NativeListFontFamilies()),
|
|
96
|
-
rendered, accuracy: 1, name)
|
|
94
|
+
XCTAssertEqual(NativeListActivityDetailsView.measure(data, width: width), rendered, accuracy: 1, name)
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
}
|
|
@@ -76,7 +76,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
76
76
|
"style": ["title": ["color": "#FFAA00"]],
|
|
77
77
|
])
|
|
78
78
|
cell.bind(item: item, theme: nil, layout: "sectioned", selected: false,
|
|
79
|
-
|
|
79
|
+
checkboxState: { _, _, fallback in fallback })
|
|
80
80
|
}
|
|
81
81
|
try bind(loading: true)
|
|
82
82
|
let spinner = try XCTUnwrap(cell.root.arrangedSubviews.first as? UIActivityIndicatorView)
|
|
@@ -106,7 +106,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
106
106
|
|
|
107
107
|
func bind(_ item: NativeListItem) {
|
|
108
108
|
cell.bind(item: item, theme: nil, layout: "linear", selected: false,
|
|
109
|
-
|
|
109
|
+
checkboxState: { _, _, fallback in fallback })
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
bind(first)
|
|
@@ -166,81 +166,6 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
166
166
|
XCTAssertTrue(second.isHidden)
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
func testFontResolversMeasureBindResetAndKeepIndependentInstances() throws {
|
|
170
|
-
let first = NativeListFontFamilies(names: ["regular": "Courier", "bold": "Courier-Bold"])
|
|
171
|
-
let second = NativeListFontFamilies(names: ["regular": "Georgia", "bold": "Georgia-Bold"])
|
|
172
|
-
XCTAssertNotNil(UIFont(name: "Courier", size: 16))
|
|
173
|
-
XCTAssertNotNil(UIFont(name: "Georgia", size: 16))
|
|
174
|
-
func resolve(_ fonts: NativeListFontFamilies) -> NativeListResolvedText {
|
|
175
|
-
NativeListResolvedText(
|
|
176
|
-
"WWWWiiii", style: nil, size: 16, color: .label,
|
|
177
|
-
lineHeight: 24, lines: 1, fonts: fonts)
|
|
178
|
-
}
|
|
179
|
-
let a = resolve(first)
|
|
180
|
-
let b = resolve(second)
|
|
181
|
-
let label = NativeListTextLabel()
|
|
182
|
-
a.bind(label)
|
|
183
|
-
XCTAssertEqual(label.font.fontName, a.font.fontName)
|
|
184
|
-
XCTAssertEqual(a.measureWidth(), ceil(a.attributed(direction: .leftToRight).size().width))
|
|
185
|
-
XCTAssertNotEqual(a.font.fontName, b.font.fontName)
|
|
186
|
-
XCTAssertNotEqual(a.measureWidth(), b.measureWidth())
|
|
187
|
-
b.bind(label)
|
|
188
|
-
XCTAssertEqual(label.font.fontName, "Georgia")
|
|
189
|
-
resolve(NativeListFontFamilies()).bind(label)
|
|
190
|
-
XCTAssertEqual(label.font.fontName, UIFont.systemFont(ofSize: 16).fontName)
|
|
191
|
-
XCTAssertEqual(a.font.fontName, "Courier")
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
func testUnstyledLeadingVisualAndFooterRebindConfiguredFonts() throws {
|
|
195
|
-
let first = NativeListFontFamilies(names: ["regular": "Courier", "bold": "Courier-Bold"])
|
|
196
|
-
let second = NativeListFontFamilies(names: ["regular": "Georgia", "bold": "Georgia-Bold"])
|
|
197
|
-
let visual = NativeListLeadingVisual()
|
|
198
|
-
for fonts in [first, second] {
|
|
199
|
-
visual.bind(
|
|
200
|
-
["kind": "account", "fallbackText": "A"], style: [:], key: "a", theme: nil,
|
|
201
|
-
isUnread: false, fonts: fonts)
|
|
202
|
-
XCTAssertEqual(
|
|
203
|
-
visual.fallbackTextView.font.fontName, fonts.font(ofSize: 13, weight: .bold).fontName)
|
|
204
|
-
}
|
|
205
|
-
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
|
|
206
|
-
view.setFontFamiliesJson("{\"regular\":\"Courier\",\"medium\":\"Courier\"}")
|
|
207
|
-
view.applySnapshotJson(
|
|
208
|
-
try snapshot(footer: [
|
|
209
|
-
"key": "footer", "type": "action", "title": "Continue", "actionKey": "continue",
|
|
210
|
-
]))
|
|
211
|
-
let footer = try XCTUnwrap(footerCell(in: view))
|
|
212
|
-
func labels(_ view: UIView) -> [UILabel] {
|
|
213
|
-
(view as? UILabel).map { [$0] } ?? view.subviews.flatMap(labels)
|
|
214
|
-
}
|
|
215
|
-
XCTAssertEqual(labels(footer).first { $0.text == "Continue" }?.font.fontName, "Courier")
|
|
216
|
-
view.setFontFamiliesJson("{\"regular\":\"Georgia\",\"medium\":\"Georgia\"}")
|
|
217
|
-
XCTAssertEqual(labels(footer).first { $0.text == "Continue" }?.font.fontName, "Georgia")
|
|
218
|
-
XCTAssertEqual(footer.accessibilityLabel, "Continue")
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
func testNestedWalletMembersAndDragBadgeFollowEachBindMapping() throws {
|
|
222
|
-
let group = NativeListWalletGroupCell(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
|
|
223
|
-
let item = try NativeListItem(data: [
|
|
224
|
-
"type": "walletGroup", "key": "group",
|
|
225
|
-
"parent": ["type": "identity", "key": "parent", "title": "Parent", "variant": "wallet"],
|
|
226
|
-
"children": [["type": "identity", "key": "child", "title": "Child", "variant": "wallet"]],
|
|
227
|
-
])
|
|
228
|
-
func labels(_ view: UIView) -> [UILabel] {
|
|
229
|
-
(view as? UILabel).map { [$0] } ?? view.subviews.flatMap(labels)
|
|
230
|
-
}
|
|
231
|
-
for face in ["Courier", "Georgia"] {
|
|
232
|
-
let fonts = NativeListFontFamilies(names: ["regular": face, "medium": face, "semibold": face])
|
|
233
|
-
group.bind(
|
|
234
|
-
item: item, theme: nil, layout: "linear", selected: false,
|
|
235
|
-
checkboxState: { _, _, fallback in fallback }, fonts: fonts)
|
|
236
|
-
let rendered = labels(group)
|
|
237
|
-
let members = rendered.filter { ["Parent", "Child"].contains($0.text ?? "") }
|
|
238
|
-
XCTAssertGreaterThanOrEqual(members.count, 2)
|
|
239
|
-
XCTAssertTrue(members.allSatisfy { $0.font.fontName == face })
|
|
240
|
-
XCTAssertEqual(rendered.first { $0.text == "+1" }?.font.fontName, face)
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
169
|
private func snapshot(footer: [String: Any]?) throws -> String {
|
|
245
170
|
var value: [String: Any] = [
|
|
246
171
|
"schemaVersion": 1, "generation": 1, "layout": ["kind": "linear"], "rows": [],
|
package/lib/module/NativeList.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useNativeListFontFamiliesJson } from "./fonts.js";
|
|
4
3
|
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
5
4
|
import { OneKeyImageCache, OneKeyImageCachePolicy } from '@onekeyfe/react-native-image';
|
|
6
5
|
import { NativeAvatarPrefetchModel, NativeAvatarPrefetchQueue } from "./avatarPrefetch.js";
|
|
@@ -53,7 +52,6 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
53
52
|
initialScrollViewOffset,
|
|
54
53
|
...viewProps
|
|
55
54
|
}, forwardedRef) {
|
|
56
|
-
const fontFamiliesJson = useNativeListFontFamiliesJson();
|
|
57
55
|
const [slotHeights, setSlotHeights] = useState([0, 0, 0]);
|
|
58
56
|
const [topOverlayHeight, setTopOverlayHeight] = useState(0);
|
|
59
57
|
const hasTopOverlay = Platform?.OS === 'ios' && parseInt(String(Platform.Version), 10) >= 26 && topScrollEdgeEffect === 'hard' && topOverlay != null;
|
|
@@ -322,7 +320,6 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
322
320
|
return /*#__PURE__*/_jsxs(NativeListHost, {
|
|
323
321
|
...viewProps,
|
|
324
322
|
...nativeCallbacks,
|
|
325
|
-
fontFamiliesJson: fontFamiliesJson,
|
|
326
323
|
snapshotJson: snapshotJson,
|
|
327
324
|
containerSlotHeightsJson: containerSlotHeightsJson,
|
|
328
325
|
topScrollEdgeHard: hasTopOverlay,
|