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