@onekeyfe/react-native-native-list 6.7.0-3 → 6.7.0-31
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 +4 -0
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +250 -9
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +35 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +47 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +152 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +1 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -287
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +7 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
- package/docs/ROW_TEMPLATES.md +70 -11
- package/docs/SPEC.md +1170 -13
- package/docs/STYLE_SPEC.md +11 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +237 -51
- package/ios/NativeListActivityDetailsView.swift +30 -11
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +167 -30
- package/ios/NativeListDesignAssets.swift +13 -75
- package/ios/NativeListGeneratedIcons.swift +55 -0
- package/ios/NativeListIconBinding.swift +171 -0
- package/ios/NativeListIdentityRenderer.swift +256 -39
- package/ios/NativeListLeadingVisual.swift +127 -28
- package/ios/NativeListMarketRenderer.swift +120 -31
- package/ios/NativeListMediaPreviewSlot.swift +122 -61
- package/ios/NativeListMediaTileRenderer.swift +7 -3
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListMetricCardRenderer.swift +4 -2
- package/ios/NativeListModels.swift +42 -2
- package/ios/NativeListRendererRegistry.swift +1 -0
- package/ios/NativeListResolvedText.swift +2 -1
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +100 -4
- package/ios/RNCNativeListView.swift +1052 -58
- package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
- package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
- package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
- package/ios/tests/NativeListLifecycleTests.swift +2798 -3
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/ios/tests/NativeListMediaVisibilityTests.swift +26 -1
- package/ios/tests/NativeListSharedIconTests.swift +236 -0
- package/lib/module/NativeList.js +221 -36
- package/lib/module/NativeList.web.js +167 -46
- package/lib/module/index.js +1 -1
- package/lib/module/models.js +3 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +1246 -48
- package/lib/module/web/NativeListGeneratedIcons.js +31 -0
- package/lib/module/web/NativeListWebEngine.js +513 -274
- package/lib/module/web/templates/ActivityRowRenderer.js +120 -87
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +40 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +158 -6
- package/lib/module/web/templates/MarketTableRowRenderer.js +37 -19
- package/lib/module/web/templates/MediaTileRowRenderer.js +4 -14
- package/lib/module/web/templates/MessageRowRenderer.js +18 -2
- package/lib/module/web/templates/RowContainerStyle.js +1 -0
- package/lib/module/web/templates/RowRendererRegistry.js +3 -0
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/lib/typescript/src/NativeList.d.ts +3 -3
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
- package/lib/typescript/src/NativeList.types.d.ts +20 -2
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +126 -17
- package/lib/typescript/src/validation.d.ts +20 -0
- package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +32 -1
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/package.json +16 -10
- package/react-native-native-list.podspec +2 -6
- package/scripts/generate-icons.mjs +150 -0
- package/scripts/generate-icons.test.mjs +288 -0
- package/scripts/native-list-icons.json +260 -0
- package/src/NativeList.nitro.ts +2 -0
- package/src/NativeList.tsx +416 -89
- package/src/NativeList.types.ts +24 -2
- package/src/NativeList.web.tsx +295 -89
- package/src/index.ts +2 -0
- package/src/models.ts +263 -144
- package/src/selection.ts +1 -0
- package/src/validation.ts +3013 -152
- package/src/web/NativeListGeneratedIcons.ts +28 -0
- package/src/web/NativeListWebEngine.ts +816 -343
- package/src/web/templates/ActivityRowRenderer.ts +178 -141
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +231 -6
- package/src/web/templates/MarketTableRowRenderer.ts +56 -33
- package/src/web/templates/MediaTileRowRenderer.ts +4 -17
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +11 -1
- package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
- package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
|
@@ -97,6 +97,7 @@ final class NativeListActivityCell: NativeListRendererCell {
|
|
|
97
97
|
details.recycle()
|
|
98
98
|
let style = data.dictionary("style") ?? [:]
|
|
99
99
|
let image = style.dictionary("image") ?? [:]
|
|
100
|
+
let hideLeading = data.bool("hideLeading")
|
|
100
101
|
root.spacing = 12
|
|
101
102
|
root.setCustomSpacing(CGFloat(style.double("leadingGap", default: 12)), after: visual)
|
|
102
103
|
switch style.dictionary("container")?.string("contentVerticalAlignment") {
|
|
@@ -113,12 +114,17 @@ final class NativeListActivityCell: NativeListRendererCell {
|
|
|
113
114
|
bottom: CGFloat(style.double("verticalPadding", default: 8)),
|
|
114
115
|
right: CGFloat(style.double("horizontalPadding", default: layout == "table" ? 16 : 12)))
|
|
115
116
|
NSLayoutConstraint.deactivate(dimensions)
|
|
117
|
+
let visualWidth = visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40)))
|
|
118
|
+
if hideLeading { visualWidth.priority = UILayoutPriority(999) }
|
|
116
119
|
dimensions = [
|
|
117
|
-
|
|
120
|
+
visualWidth,
|
|
118
121
|
visual.heightAnchor.constraint(equalToConstant: CGFloat(image.double("height", default: 40))),
|
|
119
122
|
]
|
|
120
123
|
NSLayoutConstraint.activate(dimensions)
|
|
121
|
-
|
|
124
|
+
visual.isHidden = hideLeading
|
|
125
|
+
if hideLeading {
|
|
126
|
+
visual.recycle()
|
|
127
|
+
} else if let leading = data.dictionary("leading") {
|
|
122
128
|
visual.bind(
|
|
123
129
|
leading, style: image, key: item.key, theme: theme, isUnread: false,
|
|
124
130
|
secondaryVisual: data.dictionary("secondaryLeading"), fonts: fonts)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
final class NativeListButtonGroupCell: NativeListRendererCell {
|
|
4
|
+
override class func measure(
|
|
5
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String,
|
|
6
|
+
fonts: NativeListFontFamilies
|
|
7
|
+
) -> CGFloat? { 64 }
|
|
8
|
+
|
|
9
|
+
private var buttons: [UIButton] = []
|
|
10
|
+
private var actionKeys: [String] = []
|
|
11
|
+
private var rowOpacity: CGFloat = 1
|
|
12
|
+
|
|
13
|
+
override func applyAppearance() {
|
|
14
|
+
super.applyAppearance()
|
|
15
|
+
contentView.alpha = rowOpacity
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override init(frame: CGRect) {
|
|
19
|
+
super.init(frame: frame)
|
|
20
|
+
root.axis = .horizontal
|
|
21
|
+
root.alignment = .fill
|
|
22
|
+
root.distribution = .fillEqually
|
|
23
|
+
root.spacing = 10
|
|
24
|
+
}
|
|
25
|
+
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
26
|
+
|
|
27
|
+
override func bindContent(
|
|
28
|
+
_ item: NativeListItem, theme: [String: Any]?, layout: String,
|
|
29
|
+
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
30
|
+
) {
|
|
31
|
+
recycleContent()
|
|
32
|
+
rowOpacity = CGFloat(item.data.dictionary("style")?.dictionary("container")?.double("opacity", default: item.data.double("opacity", default: 1)) ?? item.data.double("opacity", default: 1))
|
|
33
|
+
contentInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0)
|
|
34
|
+
let info = nativeListColor(theme, "info", "#0F69F6")
|
|
35
|
+
for (index, descriptor) in item.data.dictionaries("buttons").enumerated() {
|
|
36
|
+
let button = NativeListAccessoryButton(type: .custom)
|
|
37
|
+
button.tag = index
|
|
38
|
+
button.setTitle(descriptor.string("label"), for: .normal)
|
|
39
|
+
button.titleLabel?.font = nativeListFont(ofSize: 14, weight: .medium, fonts: fonts)
|
|
40
|
+
button.titleLabel?.lineBreakMode = .byTruncatingTail
|
|
41
|
+
button.setTitleColor(info, for: .normal)
|
|
42
|
+
button.contentEdgeInsets = UIEdgeInsets(top: 12, left: 8, bottom: 12, right: 8)
|
|
43
|
+
button.layer.cornerRadius = 12
|
|
44
|
+
button.layer.borderWidth = 1
|
|
45
|
+
button.layer.borderColor = info.withAlphaComponent(0.35).cgColor
|
|
46
|
+
button.normalBackgroundColor = .clear
|
|
47
|
+
button.pressedBackgroundColor = info.withAlphaComponent(0.17)
|
|
48
|
+
button.isEnabled = !item.data.bool("disabled") && !descriptor.bool("disabled") && !descriptor.bool("loading")
|
|
49
|
+
button.alpha = button.isEnabled ? 1 : 0.4
|
|
50
|
+
button.accessibilityIdentifier = descriptor["testID"] as? String
|
|
51
|
+
button.accessibilityLabel = descriptor.string("accessibilityLabel", default: descriptor.string("label"))
|
|
52
|
+
button.addTarget(self, action: #selector(pressed(_:)), for: .touchUpInside)
|
|
53
|
+
if descriptor.bool("loading"), let titleLabel = button.titleLabel {
|
|
54
|
+
let spinner = UIActivityIndicatorView(style: .medium)
|
|
55
|
+
spinner.color = info
|
|
56
|
+
spinner.isUserInteractionEnabled = false
|
|
57
|
+
spinner.translatesAutoresizingMaskIntoConstraints = false
|
|
58
|
+
button.addSubview(spinner)
|
|
59
|
+
button.contentEdgeInsets = UIEdgeInsets(top: 12, left: 36, bottom: 12, right: 8)
|
|
60
|
+
NSLayoutConstraint.activate([
|
|
61
|
+
spinner.trailingAnchor.constraint(equalTo: titleLabel.leadingAnchor, constant: -8),
|
|
62
|
+
spinner.centerYAnchor.constraint(equalTo: button.centerYAnchor),
|
|
63
|
+
spinner.widthAnchor.constraint(equalToConstant: 20),
|
|
64
|
+
spinner.heightAnchor.constraint(equalToConstant: 20),
|
|
65
|
+
])
|
|
66
|
+
spinner.startAnimating()
|
|
67
|
+
}
|
|
68
|
+
buttons.append(button)
|
|
69
|
+
actionKeys.append(descriptor.string("actionKey"))
|
|
70
|
+
root.addArrangedSubview(button)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@objc private func pressed(_ button: UIButton) {
|
|
75
|
+
guard button.isEnabled, buttons.indices.contains(button.tag), buttons[button.tag] === button else { return }
|
|
76
|
+
emitAction(actionKeys[button.tag], from: button, source: "buttonGroup", slot: button.tag)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
override func recycleContent() {
|
|
80
|
+
for button in buttons {
|
|
81
|
+
button.removeTarget(self, action: nil, for: .allEvents)
|
|
82
|
+
button.subviews.compactMap { $0 as? UIActivityIndicatorView }.forEach { $0.stopAnimating() }
|
|
83
|
+
root.removeArrangedSubview(button)
|
|
84
|
+
button.removeFromSuperview()
|
|
85
|
+
}
|
|
86
|
+
buttons.removeAll()
|
|
87
|
+
actionKeys.removeAll()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -6,17 +6,21 @@ final class NativeListDataRowCell: NativeListRendererCell {
|
|
|
6
6
|
fonts: NativeListFontFamilies
|
|
7
7
|
) -> CGFloat? {
|
|
8
8
|
let secondary = item.data.dictionaries("columns").contains {
|
|
9
|
-
|
|
9
|
+
!nativeListDataColumnText($0, "secondaryText").isEmpty
|
|
10
10
|
}
|
|
11
11
|
return secondary ? 60 : layout == "table" ? 48 : 56
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
private let visual = NativeListLeadingVisual()
|
|
15
|
-
private let favorite =
|
|
15
|
+
private let favorite = NativeListIconImageView()
|
|
16
16
|
private let accessories = NativeListAccessoryStack()
|
|
17
|
+
private let trailingAccessories = NativeListAccessoryStack()
|
|
17
18
|
private let columns = UIStackView()
|
|
18
19
|
private let cells = (0..<4).map { _ in NativeListTableColumnView() }
|
|
19
20
|
private var rowConstraints: [NSLayoutConstraint] = []
|
|
21
|
+
private var trailingWidthConstraint: NSLayoutConstraint?
|
|
22
|
+
private var columnWidthConstraints: [NSLayoutConstraint] = []
|
|
23
|
+
private var columnWeights: [Int]?
|
|
20
24
|
override func unselectedBackground(
|
|
21
25
|
_ item: NativeListItem, theme: [String: Any]?, layout: String, itemIndex: Int?
|
|
22
26
|
) -> UIColor {
|
|
@@ -34,16 +38,22 @@ final class NativeListDataRowCell: NativeListRendererCell {
|
|
|
34
38
|
columns.alignment = .center
|
|
35
39
|
columns.spacing = 8
|
|
36
40
|
cells.forEach(columns.addArrangedSubview)
|
|
37
|
-
[favorite, visual, accessories, columns].forEach(root.addArrangedSubview)
|
|
41
|
+
[favorite, visual, accessories, columns, trailingAccessories].forEach(root.addArrangedSubview)
|
|
38
42
|
accessories.onAction = { [weak self] key, view, slot, target in
|
|
39
43
|
self?.emitAction(key, from: view, source: "trailingAccessory", slot: slot, target: target)
|
|
40
44
|
}
|
|
45
|
+
trailingAccessories.onAction = { [weak self] key, view, slot, target in
|
|
46
|
+
self?.emitAction(key, from: view, source: "trailingAccessory", slot: slot, target: target)
|
|
47
|
+
}
|
|
41
48
|
}
|
|
42
49
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
43
50
|
override func bindContent(
|
|
44
51
|
_ item: NativeListItem, theme: [String: Any]?, layout: String,
|
|
45
52
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
46
53
|
) {
|
|
54
|
+
let iconUpdate = NativeListIconUpdate(self)
|
|
55
|
+
defer { iconUpdate.finish() }
|
|
56
|
+
|
|
47
57
|
let data = item.data
|
|
48
58
|
let style = data.dictionary("style") ?? [:]
|
|
49
59
|
let image = style.dictionary("image") ?? [:]
|
|
@@ -57,8 +67,7 @@ final class NativeListDataRowCell: NativeListRendererCell {
|
|
|
57
67
|
let vp = CGFloat(style.double("verticalPadding", default: layout == "table" ? 10 : 8))
|
|
58
68
|
contentInsets = UIEdgeInsets(top: vp, left: hp, bottom: vp, right: hp)
|
|
59
69
|
favorite.isHidden = !data.bool("favorite") && !data.bool("favoriteActive")
|
|
60
|
-
favorite.
|
|
61
|
-
named: data.bool("favoriteActive") ? "StarSolid" : "StarOutline")
|
|
70
|
+
favorite.bindIcon(data.bool("favoriteActive") ? "StarSolid" : "StarOutline")
|
|
62
71
|
favorite.tintColor = nativeListColor(
|
|
63
72
|
theme, data.bool("favoriteActive") ? "icon" : "iconSubdued",
|
|
64
73
|
data.bool("favoriteActive") ? "#646464" : "#8D8D8D")
|
|
@@ -86,16 +95,55 @@ final class NativeListDataRowCell: NativeListRendererCell {
|
|
|
86
95
|
item, descriptors: descriptors, theme: theme, style: accessoryStyle,
|
|
87
96
|
checkboxState: checkboxState, fonts: fonts)
|
|
88
97
|
accessories.isHidden = descriptors.isEmpty
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
let trailing = data.dictionaries("trailing")
|
|
99
|
+
trailingAccessories.bind(
|
|
100
|
+
item, descriptors: trailing, theme: theme, style: style,
|
|
101
|
+
checkboxState: checkboxState, fonts: fonts)
|
|
102
|
+
trailingAccessories.isHidden = trailing.isEmpty
|
|
103
|
+
if rowConstraints.isEmpty {
|
|
104
|
+
rowConstraints = [
|
|
105
|
+
favorite.widthAnchor.constraint(equalToConstant: 20),
|
|
106
|
+
favorite.heightAnchor.constraint(equalToConstant: 20),
|
|
107
|
+
visual.widthAnchor.constraint(equalToConstant: 40),
|
|
108
|
+
visual.heightAnchor.constraint(equalToConstant: 40),
|
|
109
|
+
]
|
|
110
|
+
NSLayoutConstraint.activate(rowConstraints)
|
|
111
|
+
}
|
|
112
|
+
let visualWidth = CGFloat(image.double("width", default: 40))
|
|
113
|
+
let visualHeight = CGFloat(image.double("height", default: 40))
|
|
114
|
+
if rowConstraints[2].constant != visualWidth { rowConstraints[2].constant = visualWidth }
|
|
115
|
+
if rowConstraints[3].constant != visualHeight { rowConstraints[3].constant = visualHeight }
|
|
116
|
+
if !trailing.isEmpty {
|
|
117
|
+
// UIStackView has no intrinsic width of its own. Reserve the controls' fitted
|
|
118
|
+
// width so extra space goes to the weighted columns instead of this stack.
|
|
119
|
+
if trailingWidthConstraint == nil {
|
|
120
|
+
trailingWidthConstraint = trailingAccessories.widthAnchor.constraint(equalToConstant: 0)
|
|
121
|
+
}
|
|
122
|
+
if trailingWidthConstraint?.isActive == true { trailingWidthConstraint?.isActive = false }
|
|
123
|
+
let trailingWidth =
|
|
124
|
+
trailingAccessories.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).width
|
|
125
|
+
if trailingWidthConstraint?.constant != trailingWidth {
|
|
126
|
+
trailingWidthConstraint?.constant = trailingWidth
|
|
127
|
+
}
|
|
128
|
+
trailingWidthConstraint?.isActive = true
|
|
129
|
+
} else {
|
|
130
|
+
if trailingWidthConstraint?.isActive == true { trailingWidthConstraint?.isActive = false }
|
|
131
|
+
}
|
|
96
132
|
let values = Array(data.dictionaries("columns").prefix(4))
|
|
133
|
+
let weights = values.map { max(1, $0.int("weight", default: 1)) }
|
|
134
|
+
var divisor = weights.first ?? 1
|
|
135
|
+
for weight in weights.dropFirst() {
|
|
136
|
+
var a = divisor
|
|
137
|
+
var b = weight
|
|
138
|
+
while b != 0 { (a, b) = (b, a % b) }
|
|
139
|
+
divisor = a
|
|
140
|
+
}
|
|
141
|
+
let normalizedWeights = weights.map { $0 / divisor }
|
|
142
|
+
let columnsChanged = columnWeights != normalizedWeights
|
|
143
|
+
if columnsChanged { NSLayoutConstraint.deactivate(columnWidthConstraints) }
|
|
97
144
|
for (index, cell) in cells.enumerated() {
|
|
98
|
-
|
|
145
|
+
let hidden = index >= values.count
|
|
146
|
+
if cell.isHidden != hidden { cell.isHidden = hidden }
|
|
99
147
|
guard index < values.count else {
|
|
100
148
|
cell.reset()
|
|
101
149
|
continue
|
|
@@ -109,23 +157,34 @@ final class NativeListDataRowCell: NativeListRendererCell {
|
|
|
109
157
|
cell.applyStyle(style) { label, style in
|
|
110
158
|
NativeListTextStyles.applyStyledText(label, style, fonts: fonts)
|
|
111
159
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
160
|
+
cell.applySegments(values[index])
|
|
161
|
+
cell.bindTitleIcons(values[index], theme: theme)
|
|
162
|
+
}
|
|
163
|
+
if columnsChanged {
|
|
164
|
+
columnWidthConstraints = values.count > 1 ? (1..<values.count).map { index in
|
|
165
|
+
cells[index].widthAnchor.constraint(equalTo: cells[0].widthAnchor,
|
|
166
|
+
multiplier: CGFloat(weights[index]) / CGFloat(weights[0]))
|
|
167
|
+
} : []
|
|
168
|
+
NSLayoutConstraint.activate(columnWidthConstraints)
|
|
169
|
+
columnWeights = normalizedWeights
|
|
119
170
|
}
|
|
120
|
-
|
|
171
|
+
|
|
121
172
|
}
|
|
122
173
|
override func bindSelectionContent(
|
|
123
174
|
_ item: NativeListItem,
|
|
124
175
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
125
|
-
) {
|
|
176
|
+
) {
|
|
177
|
+
let iconUpdate = NativeListIconUpdate(self)
|
|
178
|
+
defer { iconUpdate.finish() }
|
|
179
|
+
|
|
180
|
+
accessories.updateSelection(item, checkboxState: checkboxState)
|
|
181
|
+
trailingAccessories.updateSelection(item, checkboxState: checkboxState)
|
|
182
|
+
|
|
183
|
+
}
|
|
126
184
|
override func recycleContent() {
|
|
127
185
|
visual.recycle()
|
|
128
186
|
accessories.reset()
|
|
187
|
+
trailingAccessories.reset()
|
|
129
188
|
cells.forEach { $0.reset() }
|
|
130
189
|
}
|
|
131
190
|
}
|
|
@@ -133,6 +192,8 @@ final class NativeListDataRowCell: NativeListRendererCell {
|
|
|
133
192
|
private final class NativeListTableColumnView: UIStackView {
|
|
134
193
|
private let primaryLine = UIStackView()
|
|
135
194
|
private let primaryLabel = NativeListTextLabel()
|
|
195
|
+
private let titleIconView = NativeListIconImageView()
|
|
196
|
+
private let secondaryTitleIconView = NativeListIconImageView()
|
|
136
197
|
private let badgesStack = UIStackView()
|
|
137
198
|
private let secondaryLine = UIStackView()
|
|
138
199
|
private let secondaryLeadingLabel = NativeListTextLabel()
|
|
@@ -152,11 +213,21 @@ private final class NativeListTableColumnView: UIStackView {
|
|
|
152
213
|
primaryLabel.numberOfLines = 1
|
|
153
214
|
primaryLabel.lineBreakMode = .byTruncatingTail
|
|
154
215
|
primaryLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
|
216
|
+
for icon in [titleIconView, secondaryTitleIconView] {
|
|
217
|
+
icon.contentMode = .scaleAspectFit
|
|
218
|
+
icon.translatesAutoresizingMaskIntoConstraints = false
|
|
219
|
+
icon.widthAnchor.constraint(equalToConstant: 20).isActive = true
|
|
220
|
+
icon.heightAnchor.constraint(equalToConstant: 20).isActive = true
|
|
221
|
+
icon.setContentHuggingPriority(.required, for: .horizontal)
|
|
222
|
+
icon.isHidden = true
|
|
223
|
+
}
|
|
155
224
|
badgesStack.axis = .horizontal
|
|
156
225
|
badgesStack.alignment = .center
|
|
157
226
|
badgesStack.spacing = 4
|
|
158
227
|
badgesStack.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
159
228
|
primaryLine.addArrangedSubview(primaryLabel)
|
|
229
|
+
primaryLine.addArrangedSubview(titleIconView)
|
|
230
|
+
primaryLine.addArrangedSubview(secondaryTitleIconView)
|
|
160
231
|
primaryLine.addArrangedSubview(badgesStack)
|
|
161
232
|
|
|
162
233
|
secondaryLine.axis = .horizontal
|
|
@@ -178,8 +249,17 @@ private final class NativeListTableColumnView: UIStackView {
|
|
|
178
249
|
fatalError("init(coder:) has not been implemented")
|
|
179
250
|
}
|
|
180
251
|
|
|
181
|
-
func reset() {
|
|
252
|
+
func reset(clearPrimaryText: Bool = true) {
|
|
182
253
|
linear = false
|
|
254
|
+
primaryLine.alignment = .center
|
|
255
|
+
for icon in [titleIconView, secondaryTitleIconView] {
|
|
256
|
+
icon.image = nil
|
|
257
|
+
icon.isHidden = true
|
|
258
|
+
icon.accessibilityLabel = nil
|
|
259
|
+
icon.isAccessibilityElement = false
|
|
260
|
+
}
|
|
261
|
+
primaryLine.setCustomSpacing(UIStackView.spacingUseDefault, after: primaryLabel)
|
|
262
|
+
primaryLine.setCustomSpacing(UIStackView.spacingUseDefault, after: titleIconView)
|
|
183
263
|
for label in [primaryLabel, secondaryLeadingLabel, secondaryLabel] {
|
|
184
264
|
label.rowVerticalAlignment = nil
|
|
185
265
|
label.rowOffsetY = 0
|
|
@@ -190,7 +270,7 @@ private final class NativeListTableColumnView: UIStackView {
|
|
|
190
270
|
primaryLabel.numberOfLines = 1
|
|
191
271
|
secondaryLeadingLabel.numberOfLines = 1
|
|
192
272
|
secondaryLabel.numberOfLines = 1
|
|
193
|
-
primaryLabel.attributedText = nil
|
|
273
|
+
if clearPrimaryText { primaryLabel.attributedText = nil }
|
|
194
274
|
secondaryLeadingLabel.attributedText = nil
|
|
195
275
|
secondaryLabel.attributedText = nil
|
|
196
276
|
secondaryLeadingLabel.isHidden = true
|
|
@@ -202,12 +282,36 @@ private final class NativeListTableColumnView: UIStackView {
|
|
|
202
282
|
}
|
|
203
283
|
}
|
|
204
284
|
|
|
285
|
+
func bindTitleIcons(_ column: [String: Any], theme: [String: Any]?) {
|
|
286
|
+
let descriptors = [column.dictionary("titleIcon"), column.dictionary("secondaryTitleIcon")]
|
|
287
|
+
for (index, descriptor) in descriptors.enumerated() {
|
|
288
|
+
guard let descriptor else { continue }
|
|
289
|
+
let icon = index == 0 ? titleIconView : secondaryTitleIconView
|
|
290
|
+
icon.bindIcon(descriptor.string("name"))
|
|
291
|
+
icon.tintColor = UIColor(
|
|
292
|
+
nativeListHex: descriptor.string("tintColor",
|
|
293
|
+
default: theme?["iconSubdued"] as? String ?? "#8D8D8D"),
|
|
294
|
+
fallback: .gray)
|
|
295
|
+
icon.isHidden = false
|
|
296
|
+
let label = descriptor.string("accessibilityLabel")
|
|
297
|
+
icon.accessibilityLabel = label.isEmpty ? nil : label
|
|
298
|
+
icon.isAccessibilityElement = !label.isEmpty
|
|
299
|
+
}
|
|
300
|
+
if descriptors.contains(where: { $0 != nil }) {
|
|
301
|
+
primaryLine.setCustomSpacing(4, after: primaryLabel)
|
|
302
|
+
primaryLine.setCustomSpacing(4, after: titleIconView)
|
|
303
|
+
if linear { primaryLine.alignment = .top }
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
205
307
|
func bind(
|
|
206
308
|
column: [String: Any],
|
|
207
309
|
badges: [[String: Any]],
|
|
208
310
|
theme: [String: Any]?,
|
|
209
311
|
fonts: NativeListFontFamilies
|
|
210
312
|
) {
|
|
313
|
+
let iconUpdate = NativeListIconUpdate(self)
|
|
314
|
+
defer { iconUpdate.finish() }
|
|
211
315
|
reset()
|
|
212
316
|
let textAlignment: NSTextAlignment
|
|
213
317
|
switch column.string("alignment") {
|
|
@@ -228,7 +332,7 @@ private final class NativeListTableColumnView: UIStackView {
|
|
|
228
332
|
secondaryLeadingLabel.font = nativeListFont(ofSize: 12, fonts: fonts)
|
|
229
333
|
secondaryLabel.font = nativeListFont(ofSize: 12, fonts: fonts)
|
|
230
334
|
primaryLabel.attributedText = line(
|
|
231
|
-
column
|
|
335
|
+
nativeListDataColumnText(column, "text"),
|
|
232
336
|
font: nativeListFont(ofSize: 14, weight: .medium, fonts: fonts),
|
|
233
337
|
color: textColor(column.string("tone"), theme: theme),
|
|
234
338
|
height: 20
|
|
@@ -261,7 +365,7 @@ private final class NativeListTableColumnView: UIStackView {
|
|
|
261
365
|
secondaryLeadingLabel.isHidden = false
|
|
262
366
|
secondaryLine.isHidden = false
|
|
263
367
|
}
|
|
264
|
-
let secondary = column
|
|
368
|
+
let secondary = nativeListDataColumnText(column, "secondaryText")
|
|
265
369
|
if !secondary.isEmpty {
|
|
266
370
|
secondaryLabel.attributedText = line(
|
|
267
371
|
secondary,
|
|
@@ -286,7 +390,7 @@ private final class NativeListTableColumnView: UIStackView {
|
|
|
286
390
|
column: [String: Any], badges: [[String: Any]], theme: [String: Any]?,
|
|
287
391
|
style: [String: Any] = [:], fonts: NativeListFontFamilies
|
|
288
392
|
) {
|
|
289
|
-
reset()
|
|
393
|
+
reset(clearPrimaryText: !linear)
|
|
290
394
|
linear = true
|
|
291
395
|
alignment = .fill
|
|
292
396
|
badgesStack.isHidden = true
|
|
@@ -331,14 +435,15 @@ private final class NativeListTableColumnView: UIStackView {
|
|
|
331
435
|
primaryLabel.textAlignment =
|
|
332
436
|
column.string("alignment") == "end"
|
|
333
437
|
? .right : column.string("alignment") == "center" ? .center : .left
|
|
334
|
-
let secondary = column
|
|
438
|
+
let secondary = nativeListDataColumnText(column, "secondaryText")
|
|
335
439
|
let primaryFont = font(primaryStyle, size: 14, weight: .medium)
|
|
336
440
|
let attributed = NSMutableAttributedString(
|
|
337
|
-
string: column
|
|
441
|
+
string: nativeListDataColumnText(column, "text"),
|
|
338
442
|
attributes: [
|
|
339
443
|
.font: primaryFont,
|
|
340
444
|
.foregroundColor: color(primaryStyle, textColor(column.string("tone"), theme: theme)),
|
|
341
445
|
])
|
|
446
|
+
attributed.setAttributedString(nativeListDataSegments(attributed, column.dictionaries("textSegments")))
|
|
342
447
|
let primaryLength = attributed.length
|
|
343
448
|
// Every badge run is the legacy " text " pill: both lead spaces sit inside the badge
|
|
344
449
|
// background and are its left padding. `titleBadgeGap` adds an exact, unfilled gap between
|
|
@@ -378,7 +483,10 @@ private final class NativeListTableColumnView: UIStackView {
|
|
|
378
483
|
textColor(column.string("secondaryTone", default: "secondary"), theme: theme)),
|
|
379
484
|
]
|
|
380
485
|
attributes.merge(paragraph(secondaryStyle, font: secondaryFont, spacing: nil)) { $1 }
|
|
381
|
-
attributed.append(NSAttributedString(string: "\n
|
|
486
|
+
attributed.append(NSAttributedString(string: "\n", attributes: attributes))
|
|
487
|
+
attributed.append(nativeListDataSegments(
|
|
488
|
+
NSAttributedString(string: secondary, attributes: attributes),
|
|
489
|
+
column.dictionaries("secondaryTextSegments")))
|
|
382
490
|
lines = min(3, lines + max(1, secondaryStyle.int("lines", default: 1)))
|
|
383
491
|
}
|
|
384
492
|
primaryLabel.font = nativeListFont(ofSize: 12, fonts: fonts)
|
|
@@ -400,6 +508,16 @@ private final class NativeListTableColumnView: UIStackView {
|
|
|
400
508
|
primaryStyle.double("offsetY", default: secondaryStyle.double("offsetY")))
|
|
401
509
|
}
|
|
402
510
|
|
|
511
|
+
func applySegments(_ column: [String: Any]) {
|
|
512
|
+
guard !linear else { return }
|
|
513
|
+
if let text = primaryLabel.attributedText {
|
|
514
|
+
primaryLabel.attributedText = nativeListDataSegments(text, column.dictionaries("textSegments"))
|
|
515
|
+
}
|
|
516
|
+
if let text = secondaryLabel.attributedText {
|
|
517
|
+
secondaryLabel.attributedText = nativeListDataSegments(text, column.dictionaries("secondaryTextSegments"))
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
403
521
|
func applyStyle(_ style: [String: Any], text: (UILabel, [String: Any]) -> Void) {
|
|
404
522
|
// The linear single label already mapped its styles onto attributed ranges.
|
|
405
523
|
guard !linear else { return }
|
|
@@ -446,3 +564,22 @@ private final class NativeListTableColumnView: UIStackView {
|
|
|
446
564
|
}
|
|
447
565
|
}
|
|
448
566
|
}
|
|
567
|
+
|
|
568
|
+
private func nativeListDataColumnText(_ column: [String: Any], _ field: String) -> String {
|
|
569
|
+
let segments = column.dictionaries("\(field)Segments")
|
|
570
|
+
return segments.isEmpty ? column.string(field) : segments.map { $0.string("text") }.joined()
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
private func nativeListDataSegments(_ fallback: NSAttributedString, _ segments: [[String: Any]]) -> NSAttributedString {
|
|
574
|
+
guard !segments.isEmpty, fallback.length > 0 else { return fallback }
|
|
575
|
+
let attributes = fallback.attributes(at: 0, effectiveRange: nil)
|
|
576
|
+
let result = NSMutableAttributedString(string: "")
|
|
577
|
+
for segment in segments {
|
|
578
|
+
var runAttributes = attributes
|
|
579
|
+
if segment.string("style") == "subscript", let font = attributes[.font] as? UIFont {
|
|
580
|
+
runAttributes[.font] = font.withSize(ceil(font.pointSize * 0.6))
|
|
581
|
+
}
|
|
582
|
+
result.append(NSAttributedString(string: segment.string("text"), attributes: runAttributes))
|
|
583
|
+
}
|
|
584
|
+
return result
|
|
585
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import CoreText
|
|
2
|
+
import OneKeyImage
|
|
2
3
|
import UIKit
|
|
3
4
|
|
|
4
|
-
private final class NativeListResourceToken {}
|
|
5
|
-
|
|
6
5
|
enum NativeListFontWeight {
|
|
7
6
|
case regular
|
|
8
7
|
case medium
|
|
@@ -19,19 +18,6 @@ enum NativeListFontWeight {
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
private enum NativeListResources {
|
|
23
|
-
static let bundle: Bundle = {
|
|
24
|
-
let owners = [Bundle(for: NativeListResourceToken.self), .main]
|
|
25
|
-
for owner in owners {
|
|
26
|
-
if let url = owner.url(forResource: "NativeListResources", withExtension: "bundle"),
|
|
27
|
-
let bundle = Bundle(url: url) {
|
|
28
|
-
return bundle
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return Bundle(for: NativeListResourceToken.self)
|
|
32
|
-
}()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
21
|
struct NativeListFontFamilies: Equatable {
|
|
36
22
|
let names: [String: String]
|
|
37
23
|
init(names: [String: String] = [:]) { self.names = names }
|
|
@@ -84,67 +70,19 @@ func nativeListTabularFont(
|
|
|
84
70
|
descriptor: font.fontDescriptor.addingAttributes([.featureSettings: settings]), size: size)
|
|
85
71
|
}
|
|
86
72
|
|
|
87
|
-
func
|
|
88
|
-
// OneKey patch: the connection indicator is a solid circle at its requested size.
|
|
73
|
+
func nativeListIconMetadata(named name: String) -> NativeListIconMetadata? {
|
|
89
74
|
if name == "Circle" {
|
|
90
|
-
return
|
|
91
|
-
UIColor.black.setFill()
|
|
92
|
-
UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: 24, height: 24)).fill()
|
|
93
|
-
}.withRenderingMode(.alwaysTemplate)
|
|
75
|
+
return NativeListIconMetadata(name: "Circle", size: CGSize(width: 24, height: 24), original: false)
|
|
94
76
|
}
|
|
95
|
-
let
|
|
96
|
-
|
|
97
|
-
// OneKey patch: official selector icon geometry.
|
|
98
|
-
case "AccountErrorCustom": assetName = "onekey_selector_account_error_custom"
|
|
99
|
-
// OneKey patch: official selector icon geometry.
|
|
100
|
-
case "CrossedSmallSolid": assetName = "onekey_selector_crossed_small_solid"
|
|
101
|
-
// OneKey patch: official selector icon geometry.
|
|
102
|
-
case "AllNetworksSolid": assetName = "onekey_selector_all_networks_solid"
|
|
103
|
-
// OneKey patch: official selector icon geometry.
|
|
104
|
-
case "BotIllus": assetName = "onekey_selector_bot_illus"
|
|
105
|
-
// OneKey patch: official selector icon geometry.
|
|
106
|
-
case "AppleBrand": assetName = "onekey_selector_apple_brand"
|
|
107
|
-
// OneKey patch: official selector icon geometry.
|
|
108
|
-
case "GoogleIllus": assetName = "onekey_selector_google_illus"
|
|
109
|
-
// OneKey patch: official selector icon geometry.
|
|
110
|
-
case "LockSolid": assetName = "onekey_selector_lock_solid"
|
|
111
|
-
// OneKey patch: official selector icon geometry.
|
|
112
|
-
case "GlobusOutline": assetName = "onekey_selector_globus_outline"
|
|
113
|
-
case "ArrowBottomOutline": assetName = "onekey_arrow_bottom"
|
|
114
|
-
case "ArrowTopOutline": assetName = "onekey_arrow_top"
|
|
115
|
-
case "ChartTrendingUpOutline": assetName = "onekey_chart_trending_up"
|
|
116
|
-
case "SwapHorOutline": assetName = "onekey_swap_hor"
|
|
117
|
-
case "ShieldExclamationOutline": assetName = "onekey_shield_exclamation"
|
|
118
|
-
case "InfoCircleOutline": assetName = "onekey_info_circle"
|
|
119
|
-
case "SpeakerPromoteOutline": assetName = "onekey_speaker_promote"
|
|
120
|
-
case "PlusCircleOutline": assetName = "onekey_plus_circle"
|
|
121
|
-
case "PlusSmallOutline": assetName = "onekey_plus_small"
|
|
122
|
-
case "DotHorOutline": assetName = "onekey_dot_hor"
|
|
123
|
-
case "PencilOutline": assetName = "onekey_pencil"
|
|
124
|
-
case "MinusCircleSolid": assetName = "onekey_minus_circle_solid"
|
|
125
|
-
case "MinusCircleOutline": assetName = "onekey_minus_circle"
|
|
126
|
-
case "ChevronRightSmallOutline": assetName = "onekey_chevron_right_small"
|
|
127
|
-
case "DragOutline": assetName = "onekey_drag"
|
|
128
|
-
case "StarOutline": assetName = "onekey_star"
|
|
129
|
-
case "StarSolid": assetName = "onekey_star_solid"
|
|
130
|
-
case "BadgeVerifiedSolid": assetName = "onekey_badge_verified_solid"
|
|
131
|
-
case "ChevronGrabberVerOutline": assetName = "onekey_chevron_grabber_ver"
|
|
132
|
-
case "ChevronBottomOutline": assetName = "onekey_chevron_bottom"
|
|
133
|
-
case "ChevronTopOutline": assetName = "onekey_chevron_top"
|
|
134
|
-
case "CheckboxCheckedCustom": assetName = "onekey_checkbox_checked"
|
|
135
|
-
case "CheckboxIndeterminateCustom": assetName = "onekey_checkbox_indeterminate"
|
|
136
|
-
case "ErrorSolid": assetName = "onekey_error_solid"
|
|
137
|
-
case "QuestionmarkSolid": assetName = "onekey_questionmark_solid"
|
|
138
|
-
case "ImageSquareWavesOutline": assetName = "onekey_image_square_waves"
|
|
139
|
-
default: return nil
|
|
77
|
+
if let generated = NativeListGeneratedIcons.icons[name] {
|
|
78
|
+
return generated
|
|
140
79
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}.withRenderingMode(.alwaysTemplate)
|
|
80
|
+
guard let meta = OneKeyNamedSVG.shared.iconMetadata(forName: name) else {
|
|
81
|
+
return nil
|
|
82
|
+
}
|
|
83
|
+
return NativeListIconMetadata(
|
|
84
|
+
name: name,
|
|
85
|
+
size: CGSize(width: meta.width, height: meta.height),
|
|
86
|
+
original: meta.recolorMode == .fixed || meta.recolorMode == .raster
|
|
87
|
+
)
|
|
150
88
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Generated by scripts/generate-icons.mjs. Coverage and legacy names only; hosts provide SVG resources.
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
struct NativeListIconMetadata {
|
|
5
|
+
let name: String
|
|
6
|
+
let size: CGSize
|
|
7
|
+
let original: Bool
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
enum NativeListGeneratedIcons {
|
|
11
|
+
static let icons: [String: NativeListIconMetadata] = [
|
|
12
|
+
"AccountErrorCustom": NativeListIconMetadata(name: "AccountErrorCustom", size: CGSize(width: 18, height: 18), original: true),
|
|
13
|
+
"AllNetworksSolid": NativeListIconMetadata(name: "AllNetworksSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
14
|
+
"AppleBrand": NativeListIconMetadata(name: "AppleBrand", size: CGSize(width: 16, height: 20), original: false),
|
|
15
|
+
"ArrowBottomOutline": NativeListIconMetadata(name: "ArrowBottomOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
16
|
+
"ArrowTopOutline": NativeListIconMetadata(name: "ArrowTopOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
17
|
+
"BadgeVerifiedSolid": NativeListIconMetadata(name: "BadgeRecognizedSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
18
|
+
"BotIllus": NativeListIconMetadata(name: "BotIllus", size: CGSize(width: 24, height: 24), original: true),
|
|
19
|
+
"ChartTrendingUpOutline": NativeListIconMetadata(name: "ChartTrendingUpOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
20
|
+
"CheckboxCheckedCustom": NativeListIconMetadata(name: "CheckboxCheckedCustom", size: CGSize(width: 16, height: 16), original: false),
|
|
21
|
+
"CheckboxIndeterminateCustom": NativeListIconMetadata(name: "CheckboxIndeterminateCustom", size: CGSize(width: 16, height: 16), original: false),
|
|
22
|
+
"ChevronBottomOutline": NativeListIconMetadata(name: "ChevronBottomOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
23
|
+
"ChevronGrabberVerOutline": NativeListIconMetadata(name: "ChevronGrabberVerOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
24
|
+
"ChevronRightSmallOutline": NativeListIconMetadata(name: "ChevronRightSmallOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
25
|
+
"ChevronTopOutline": NativeListIconMetadata(name: "ChevronTopOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
26
|
+
"CrossedSmallSolid": NativeListIconMetadata(name: "CrossedSmallSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
27
|
+
"CryptoCoinOutline": NativeListIconMetadata(name: "CryptoCoinOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
28
|
+
"Document2Outline": NativeListIconMetadata(name: "Document2Outline", size: CGSize(width: 24, height: 24), original: false),
|
|
29
|
+
"DotHorOutline": NativeListIconMetadata(name: "DotHorOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
30
|
+
"DotVerSolid": NativeListIconMetadata(name: "DotVerSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
31
|
+
"DragOutline": NativeListIconMetadata(name: "DragOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
32
|
+
"ErrorSolid": NativeListIconMetadata(name: "ErrorSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
33
|
+
"GasSolid": NativeListIconMetadata(name: "GasSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
34
|
+
"GlobusOutline": NativeListIconMetadata(name: "GlobusOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
35
|
+
"GoogleIllus": NativeListIconMetadata(name: "GoogleIllus", size: CGSize(width: 24, height: 24), original: true),
|
|
36
|
+
"ImageSquareWavesOutline": NativeListIconMetadata(name: "ImageSquareWavesOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
37
|
+
"InfoCircleOutline": NativeListIconMetadata(name: "InfoCircleOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
38
|
+
"LockSolid": NativeListIconMetadata(name: "LockSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
39
|
+
"MinusCircleOutline": NativeListIconMetadata(name: "MinusCircleOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
40
|
+
"MinusCircleSolid": NativeListIconMetadata(name: "MinusCircleSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
41
|
+
"PencilOutline": NativeListIconMetadata(name: "PencilOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
42
|
+
"PlusCircleOutline": NativeListIconMetadata(name: "PlusCircleOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
43
|
+
"PlusLargeOutline": NativeListIconMetadata(name: "PlusLargeOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
44
|
+
"PlusSmallOutline": NativeListIconMetadata(name: "PlusSmallOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
45
|
+
"QuestionmarkSolid": NativeListIconMetadata(name: "QuestionmarkSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
46
|
+
"RefreshCcwOutline": NativeListIconMetadata(name: "RefreshCcwOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
47
|
+
"ShieldExclamationOutline": NativeListIconMetadata(name: "ShieldExclamationOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
48
|
+
"SpeakerPromoteOutline": NativeListIconMetadata(name: "SpeakerPromoteOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
49
|
+
"StarOutline": NativeListIconMetadata(name: "StarOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
50
|
+
"StarSolid": NativeListIconMetadata(name: "StarSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
51
|
+
"SwapHorOutline": NativeListIconMetadata(name: "SwapHorOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
52
|
+
"TicketOutline": NativeListIconMetadata(name: "TicketOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
53
|
+
"WalletOutline": NativeListIconMetadata(name: "WalletOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
54
|
+
]
|
|
55
|
+
}
|