@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
|
@@ -23,14 +23,21 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
23
23
|
private val icon = OneKeyIconView(context)
|
|
24
24
|
private val unread = View(context)
|
|
25
25
|
private val networkBackdrop = View(context)
|
|
26
|
+
// Ring under the secondary token of an Activity pair (SPEC "Activity leading pair").
|
|
27
|
+
private val pairBackdrop = View(context)
|
|
26
28
|
private val corner = OneKeyIconView(context)
|
|
27
29
|
private val cornerBackdrop = View(context)
|
|
28
30
|
private val slots = mutableListOf<NativeListImageSlot>()
|
|
29
31
|
private val overlaySlots = mutableListOf<NativeListImageSlot>()
|
|
32
|
+
private val overlayFallbackIcons = mutableListOf<OneKeyIconView>()
|
|
30
33
|
private val overlays = mutableListOf<Pair<FrameLayout, JSONObject>>()
|
|
31
34
|
private var visual = JSONObject()
|
|
32
35
|
private var style = JSONObject()
|
|
33
36
|
private var sources = emptyList<Pair<JSONObject, String>>()
|
|
37
|
+
// Roles inside [sources]: the token `networkImage` badge and the Activity
|
|
38
|
+
// `secondaryLeading` token; null when absent.
|
|
39
|
+
private var networkIndex: Int? = null
|
|
40
|
+
private var pairIndex: Int? = null
|
|
34
41
|
val fallbackTextView: TextView
|
|
35
42
|
get() = fallback
|
|
36
43
|
|
|
@@ -42,6 +49,15 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
42
49
|
*/
|
|
43
50
|
var walletTextOverlays = false
|
|
44
51
|
|
|
52
|
+
/**
|
|
53
|
+
* True once the bound visual lays a badge past this frame (see
|
|
54
|
+
* [nativeListLeadingVisualOverhangsFrame]). This view never clips its children,
|
|
55
|
+
* but a host that clips children clips this view to its own bounds, so such a
|
|
56
|
+
* host must stop clipping or the badge is cut flat (OK-65694).
|
|
57
|
+
*/
|
|
58
|
+
var requestsUnclippedHost = false
|
|
59
|
+
private set
|
|
60
|
+
|
|
45
61
|
private fun isWalletText(data: JSONObject) =
|
|
46
62
|
walletTextOverlays &&
|
|
47
63
|
data.optString("text").isNotEmpty() &&
|
|
@@ -80,7 +96,9 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
80
96
|
}
|
|
81
97
|
|
|
82
98
|
init {
|
|
83
|
-
listOf(fallback, icon, networkBackdrop, cornerBackdrop, corner, unread).forEach {
|
|
99
|
+
listOf(fallback, icon, pairBackdrop, networkBackdrop, cornerBackdrop, corner, unread).forEach {
|
|
100
|
+
addView(it)
|
|
101
|
+
}
|
|
84
102
|
clipChildren = false
|
|
85
103
|
clipToPadding = false
|
|
86
104
|
}
|
|
@@ -94,6 +112,9 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
94
112
|
sourceScale: Boolean,
|
|
95
113
|
secondaryVisual: JSONObject? = null,
|
|
96
114
|
) {
|
|
115
|
+
val iconUpdate = NativeListIconUpdate(this)
|
|
116
|
+
try {
|
|
117
|
+
|
|
97
118
|
fallback.typeface = fonts.bold(context)
|
|
98
119
|
this.visual = visual
|
|
99
120
|
this.style = style
|
|
@@ -109,6 +130,8 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
109
130
|
"wallet" -> "avatar"
|
|
110
131
|
else -> "generic"
|
|
111
132
|
}
|
|
133
|
+
networkIndex = null
|
|
134
|
+
pairIndex = null
|
|
112
135
|
sources =
|
|
113
136
|
if (kind == "stackedImages")
|
|
114
137
|
visual
|
|
@@ -122,7 +145,10 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
122
145
|
else if (kind == "icon") emptyList()
|
|
123
146
|
else visual.optJSONObject("image")?.let { listOf(it to variant) }.orEmpty()
|
|
124
147
|
if (kind == "token" && sources.isNotEmpty())
|
|
125
|
-
visual.optJSONObject("networkImage")?.let {
|
|
148
|
+
visual.optJSONObject("networkImage")?.let {
|
|
149
|
+
networkIndex = sources.size
|
|
150
|
+
sources = sources + (it to "network")
|
|
151
|
+
}
|
|
126
152
|
secondaryVisual?.let { second ->
|
|
127
153
|
val kind = second.optString("kind")
|
|
128
154
|
val source =
|
|
@@ -131,7 +157,10 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
131
157
|
"icon" -> null
|
|
132
158
|
else -> second.optJSONObject("image")
|
|
133
159
|
}
|
|
134
|
-
if (source != null)
|
|
160
|
+
if (source != null) {
|
|
161
|
+
// A second token forms a pair only next to a primary image; without one
|
|
162
|
+
// it simply takes the primary's place (OK-66071).
|
|
163
|
+
if (this.visual.optString("kind") == "token" && sources.isNotEmpty()) pairIndex = sources.size
|
|
135
164
|
sources =
|
|
136
165
|
sources +
|
|
137
166
|
(source to
|
|
@@ -142,6 +171,7 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
142
171
|
"wallet" -> "avatar"
|
|
143
172
|
else -> "generic"
|
|
144
173
|
})
|
|
174
|
+
}
|
|
145
175
|
}
|
|
146
176
|
while (slots.size < sources.size) {
|
|
147
177
|
val slot = NativeListImageSlot(reactContext)
|
|
@@ -150,6 +180,8 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
150
180
|
}
|
|
151
181
|
val placeholder = theme?.optString("strongBackground", "#0000000F") ?: "#0000000F"
|
|
152
182
|
val fallbackIcon = visual.optJSONObject("fallbackIcon")
|
|
183
|
+
val fallbackBackground = fallbackIcon?.optString("backgroundColor")
|
|
184
|
+
?.takeIf(String::isNotEmpty) ?: placeholder
|
|
153
185
|
val sourceFallback =
|
|
154
186
|
sources.firstOrNull()?.first?.optString("loadingStrategy", "none")?.let { it != "none" } ==
|
|
155
187
|
true && (visual.has("fallbackText") || fallbackIcon != null)
|
|
@@ -170,7 +202,7 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
170
202
|
val restored = fallbackKey?.let(NativeListSourceFallbackState::has) == true
|
|
171
203
|
fallback.textSize = if (sourceScale) 13f else NativeListScale.font(resources, 13f)
|
|
172
204
|
fallback.text = visual.optString("fallbackText").take(2)
|
|
173
|
-
fallback.setTextColor(color("#00000072"))
|
|
205
|
+
fallback.setTextColor(color(visual.optString("fallbackTextColor", "#00000072")))
|
|
174
206
|
fallback.visibility =
|
|
175
207
|
if (kind != "icon" && fallbackIcon == null && (sources.isEmpty() || restored)) VISIBLE
|
|
176
208
|
else GONE
|
|
@@ -184,7 +216,9 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
184
216
|
color(
|
|
185
217
|
visual.optString("backgroundColor", if (sources.isEmpty()) placeholder else "#00000000")
|
|
186
218
|
)
|
|
187
|
-
val backgroundColor =
|
|
219
|
+
val backgroundColor =
|
|
220
|
+
if (sources.isEmpty() && fallbackIcon?.has("backgroundColor") == true || restored) color(fallbackBackground)
|
|
221
|
+
else if (sourceFallback) color(placeholder) else visualBackground
|
|
188
222
|
background =
|
|
189
223
|
fill(backgroundColor, 0f).apply {
|
|
190
224
|
if (kind == "icon" && iconBorder) setStroke(1, color("#0000001F"))
|
|
@@ -201,7 +235,7 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
201
235
|
slot.recycle()
|
|
202
236
|
slot.view.visibility = GONE
|
|
203
237
|
} else {
|
|
204
|
-
slot.view.visibility = if (index > 0 ||
|
|
238
|
+
slot.view.visibility = if (index > 0 || restored) INVISIBLE else VISIBLE
|
|
205
239
|
slot.bind(
|
|
206
240
|
sources[index].first,
|
|
207
241
|
"$key:leading:$index",
|
|
@@ -214,13 +248,14 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
214
248
|
) { loaded ->
|
|
215
249
|
slot.view.visibility =
|
|
216
250
|
if (!loaded && (index > 0 || sourceFallback)) INVISIBLE else VISIBLE
|
|
251
|
+
if (index == pairIndex) syncPairBackdrop()
|
|
217
252
|
if (index == 0 && sourceFallback) {
|
|
218
253
|
fallbackKey?.let {
|
|
219
254
|
if (loaded) NativeListSourceFallbackState.forget(it)
|
|
220
255
|
else NativeListSourceFallbackState.remember(it)
|
|
221
256
|
}
|
|
222
257
|
(background as? GradientDrawable)?.setColor(
|
|
223
|
-
if (loaded) visualBackground else color(
|
|
258
|
+
if (loaded) visualBackground else color(fallbackBackground)
|
|
224
259
|
)
|
|
225
260
|
fallback.visibility = if (!loaded && fallbackIcon == null) VISIBLE else GONE
|
|
226
261
|
icon.visibility = if (!loaded && fallbackIcon != null) VISIBLE else GONE
|
|
@@ -228,9 +263,21 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
228
263
|
}
|
|
229
264
|
}
|
|
230
265
|
}
|
|
231
|
-
networkBackdrop.visibility = if (
|
|
266
|
+
networkBackdrop.visibility = if (networkIndex != null) VISIBLE else GONE
|
|
232
267
|
networkBackdrop.background =
|
|
233
268
|
fill(color(theme?.optString("rowBackground", "#FFFFFF") ?: "#FFFFFF"), dp(10).toFloat())
|
|
269
|
+
pairBackdrop.background =
|
|
270
|
+
fill(color(theme?.optString("rowBackground", "#FFFFFF") ?: "#FFFFFF"), 0f)
|
|
271
|
+
syncPairBackdrop()
|
|
272
|
+
// Stacking order by role: primary, pair ring, secondary token, badge
|
|
273
|
+
// backdrop, badge, corner icon. Slots are reused across binds with
|
|
274
|
+
// different roles, so the order is restored on every bind.
|
|
275
|
+
pairBackdrop.bringToFront()
|
|
276
|
+
pairIndex?.let { slots[it].view.bringToFront() }
|
|
277
|
+
networkBackdrop.bringToFront()
|
|
278
|
+
networkIndex?.let { slots[it].view.bringToFront() }
|
|
279
|
+
cornerBackdrop.bringToFront()
|
|
280
|
+
corner.bringToFront()
|
|
234
281
|
val badge = visual.optJSONObject("cornerIcon")
|
|
235
282
|
corner.visibility = if (badge == null) GONE else VISIBLE
|
|
236
283
|
cornerBackdrop.visibility = corner.visibility
|
|
@@ -255,9 +302,26 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
255
302
|
.optJSONArray("overlays")
|
|
256
303
|
?.let { values -> (0 until minOf(2, values.length())).map { values.getJSONObject(it) } }
|
|
257
304
|
.orEmpty()
|
|
305
|
+
requestsUnclippedHost =
|
|
306
|
+
nativeListLeadingVisualOverhangsFrame(
|
|
307
|
+
kind = kind,
|
|
308
|
+
sourceCount = sources.size,
|
|
309
|
+
hasCornerIcon = badge != null,
|
|
310
|
+
overlayCount = descriptors.size,
|
|
311
|
+
)
|
|
258
312
|
while (overlaySlots.size < descriptors.size) overlaySlots.add(NativeListImageSlot(reactContext))
|
|
313
|
+
while (overlayFallbackIcons.size < descriptors.size)
|
|
314
|
+
overlayFallbackIcons.add(OneKeyIconView(context))
|
|
259
315
|
descriptors.forEachIndexed { index, data ->
|
|
260
316
|
val frame = previousOverlays.getOrNull(index)?.first ?: FrameLayout(context)
|
|
317
|
+
val image = data.optJSONObject("image")
|
|
318
|
+
val fallbackData = data.optJSONObject("fallbackIcon")
|
|
319
|
+
val fallbackGlyph = overlayFallbackIcons[index].apply {
|
|
320
|
+
visibility = GONE
|
|
321
|
+
iconName = fallbackData?.optString("name") ?: ""
|
|
322
|
+
tintColor = color(fallbackData?.optString("tintColor", "#0000009B") ?: "#0000009B")
|
|
323
|
+
useSourceScale = sourceScale
|
|
324
|
+
}
|
|
261
325
|
frame.background =
|
|
262
326
|
fill(
|
|
263
327
|
color(data.optString("backgroundColor", "#00000000")),
|
|
@@ -269,11 +333,15 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
269
333
|
frame.outlineProvider = ViewOutlineProvider.BACKGROUND
|
|
270
334
|
frame.clipToOutline = true
|
|
271
335
|
val child: View =
|
|
272
|
-
|
|
336
|
+
image?.let { source ->
|
|
273
337
|
val slot = overlaySlots[index]
|
|
274
338
|
slot.view.visibility = INVISIBLE
|
|
275
|
-
|
|
339
|
+
val circularImage = data.optInt("padding", 0) > 0 &&
|
|
340
|
+
data.optInt("width", data.optInt("size", 20)) == overlayHeight(data)
|
|
341
|
+
slot.bind(source, "$key:overlay:$index", placeholder = placeholder,
|
|
342
|
+
round = circularImage) {
|
|
276
343
|
slot.view.visibility = if (it) VISIBLE else INVISIBLE
|
|
344
|
+
fallbackGlyph.visibility = if (!it && fallbackData != null) VISIBLE else GONE
|
|
277
345
|
}
|
|
278
346
|
slot.view
|
|
279
347
|
}
|
|
@@ -290,8 +358,13 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
290
358
|
if (walletText) androidx.core.widget.TextViewCompat.setLineHeight(this, dp(16))
|
|
291
359
|
else setLineSpacing(0f, 1f)
|
|
292
360
|
typeface =
|
|
293
|
-
|
|
294
|
-
|
|
361
|
+
when (data.optString("fontWeight")) {
|
|
362
|
+
"regular" -> fonts.regular(context)
|
|
363
|
+
"medium" -> fonts.medium(context)
|
|
364
|
+
"semibold" -> fonts.semibold(context)
|
|
365
|
+
"bold" -> fonts.bold(context)
|
|
366
|
+
else -> if (isWalletText(data)) fonts.regular(context) else fonts.medium(context)
|
|
367
|
+
}
|
|
295
368
|
setTextColor(color(data.optString("tintColor", "#0000009B")))
|
|
296
369
|
}
|
|
297
370
|
} else {
|
|
@@ -305,13 +378,15 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
305
378
|
val inset = data.optInt("padding", 0)
|
|
306
379
|
if (isWalletText(data)) frame.setPadding(dp(2), 0, dp(2), 0)
|
|
307
380
|
else frame.setPadding(dp(inset), dp(inset), dp(inset), dp(inset))
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
381
|
+
frame.removeAllViews()
|
|
382
|
+
// A reused slot view may still belong to a frame dropped by an earlier bind.
|
|
383
|
+
(child.parent as? android.view.ViewGroup)?.removeView(child)
|
|
384
|
+
frame.addView(child, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
385
|
+
if (image != null && fallbackData != null) {
|
|
386
|
+
(fallbackGlyph.parent as? android.view.ViewGroup)?.removeView(fallbackGlyph)
|
|
387
|
+
frame.addView(fallbackGlyph, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
313
388
|
}
|
|
314
|
-
if (frame.parent == null) addView(frame)
|
|
389
|
+
if (frame.parent == null) addView(frame) else frame.bringToFront()
|
|
315
390
|
overlays.add(frame to data)
|
|
316
391
|
}
|
|
317
392
|
previousOverlays.drop(descriptors.size).forEach { (frame, _) ->
|
|
@@ -322,6 +397,8 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
322
397
|
overlaySlots.drop(descriptors.size).forEach { it.recycle() }
|
|
323
398
|
unread.bringToFront()
|
|
324
399
|
requestLayout()
|
|
400
|
+
|
|
401
|
+
} finally { iconUpdate.finish() }
|
|
325
402
|
}
|
|
326
403
|
|
|
327
404
|
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
|
@@ -367,8 +444,11 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
367
444
|
)
|
|
368
445
|
}
|
|
369
446
|
place(fallback, 0, 0, w, h)
|
|
447
|
+
val explicitFallbackSize = visual.optJSONObject("fallbackIcon")
|
|
448
|
+
?.optDouble("size", Double.NaN)?.takeIf { it.isFinite() && it > 0.0 }
|
|
370
449
|
val iconSize =
|
|
371
|
-
if (
|
|
450
|
+
if (explicitFallbackSize != null) dp(explicitFallbackSize.roundToInt())
|
|
451
|
+
else if (sources.isNotEmpty() && visual.optJSONObject("fallbackIcon") != null)
|
|
372
452
|
(minOf(w, h) *
|
|
373
453
|
if (visual.optJSONObject("fallbackIcon")?.optString("name") == "GlobusOutline") 1.2f
|
|
374
454
|
else 1f)
|
|
@@ -381,28 +461,46 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
381
461
|
iconSize,
|
|
382
462
|
iconSize,
|
|
383
463
|
)
|
|
384
|
-
val
|
|
464
|
+
val ring = dp(2)
|
|
385
465
|
slots.take(sources.size).forEachIndexed { index, slot ->
|
|
386
|
-
val
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
466
|
+
val frame =
|
|
467
|
+
nativeListLeadingSlotFrame(
|
|
468
|
+
index = index,
|
|
469
|
+
sourceCount = sources.size,
|
|
470
|
+
networkIndex = networkIndex,
|
|
471
|
+
pairIndex = pairIndex,
|
|
472
|
+
width = w,
|
|
473
|
+
height = h,
|
|
474
|
+
badgeSize = dp(16),
|
|
475
|
+
badgeOverhang = dp(2),
|
|
476
|
+
pairRing = ring,
|
|
477
|
+
)
|
|
395
478
|
slot.view.measure(
|
|
396
|
-
MeasureSpec.makeMeasureSpec(
|
|
397
|
-
MeasureSpec.makeMeasureSpec(
|
|
479
|
+
MeasureSpec.makeMeasureSpec(frame.width, MeasureSpec.EXACTLY),
|
|
480
|
+
MeasureSpec.makeMeasureSpec(frame.height, MeasureSpec.EXACTLY),
|
|
398
481
|
)
|
|
399
482
|
val inset = if (index == 0) bitmapBorderWidth else 0
|
|
400
|
-
place(
|
|
483
|
+
place(
|
|
484
|
+
slot.view,
|
|
485
|
+
frame.x + inset,
|
|
486
|
+
frame.y + inset,
|
|
487
|
+
frame.width - 2 * inset,
|
|
488
|
+
frame.height - 2 * inset,
|
|
489
|
+
)
|
|
401
490
|
val imageRadius =
|
|
402
491
|
if (shape == "rounded" && !style.has("shape") && !style.has("cornerRadius"))
|
|
403
492
|
dp(roundedImageRadius).toFloat()
|
|
404
493
|
else radius
|
|
405
|
-
val
|
|
494
|
+
val fillsFrame = index == 0 && pairIndex == null && (sources.size == 1 || networkIndex != null)
|
|
495
|
+
val r =
|
|
496
|
+
when {
|
|
497
|
+
fillsFrame -> imageRadius
|
|
498
|
+
// Pair members keep the token shape at their own size (rounded NFTs
|
|
499
|
+
// use the box's 10dp rule scaled to the member).
|
|
500
|
+
pairIndex != null && index != networkIndex && shape == "rounded" ->
|
|
501
|
+
minOf(dp(roundedImageRadius).toFloat(), frame.height / 4f)
|
|
502
|
+
else -> frame.height / 2f
|
|
503
|
+
}
|
|
406
504
|
slot.view.outlineProvider =
|
|
407
505
|
object : ViewOutlineProvider() {
|
|
408
506
|
override fun getOutline(view: View, outline: Outline) {
|
|
@@ -413,6 +511,14 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
413
511
|
}
|
|
414
512
|
slot.view.clipToOutline = true
|
|
415
513
|
}
|
|
514
|
+
if (pairIndex != null) {
|
|
515
|
+
val member = nativeListLeadingPairMemberSize(h)
|
|
516
|
+
val box = member + 2 * ring
|
|
517
|
+
(pairBackdrop.background as? GradientDrawable)?.cornerRadius =
|
|
518
|
+
if (shape == "rounded") minOf(dp(roundedImageRadius).toFloat(), member / 4f) + ring
|
|
519
|
+
else box / 2f
|
|
520
|
+
place(pairBackdrop, w - box, h - box, box, box)
|
|
521
|
+
}
|
|
416
522
|
place(networkBackdrop, w - dp(16), h - dp(16), dp(20), dp(20))
|
|
417
523
|
place(cornerBackdrop, w - dp(16), h - dp(16), dp(20), dp(20))
|
|
418
524
|
place(corner, w - dp(15), h - dp(15), dp(18), dp(18))
|
|
@@ -442,9 +548,22 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
442
548
|
}
|
|
443
549
|
}
|
|
444
550
|
|
|
551
|
+
/**
|
|
552
|
+
* The pair ring sits above the primary token, so it is shown only while the
|
|
553
|
+
* secondary token image is actually displayed: hidden while that image loads,
|
|
554
|
+
* after a failed load and once the slot is recycled, or it would cover the
|
|
555
|
+
* primary's lower-right corner with a blank row-background disc.
|
|
556
|
+
*/
|
|
557
|
+
private fun syncPairBackdrop() {
|
|
558
|
+
val secondary = pairIndex?.let { slots.getOrNull(it) }
|
|
559
|
+
pairBackdrop.visibility =
|
|
560
|
+
if (secondary != null && secondary.view.visibility == VISIBLE) VISIBLE else GONE
|
|
561
|
+
}
|
|
562
|
+
|
|
445
563
|
fun recycle() {
|
|
446
564
|
slots.forEach { it.recycle() }
|
|
447
565
|
overlaySlots.forEach { it.recycle() }
|
|
566
|
+
pairBackdrop.visibility = GONE
|
|
448
567
|
}
|
|
449
568
|
|
|
450
569
|
fun dispose() {
|
|
@@ -38,6 +38,9 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
38
38
|
private val marketSubtitleLine = PackedTitleLineLayout(context)
|
|
39
39
|
private val trailingColumn = LinearLayout(context)
|
|
40
40
|
private val trailingViews = List(2) { NativeListTextView(context) }
|
|
41
|
+
private val metricColumns = List(3) { LinearLayout(context) }
|
|
42
|
+
private val metricPrimaryViews = List(3) { NativeListTextView(context) }
|
|
43
|
+
private val metricSecondaryViews = List(3) { NativeListTextView(context) }
|
|
41
44
|
private val marketBadgeViews = List(3) { LinearLayout(context) }
|
|
42
45
|
private val marketBadgeLabels = List(3) { TextView(context) }
|
|
43
46
|
private val badgeSlots = List(3) { NativeListImageSlot(context) }
|
|
@@ -88,6 +91,12 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
88
91
|
mainColumn.addView(subtitle)
|
|
89
92
|
mainColumn.addView(tertiary)
|
|
90
93
|
trailingViews.forEach(trailingColumn::addView)
|
|
94
|
+
metricColumns.forEachIndexed { index, column ->
|
|
95
|
+
column.orientation = VERTICAL
|
|
96
|
+
column.gravity = Gravity.CENTER_VERTICAL
|
|
97
|
+
column.addView(metricPrimaryViews[index])
|
|
98
|
+
column.addView(metricSecondaryViews[index])
|
|
99
|
+
}
|
|
91
100
|
leadingActionIcon.useSourceScale = true
|
|
92
101
|
marketBadgeViews.forEachIndexed { index, badge ->
|
|
93
102
|
badge.orientation = HORIZONTAL
|
|
@@ -129,6 +138,50 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
129
138
|
|
|
130
139
|
private fun weighted() = LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f)
|
|
131
140
|
|
|
141
|
+
private fun metricColor(theme: JSONObject?, tone: String): Int =
|
|
142
|
+
when (tone) {
|
|
143
|
+
"positive" -> color(theme, "positive", "#218358")
|
|
144
|
+
"negative" -> color(theme, "negative", "#CE2C31")
|
|
145
|
+
"secondary" -> color(theme, "secondaryText", "#646464")
|
|
146
|
+
else -> color(theme, "primaryText", "#202020")
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private fun bindMetrics(metrics: JSONArray, theme: JSONObject?, gap: Int) {
|
|
150
|
+
updateMetricLabels(metrics, theme)
|
|
151
|
+
for (index in 0 until metrics.length()) {
|
|
152
|
+
val metric = metrics.getJSONObject(index)
|
|
153
|
+
addView(
|
|
154
|
+
metricColumns[index],
|
|
155
|
+
LayoutParams(0, LayoutParams.WRAP_CONTENT, metric.optInt("weight", 1).toFloat()).apply {
|
|
156
|
+
marginStart = dp(gap)
|
|
157
|
+
},
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private fun updateMetricLabels(metrics: JSONArray, theme: JSONObject?) {
|
|
163
|
+
for (index in 0 until metrics.length()) {
|
|
164
|
+
val metric = metrics.getJSONObject(index)
|
|
165
|
+
val alignment = metric.optString("alignment", "end")
|
|
166
|
+
val primary = metricPrimaryViews[index]
|
|
167
|
+
val secondary = metricSecondaryViews[index]
|
|
168
|
+
applyMarketTextStyle(
|
|
169
|
+
primary, null, 14f, 20, "medium",
|
|
170
|
+
metricColor(theme, metric.optString("tone")), alignment,
|
|
171
|
+
)
|
|
172
|
+
primary.text = marketText(metric.optString("text"), metric.optJSONArray("textSegments"), 14f)
|
|
173
|
+
primary.visibility = VISIBLE
|
|
174
|
+
applyMarketTextStyle(
|
|
175
|
+
secondary, null, 12f, 16, "regular",
|
|
176
|
+
metricColor(theme, metric.optString("secondaryTone", "secondary")), alignment,
|
|
177
|
+
)
|
|
178
|
+
secondary.text = marketText(
|
|
179
|
+
metric.optString("secondaryText"), metric.optJSONArray("secondaryTextSegments"), 12f,
|
|
180
|
+
)
|
|
181
|
+
secondary.visibility = if (secondary.text.isEmpty()) GONE else VISIBLE
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
132
185
|
private fun showText(view: TextView, text: String, lines: Int) {
|
|
133
186
|
view.text = text
|
|
134
187
|
view.maxLines = lines
|
|
@@ -146,18 +199,27 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
146
199
|
emitAction(key, view, source, slot, target)
|
|
147
200
|
}
|
|
148
201
|
|
|
149
|
-
override fun accessibilityText(item: NativeListItem)
|
|
150
|
-
item.json.
|
|
151
|
-
"accessibilityLabel"
|
|
202
|
+
override fun accessibilityText(item: NativeListItem): String {
|
|
203
|
+
if (item.json.has("accessibilityLabel") && !item.json.isNull("accessibilityLabel")) {
|
|
204
|
+
return item.json.optString("accessibilityLabel")
|
|
205
|
+
}
|
|
206
|
+
val metrics = item.json.optJSONArray("metrics")?.takeIf { it.length() in 2..3 }
|
|
207
|
+
val values = if (metrics != null) {
|
|
208
|
+
(0 until metrics.length()).flatMap { index ->
|
|
209
|
+
listOf(metricPrimaryViews[index], metricSecondaryViews[index])
|
|
210
|
+
.filter { it.visibility == VISIBLE }
|
|
211
|
+
.map { it.text.toString() }
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
152
214
|
listOf(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
215
|
+
item.json.optString("price"),
|
|
216
|
+
item.json.optJSONObject("change")?.optString("text") ?: "",
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
return (listOf(item.json.optString("title"), item.json.optString("subtitle")) + values)
|
|
220
|
+
.filter(String::isNotEmpty)
|
|
221
|
+
.joinToString(", ")
|
|
222
|
+
}
|
|
161
223
|
|
|
162
224
|
override fun bindContent(
|
|
163
225
|
item: NativeListItem,
|
|
@@ -183,7 +245,8 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
183
245
|
if (item.json.optJSONArray("badges")?.optJSONObject(index)?.optJSONObject("icon") == null)
|
|
184
246
|
badgeSlots[index].recycle()
|
|
185
247
|
}
|
|
186
|
-
for (view in listOf(title, subtitle, tertiary) + trailingViews
|
|
248
|
+
for (view in listOf(title, subtitle, tertiary) + trailingViews +
|
|
249
|
+
metricPrimaryViews + metricSecondaryViews) {
|
|
187
250
|
view.text = ""
|
|
188
251
|
view.visibility = GONE
|
|
189
252
|
view.maxLines = 1
|
|
@@ -217,7 +280,13 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
217
280
|
}
|
|
218
281
|
|
|
219
282
|
override fun bindMarketQuote(item: NativeListItem, theme: JSONObject?) {
|
|
220
|
-
if (retainBoundItem(item))
|
|
283
|
+
if (retainBoundItem(item)) {
|
|
284
|
+
item.json.optJSONArray("metrics")?.takeIf { it.length() in 2..3 }?.let {
|
|
285
|
+
updateMetricLabels(it, theme)
|
|
286
|
+
}
|
|
287
|
+
bindQuote(item, theme)
|
|
288
|
+
contentDescription = accessibilityText(item)
|
|
289
|
+
}
|
|
221
290
|
}
|
|
222
291
|
|
|
223
292
|
private fun cancelMarketHold() {
|
|
@@ -304,6 +373,7 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
304
373
|
longPressFired = false
|
|
305
374
|
leadingFrame.recycle()
|
|
306
375
|
badgeSlots.forEach { it.recycle() }
|
|
376
|
+
(metricPrimaryViews + metricSecondaryViews).forEach { it.text = "" }
|
|
307
377
|
imageSignature = ""
|
|
308
378
|
}
|
|
309
379
|
|
|
@@ -561,10 +631,12 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
561
631
|
)
|
|
562
632
|
// OneKey patch: retain the source gap without changing other templates.
|
|
563
633
|
// addView(mainColumn, weighted())
|
|
634
|
+
val metrics = item.json.optJSONArray("metrics")?.takeIf { it.length() in 2..3 }
|
|
564
635
|
addView(
|
|
565
636
|
mainColumn,
|
|
566
637
|
weighted().apply {
|
|
567
|
-
|
|
638
|
+
if (metrics != null) weight = 2f
|
|
639
|
+
else marginEnd = dp(style?.optDouble("contentTrailingGap", 0.0)?.roundToInt() ?: 0)
|
|
568
640
|
},
|
|
569
641
|
)
|
|
570
642
|
titleLine.packsChildrenAtStart = true
|
|
@@ -748,7 +820,11 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
748
820
|
}
|
|
749
821
|
trailingColumn.orientation = HORIZONTAL
|
|
750
822
|
trailingColumn.gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
|
751
|
-
|
|
823
|
+
if (metrics != null) {
|
|
824
|
+
bindMetrics(metrics, theme, style?.optDouble("trailingGap", 8.0)?.roundToInt() ?: 8)
|
|
825
|
+
} else {
|
|
826
|
+
addView(trailingColumn, wrap())
|
|
827
|
+
}
|
|
752
828
|
bindQuote(item, theme)
|
|
753
829
|
val nextImageSignature =
|
|
754
830
|
nativeListCanonical(
|
|
@@ -861,18 +937,6 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
861
937
|
)
|
|
862
938
|
}
|
|
863
939
|
}
|
|
864
|
-
contentDescription =
|
|
865
|
-
item.json.optString(
|
|
866
|
-
"accessibilityLabel",
|
|
867
|
-
listOf(
|
|
868
|
-
item.json.optString("title"),
|
|
869
|
-
item.json.optString("subtitle"),
|
|
870
|
-
item.json.optString("price"),
|
|
871
|
-
changeData.optString("text"),
|
|
872
|
-
)
|
|
873
|
-
.filter(String::isNotEmpty)
|
|
874
|
-
.joinToString(", "),
|
|
875
|
-
)
|
|
876
940
|
}
|
|
877
941
|
|
|
878
942
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
@@ -912,7 +976,7 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
912
976
|
?.has("contentVerticalAlignment") == true
|
|
913
977
|
if (item.type == "market" && item.json.optJSONObject("style") != null) {
|
|
914
978
|
// OneKey patch: preserve Yoga's half-pixel centering for Market columns and badges.
|
|
915
|
-
for (column in listOf(leadingFrame, mainColumn, trailingColumn)) {
|
|
979
|
+
for (column in listOf(leadingFrame, mainColumn, trailingColumn) + metricColumns) {
|
|
916
980
|
if (!hasContainerAlignment && column.parent === this && column.visibility != GONE) {
|
|
917
981
|
column.offsetTopAndBottom((height - column.height + 1) / 2 - column.top)
|
|
918
982
|
}
|