@onekeyfe/react-native-native-list 6.7.0-20 → 6.7.0-22
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/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +5 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +29 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +6 -10
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +15 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +47 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +33 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +5 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +13 -10
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -338
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +5 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +33 -8
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +11 -5
- package/docs/ROW_TEMPLATES.md +10 -2
- package/docs/SPEC.md +432 -50
- package/ios/NativeListAccessoryStack.swift +6 -16
- package/ios/NativeListActivityDetailsView.swift +13 -4
- package/ios/NativeListDataRowRenderer.swift +15 -6
- package/ios/NativeListDesignAssets.swift +13 -84
- package/ios/NativeListGeneratedIcons.swift +55 -0
- package/ios/NativeListIconBinding.swift +171 -0
- package/ios/NativeListIdentityRenderer.swift +69 -13
- package/ios/NativeListLeadingVisual.swift +11 -9
- package/ios/NativeListMarketRenderer.swift +120 -31
- package/ios/NativeListMediaTileRenderer.swift +6 -2
- package/ios/NativeListMetricCardRenderer.swift +4 -2
- package/ios/NativeListSectionHeaderRenderer.swift +12 -4
- package/ios/RNCNativeListView.swift +21 -3
- package/ios/tests/NativeListAccessoryStackTests.swift +12 -0
- package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +97 -0
- package/ios/tests/NativeListLifecycleTests.swift +73 -4
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/ios/tests/NativeListSharedIconTests.swift +236 -0
- package/lib/module/NativeList.js +25 -6
- package/lib/module/NativeList.web.js +9 -12
- package/lib/module/models.js +2 -0
- package/lib/module/validation.js +695 -114
- package/lib/module/web/NativeListGeneratedIcons.js +31 -0
- package/lib/module/web/NativeListWebEngine.js +24 -332
- package/lib/module/web/templates/ActivityRowRenderer.js +4 -24
- package/lib/module/web/templates/IdentityRowRenderer.js +66 -4
- package/lib/module/web/templates/MarketTableRowRenderer.js +36 -19
- package/lib/module/web/templates/MediaTileRowRenderer.js +2 -12
- package/lib/typescript/src/NativeList.types.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +27 -14
- package/lib/typescript/src/validation.d.ts +7 -2
- package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +0 -1
- package/package.json +16 -10
- package/react-native-native-list.podspec +0 -5
- 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.tsx +30 -10
- package/src/NativeList.types.ts +2 -2
- package/src/NativeList.web.tsx +10 -14
- package/src/models.ts +158 -153
- package/src/validation.ts +1757 -167
- package/src/web/NativeListGeneratedIcons.ts +28 -0
- package/src/web/NativeListWebEngine.ts +31 -415
- package/src/web/templates/ActivityRowRenderer.ts +15 -53
- package/src/web/templates/IdentityRowRenderer.ts +78 -4
- package/src/web/templates/MarketTableRowRenderer.ts +53 -33
- package/src/web/templates/MediaTileRowRenderer.ts +2 -15
- 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_crypto_coin_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +0 -4
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.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_dot_ver_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.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_gas_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +0 -3
- 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_large.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.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_refresh_ccw_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +0 -3
- 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
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/icon.svg +0 -1
|
@@ -122,6 +122,9 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
122
122
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
|
|
123
123
|
horizontal: Boolean = false,
|
|
124
124
|
) {
|
|
125
|
+
val iconUpdate = NativeListIconUpdate(this)
|
|
126
|
+
try {
|
|
127
|
+
|
|
125
128
|
selectorUsesSourceScale = sourceScale
|
|
126
129
|
reset()
|
|
127
130
|
tag = item
|
|
@@ -179,6 +182,8 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
179
182
|
}
|
|
180
183
|
visibility =
|
|
181
184
|
if ((0 until childCount).any { getChildAt(it).visibility != GONE }) VISIBLE else GONE
|
|
185
|
+
|
|
186
|
+
} finally { iconUpdate.finish() }
|
|
182
187
|
}
|
|
183
188
|
|
|
184
189
|
fun updateSelection(
|
|
@@ -16,7 +16,11 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
16
16
|
var onAction: ((String, View, String, Int) -> Unit)? = null
|
|
17
17
|
private var sourceScale = false
|
|
18
18
|
private val main = LinearLayout(context).apply { orientation = HORIZONTAL; gravity = Gravity.CENTER_VERTICAL }
|
|
19
|
+
private val identityColumn = LinearLayout(context).apply { orientation = HORIZONTAL; gravity = Gravity.CENTER_VERTICAL }
|
|
19
20
|
private val visual = NativeListLeadingVisual(reactContext, fonts)
|
|
21
|
+
/** Whether the bound leading visual lays a badge past its frame; see [setClipping]. */
|
|
22
|
+
var leadingOverhangs = false
|
|
23
|
+
private set
|
|
20
24
|
private val identity = LinearLayout(context).apply { orientation = VERTICAL }
|
|
21
25
|
private val titleLine = LinearLayout(context).apply { orientation = HORIZONTAL; gravity = Gravity.CENTER_VERTICAL }
|
|
22
26
|
private val title = NativeListTextView(context)
|
|
@@ -40,13 +44,26 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
40
44
|
identity.addView(status)
|
|
41
45
|
feeLine.addView(feePrimary); feeLine.addView(feeSecondary)
|
|
42
46
|
fee.addView(feeLabel); fee.addView(feeLine)
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
identityColumn.addView(visual)
|
|
48
|
+
identityColumn.addView(identity, LayoutParams(0, -2, 1f))
|
|
49
|
+
main.addView(identityColumn, LayoutParams(0, -2, 1f))
|
|
45
50
|
main.addView(amounts)
|
|
46
51
|
main.addView(fee)
|
|
47
52
|
addView(main, LayoutParams(-1, -2))
|
|
48
53
|
addView(actions, LayoutParams(-1, -2))
|
|
49
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Android clips a child to its own bounds while its parent clips children, so
|
|
57
|
+
* every view between the leading visual and the row host stops clipping when
|
|
58
|
+
* the visual's network badge overhangs its box (SPEC "Leading badge overhang",
|
|
59
|
+
* OK-66275); the host row applies the same policy to itself.
|
|
60
|
+
*/
|
|
61
|
+
private fun setClipping(clips: Boolean) {
|
|
62
|
+
for (group in listOf(identityColumn, main, this)) {
|
|
63
|
+
group.clipChildren = clips
|
|
64
|
+
group.clipToPadding = clips
|
|
65
|
+
}
|
|
66
|
+
}
|
|
50
67
|
private fun dp(value: Int) = if (sourceScale) (value * resources.displayMetrics.density).roundToInt() else NativeListScale.dp(resources, value)
|
|
51
68
|
private fun px(value: Double) = (value * resources.displayMetrics.density).roundToInt()
|
|
52
69
|
private fun color(tone: String, theme: JSONObject?): Int {
|
|
@@ -77,6 +94,8 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
77
94
|
visual.visibility = if (hideLeading) GONE else VISIBLE
|
|
78
95
|
if (hideLeading) visual.recycle()
|
|
79
96
|
else visual.bind(data.optJSONObject("leading") ?: JSONObject(), image, item.key, theme, false, sourceScale, data.optJSONObject("secondaryLeading"))
|
|
97
|
+
leadingOverhangs = !hideLeading && visual.requestsUnclippedHost
|
|
98
|
+
setClipping(nativeListActivityHostClips(leadingOverhangs))
|
|
80
99
|
amounts.layoutParams = if (table) LayoutParams(0, -2, 1f).apply { marginStart = gap } else LayoutParams(-2, -2).apply { marginStart = gap }
|
|
81
100
|
text(title, data.optString("title"), style.optJSONObject("title"), 16f, color("primary", theme), 24, "medium")
|
|
82
101
|
text(description, data.optString("description"), style.optJSONObject("description"), 14f, color("secondary", theme), 20, lines = 2)
|
|
@@ -110,7 +129,9 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
110
129
|
val feeData = data.optJSONObject("fee")
|
|
111
130
|
fee.visibility = if (feeData == null) GONE else VISIBLE
|
|
112
131
|
fee.alpha = if (feeData?.optBoolean("hidden") == true) 0f else 1f
|
|
113
|
-
fee.layoutParams = LayoutParams(-2, -2).apply { marginStart = gap }
|
|
132
|
+
fee.layoutParams = (if (table) LayoutParams(0, -2, 0.6f) else LayoutParams(-2, -2)).apply { marginStart = gap }
|
|
133
|
+
feeLabel.layoutParams.width = if (table) LayoutParams.WRAP_CONTENT else LayoutParams.MATCH_PARENT
|
|
134
|
+
feeLine.layoutParams.width = if (table) LayoutParams.WRAP_CONTENT else LayoutParams.MATCH_PARENT
|
|
114
135
|
text(feeLabel, feeData?.optString("label") ?: "", style.optJSONObject("secondaryAmount"), 12f, color("secondary", theme), 16)
|
|
115
136
|
text(feePrimary, feeData?.optString("primary") ?: "", style.optJSONObject("secondaryAmount"), 14f, color("primary", theme), 20)
|
|
116
137
|
text(feeSecondary, feeData?.optString("secondary") ?: "", style.optJSONObject("secondaryAmount"), 12f, color("secondary", theme), 16)
|
|
@@ -149,7 +170,11 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
149
170
|
}
|
|
150
171
|
label.text = styled
|
|
151
172
|
}
|
|
152
|
-
fun recycle() {
|
|
173
|
+
fun recycle() {
|
|
174
|
+
visual.recycle(); visual.visibility = VISIBLE; amountViews.forEach { it.recycle() }; description.setOnClickListener(null); actions.removeAllViews()
|
|
175
|
+
leadingOverhangs = false
|
|
176
|
+
setClipping(true)
|
|
177
|
+
}
|
|
153
178
|
fun dispose() { recycle(); visual.dispose(); amountViews.forEach { it.dispose() } }
|
|
154
179
|
|
|
155
180
|
private inner class AmountView : LinearLayout(context) {
|
|
@@ -83,10 +83,11 @@ internal class NativeListActivityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
83
83
|
setPadding(hp, vp, hp, vp)
|
|
84
84
|
visual.recycle()
|
|
85
85
|
details.bind(item, theme, sourceScale)
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
|
|
86
|
+
// The rich row's leading visual lives on the details view, where its
|
|
87
|
+
// network badge overhangs the box (OK-66275): this host must stop clipping
|
|
88
|
+
// as well, and a view reused from a badge row clips again when the bound
|
|
89
|
+
// row has no badge.
|
|
90
|
+
setHostClipping(nativeListActivityHostClips(details.leadingOverhangs))
|
|
90
91
|
return
|
|
91
92
|
}
|
|
92
93
|
details.recycle()
|
|
@@ -174,12 +175,7 @@ internal class NativeListActivityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
174
175
|
// Stop clipping the content row and this row's padding exactly when the
|
|
175
176
|
// bound visual reports such a badge (SPEC "Leading badge overhang"), as the
|
|
176
177
|
// Identity renderer does.
|
|
177
|
-
setHostClipping(
|
|
178
|
-
nativeListActivityHostClips(
|
|
179
|
-
rich = false,
|
|
180
|
-
leadingOverhangs = !hideLeading && visual.requestsUnclippedHost,
|
|
181
|
-
)
|
|
182
|
-
)
|
|
178
|
+
setHostClipping(nativeListActivityHostClips(!hideLeading && visual.requestsUnclippedHost))
|
|
183
179
|
bind(
|
|
184
180
|
title,
|
|
185
181
|
data.optString("title"),
|
|
@@ -240,9 +240,10 @@ internal class NativeListAdapter(
|
|
|
240
240
|
|
|
241
241
|
private fun isMarketQuoteUpdate(oldItem: NativeListItem, newItem: NativeListItem): Boolean {
|
|
242
242
|
if (oldItem.type != "market" || newItem.type != "market") return false
|
|
243
|
+
if (!hasSameMarketMetricStructure(oldItem, newItem)) return false
|
|
243
244
|
fun stableContent(item: NativeListItem): String {
|
|
244
245
|
val value = JSONObject(item.json.toString())
|
|
245
|
-
listOf("revision", "price", "priceSegments", "change", "accessibilityLabel")
|
|
246
|
+
listOf("revision", "price", "priceSegments", "change", "accessibilityLabel", "metrics")
|
|
246
247
|
.forEach(value::remove)
|
|
247
248
|
return value.toString()
|
|
248
249
|
}
|
|
@@ -256,3 +257,18 @@ internal const val SELECTION_PAYLOAD = "selection"
|
|
|
256
257
|
// OneKey patch: internal payload, never exposed through the serialized row contract.
|
|
257
258
|
internal const val SELECTION_ECHO_PAYLOAD = "selectionEcho"
|
|
258
259
|
internal const val MARKET_QUOTE_PAYLOAD = "marketQuote"
|
|
260
|
+
|
|
261
|
+
internal fun hasSameMarketMetricStructure(before: NativeListItem, after: NativeListItem): Boolean {
|
|
262
|
+
val old = before.json.optJSONArray("metrics")
|
|
263
|
+
val next = after.json.optJSONArray("metrics")
|
|
264
|
+
val oldCount = old?.length() ?: 0
|
|
265
|
+
if (oldCount != (next?.length() ?: 0)) return false
|
|
266
|
+
for (index in 0 until oldCount) {
|
|
267
|
+
val previous = old?.optJSONObject(index) ?: return false
|
|
268
|
+
val current = next?.optJSONObject(index) ?: return false
|
|
269
|
+
if (previous.optString("key") != current.optString("key") ||
|
|
270
|
+
previous.optInt("weight", 1) != current.optInt("weight", 1) ||
|
|
271
|
+
previous.optString("alignment", "end") != current.optString("alignment", "end")) return false
|
|
272
|
+
}
|
|
273
|
+
return true
|
|
274
|
+
}
|
|
@@ -292,12 +292,14 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
292
292
|
|
|
293
293
|
fun reset() {
|
|
294
294
|
primaryLine.gravity = Gravity.CENTER_VERTICAL
|
|
295
|
+
secondaryLine.gravity = Gravity.CENTER_VERTICAL
|
|
295
296
|
for (icon in listOf(titleIcon, secondaryTitleIcon)) {
|
|
296
297
|
icon.visibility = GONE
|
|
297
298
|
icon.iconName = ""
|
|
298
299
|
icon.contentDescription = null
|
|
299
300
|
icon.setOnClickListener(null)
|
|
300
301
|
}
|
|
302
|
+
(primaryLine.layoutParams as LayoutParams).gravity = -1
|
|
301
303
|
primaryLine.layoutParams.width = LayoutParams.WRAP_CONTENT
|
|
302
304
|
primaryLine.layoutParams.height = LayoutParams.WRAP_CONTENT
|
|
303
305
|
secondaryLine.layoutParams.height = LayoutParams.WRAP_CONTENT
|
|
@@ -357,6 +359,17 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
357
359
|
"end" -> Gravity.END
|
|
358
360
|
else -> Gravity.START
|
|
359
361
|
}
|
|
362
|
+
fun horizontalGravity(alignment: String) = when (alignment) {
|
|
363
|
+
"center" -> Gravity.CENTER_HORIZONTAL
|
|
364
|
+
"end" -> Gravity.END
|
|
365
|
+
else -> Gravity.START
|
|
366
|
+
}
|
|
367
|
+
val primaryAlignment = style.optJSONObject("columns")?.optString("alignment")
|
|
368
|
+
?.takeIf(String::isNotEmpty) ?: column.optString("alignment", "start")
|
|
369
|
+
(primaryLine.layoutParams as LayoutParams).gravity = horizontalGravity(primaryAlignment)
|
|
370
|
+
val secondaryAlignment = style.optJSONObject("columnSecondary")?.optString("alignment")
|
|
371
|
+
?.takeIf(String::isNotEmpty) ?: column.optString("alignment", "start")
|
|
372
|
+
secondaryLine.gravity = Gravity.CENTER_VERTICAL or horizontalGravity(secondaryAlignment)
|
|
360
373
|
fun bindText(
|
|
361
374
|
view: NativeListTextView,
|
|
362
375
|
value: String,
|
|
@@ -433,6 +446,8 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
433
446
|
secondaryLine.visibility = VISIBLE
|
|
434
447
|
}
|
|
435
448
|
if (!fixedTableGeometry) applyStyle(style)
|
|
449
|
+
(secondary.layoutParams as LayoutParams).marginStart =
|
|
450
|
+
if (secondaryLeading.visibility == VISIBLE) dp(4) else 0
|
|
436
451
|
if (fixedTableGeometry) {
|
|
437
452
|
// Legacy table lines: fixed 20dp primary and 16dp secondary/badge boxes.
|
|
438
453
|
primaryLine.layoutParams.height = dp(20)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Generated by scripts/generate-icons.mjs. Coverage and legacy names only; hosts provide SVG resources.
|
|
2
|
+
package com.margelo.nitro.nativelist
|
|
3
|
+
|
|
4
|
+
internal data class NativeListIconMetadata(val name: String, val width: Float, val height: Float)
|
|
5
|
+
internal val nativeListGeneratedIcons: Map<String, NativeListIconMetadata> = mapOf(
|
|
6
|
+
"AccountErrorCustom" to NativeListIconMetadata("AccountErrorCustom", 18f, 18f),
|
|
7
|
+
"AllNetworksSolid" to NativeListIconMetadata("AllNetworksSolid", 24f, 24f),
|
|
8
|
+
"AppleBrand" to NativeListIconMetadata("AppleBrand", 16f, 20f),
|
|
9
|
+
"ArrowBottomOutline" to NativeListIconMetadata("ArrowBottomOutline", 24f, 24f),
|
|
10
|
+
"ArrowTopOutline" to NativeListIconMetadata("ArrowTopOutline", 24f, 24f),
|
|
11
|
+
"BadgeVerifiedSolid" to NativeListIconMetadata("BadgeRecognizedSolid", 24f, 24f),
|
|
12
|
+
"BotIllus" to NativeListIconMetadata("BotIllus", 24f, 24f),
|
|
13
|
+
"ChartTrendingUpOutline" to NativeListIconMetadata("ChartTrendingUpOutline", 24f, 24f),
|
|
14
|
+
"ChevronBottomOutline" to NativeListIconMetadata("ChevronBottomOutline", 24f, 24f),
|
|
15
|
+
"ChevronGrabberVerOutline" to NativeListIconMetadata("ChevronGrabberVerOutline", 24f, 24f),
|
|
16
|
+
"ChevronRightSmallOutline" to NativeListIconMetadata("ChevronRightSmallOutline", 24f, 24f),
|
|
17
|
+
"ChevronTopOutline" to NativeListIconMetadata("ChevronTopOutline", 24f, 24f),
|
|
18
|
+
"Circle" to NativeListIconMetadata("Circle", 24f, 24f),
|
|
19
|
+
"CrossedSmallSolid" to NativeListIconMetadata("CrossedSmallSolid", 24f, 24f),
|
|
20
|
+
"CryptoCoinOutline" to NativeListIconMetadata("CryptoCoinOutline", 24f, 24f),
|
|
21
|
+
"Document2Outline" to NativeListIconMetadata("Document2Outline", 24f, 24f),
|
|
22
|
+
"DotHorOutline" to NativeListIconMetadata("DotHorOutline", 24f, 24f),
|
|
23
|
+
"DotVerSolid" to NativeListIconMetadata("DotVerSolid", 24f, 24f),
|
|
24
|
+
"DragOutline" to NativeListIconMetadata("DragOutline", 24f, 24f),
|
|
25
|
+
"ErrorSolid" to NativeListIconMetadata("ErrorSolid", 24f, 24f),
|
|
26
|
+
"GasSolid" to NativeListIconMetadata("GasSolid", 24f, 24f),
|
|
27
|
+
"GlobusOutline" to NativeListIconMetadata("GlobusOutline", 24f, 24f),
|
|
28
|
+
"GoogleIllus" to NativeListIconMetadata("GoogleIllus", 24f, 24f),
|
|
29
|
+
"ImageSquareWavesOutline" to NativeListIconMetadata("ImageSquareWavesOutline", 24f, 24f),
|
|
30
|
+
"InfoCircleOutline" to NativeListIconMetadata("InfoCircleOutline", 24f, 24f),
|
|
31
|
+
"LockSolid" to NativeListIconMetadata("LockSolid", 24f, 24f),
|
|
32
|
+
"MinusCircleOutline" to NativeListIconMetadata("MinusCircleOutline", 24f, 24f),
|
|
33
|
+
"MinusCircleSolid" to NativeListIconMetadata("MinusCircleSolid", 24f, 24f),
|
|
34
|
+
"PencilOutline" to NativeListIconMetadata("PencilOutline", 24f, 24f),
|
|
35
|
+
"PlusCircleOutline" to NativeListIconMetadata("PlusCircleOutline", 24f, 24f),
|
|
36
|
+
"PlusLargeOutline" to NativeListIconMetadata("PlusLargeOutline", 24f, 24f),
|
|
37
|
+
"PlusSmallOutline" to NativeListIconMetadata("PlusSmallOutline", 24f, 24f),
|
|
38
|
+
"QuestionmarkSolid" to NativeListIconMetadata("QuestionmarkSolid", 24f, 24f),
|
|
39
|
+
"RefreshCcwOutline" to NativeListIconMetadata("RefreshCcwOutline", 24f, 24f),
|
|
40
|
+
"ShieldExclamationOutline" to NativeListIconMetadata("ShieldExclamationOutline", 24f, 24f),
|
|
41
|
+
"SpeakerPromoteOutline" to NativeListIconMetadata("SpeakerPromoteOutline", 24f, 24f),
|
|
42
|
+
"StarOutline" to NativeListIconMetadata("StarOutline", 24f, 24f),
|
|
43
|
+
"StarSolid" to NativeListIconMetadata("StarSolid", 24f, 24f),
|
|
44
|
+
"SwapHorOutline" to NativeListIconMetadata("SwapHorOutline", 24f, 24f),
|
|
45
|
+
"TicketOutline" to NativeListIconMetadata("TicketOutline", 24f, 24f),
|
|
46
|
+
"WalletOutline" to NativeListIconMetadata("WalletOutline", 24f, 24f),
|
|
47
|
+
)
|
|
@@ -31,6 +31,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
31
31
|
private val titleLine = PackedTitleLineLayout(context)
|
|
32
32
|
private val title = NativeListTextView(context)
|
|
33
33
|
private val titleIcon = OneKeyIconView(context)
|
|
34
|
+
private var titleImage: NativeListImageSlot? = null
|
|
34
35
|
private val subtitle = NativeListTextView(context)
|
|
35
36
|
private val tertiary = NativeListTextView(context)
|
|
36
37
|
private val badgeLine = NativeListTextView(context)
|
|
@@ -79,7 +80,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
79
80
|
"single"
|
|
80
81
|
else item.json.optString("groupPosition")
|
|
81
82
|
|
|
82
|
-
override val assetFields = listOf("leading")
|
|
83
|
+
override val assetFields = listOf("leading", "titleImage")
|
|
83
84
|
|
|
84
85
|
override fun usesSourceScale(item: NativeListItem, provided: Boolean) =
|
|
85
86
|
item.usesSelectorSourceScale || provided
|
|
@@ -262,6 +263,29 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
262
263
|
leadingActionIcon.useSourceScale = sourceScale
|
|
263
264
|
leadingActionIcon.setOnClickListener(null)
|
|
264
265
|
bindIdentity(item, theme, item.json.optBoolean("selected"), checkboxState)
|
|
266
|
+
val titleImageDescriptor = item.json.optJSONObject("titleImage")
|
|
267
|
+
val titleImageSource = titleImageDescriptor?.optJSONObject("image")
|
|
268
|
+
if (titleImageSource != null && titleImageSource.optString("uri").isNotEmpty()) {
|
|
269
|
+
if (item.json.optString("presentation") == "walletSidebar") {
|
|
270
|
+
titleLine.packsChildrenAtStart = true
|
|
271
|
+
title.layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
|
|
272
|
+
}
|
|
273
|
+
val slot = titleImage ?: NativeListImageSlot(reactContext).also { titleImage = it }
|
|
274
|
+
// Reinsert after icons so newly added suffixes cannot precede the image.
|
|
275
|
+
titleLine.removeView(slot.view)
|
|
276
|
+
titleLine.addView(slot.view, titleLine.indexOfChild(titleIcon) + 1)
|
|
277
|
+
val size = stylePx(titleImageSource.optDouble("width"))
|
|
278
|
+
slot.view.layoutParams = LayoutParams(size, size).apply { marginStart = dp(4) }
|
|
279
|
+
slot.view.visibility = VISIBLE
|
|
280
|
+
slot.view.contentDescription = titleImageDescriptor.optString("accessibilityLabel").takeIf(String::isNotEmpty)
|
|
281
|
+
slot.view.importantForAccessibility = if (slot.view.contentDescription == null)
|
|
282
|
+
View.IMPORTANT_FOR_ACCESSIBILITY_NO else View.IMPORTANT_FOR_ACCESSIBILITY_YES
|
|
283
|
+
slot.bind(titleImageSource, "${item.key}:titleImage", placeholder = "#00000000", round = true)
|
|
284
|
+
} else {
|
|
285
|
+
titleImage?.recycle()
|
|
286
|
+
titleImage?.view?.visibility = GONE
|
|
287
|
+
titleImage?.view?.contentDescription = null
|
|
288
|
+
}
|
|
265
289
|
TextViewCompat.setLineHeight(
|
|
266
290
|
title,
|
|
267
291
|
dp(if (item.json.optString("presentation") == "walletSidebar") 16 else 24),
|
|
@@ -449,7 +473,10 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
449
473
|
val inner = (MeasureSpec.getSize(widthMeasureSpec) - paddingLeft - paddingRight)
|
|
450
474
|
.coerceAtLeast(0)
|
|
451
475
|
val leading = leadingFrame.layoutParams as LayoutParams
|
|
452
|
-
val
|
|
476
|
+
val imageWidth = titleImage?.view?.takeIf { it.visibility == VISIBLE }?.let {
|
|
477
|
+
it.layoutParams.width + dp(4)
|
|
478
|
+
} ?: 0
|
|
479
|
+
val icon = (if (titleIcon.visibility == VISIBLE) dp(24) else 0) + imageWidth
|
|
453
480
|
(inner * ratio).roundToInt()
|
|
454
481
|
.minus(leading.width + leading.marginEnd + icon)
|
|
455
482
|
.coerceAtLeast(0)
|
|
@@ -555,6 +582,9 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
555
582
|
longPressPoint = null
|
|
556
583
|
longPressPointEpoch = -1L
|
|
557
584
|
leadingFrame.recycle()
|
|
585
|
+
titleImage?.recycle()
|
|
586
|
+
titleImage?.view?.visibility = GONE
|
|
587
|
+
titleImage?.view?.contentDescription = null
|
|
558
588
|
trailingColumn.reset()
|
|
559
589
|
currentItem = null
|
|
560
590
|
}
|
|
@@ -562,6 +592,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
562
592
|
override fun disposeContent() {
|
|
563
593
|
recycleContent()
|
|
564
594
|
leadingFrame.dispose()
|
|
595
|
+
titleImage?.dispose()
|
|
565
596
|
}
|
|
566
597
|
|
|
567
598
|
private fun bindIdentity(
|
|
@@ -112,6 +112,9 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
112
112
|
sourceScale: Boolean,
|
|
113
113
|
secondaryVisual: JSONObject? = null,
|
|
114
114
|
) {
|
|
115
|
+
val iconUpdate = NativeListIconUpdate(this)
|
|
116
|
+
try {
|
|
117
|
+
|
|
115
118
|
fallback.typeface = fonts.bold(context)
|
|
116
119
|
this.visual = visual
|
|
117
120
|
this.style = style
|
|
@@ -394,6 +397,8 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
394
397
|
overlaySlots.drop(descriptors.size).forEach { it.recycle() }
|
|
395
398
|
unread.bringToFront()
|
|
396
399
|
requestLayout()
|
|
400
|
+
|
|
401
|
+
} finally { iconUpdate.finish() }
|
|
397
402
|
}
|
|
398
403
|
|
|
399
404
|
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
|
@@ -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
|
}
|
|
@@ -50,16 +50,17 @@ internal fun nativeListLeadingVisualOverhangsFrame(
|
|
|
50
50
|
): Boolean = kind == "token" && sourceCount > 1 || hasCornerIcon || overlayCount > 0
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* Whether an Activity row host
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
53
|
+
* Whether an Activity row host (and, for a rich `amounts` row, the details view
|
|
54
|
+
* with its nested columns) clips its children and padding for this bind. One
|
|
55
|
+
* row view serves both the legacy row and the rich row and is reused across
|
|
56
|
+
* binds, so clipping is derived from the bound item alone and applied on every
|
|
57
|
+
* bind: a row whose bound leading visual lays a badge past its frame
|
|
58
|
+
* ([nativeListLeadingVisualOverhangsFrame]) opts out, whether that visual sits
|
|
59
|
+
* on the host (legacy row, OK-66071) or on the details view (rich row,
|
|
60
|
+
* OK-66275); a row without such a badge clips again even when the view it
|
|
61
|
+
* reuses last showed one.
|
|
60
62
|
*/
|
|
61
|
-
internal fun nativeListActivityHostClips(
|
|
62
|
-
rich || !leadingOverhangs
|
|
63
|
+
internal fun nativeListActivityHostClips(leadingOverhangs: Boolean): Boolean = !leadingOverhangs
|
|
63
64
|
|
|
64
65
|
internal data class NativeListSlotFrame(val x: Int, val y: Int, val width: Int, val height: Int)
|
|
65
66
|
|
|
@@ -378,7 +379,9 @@ internal fun mergeRow(original: JSONObject, changes: JSONObject): JSONObject {
|
|
|
378
379
|
val keys = changes.keys()
|
|
379
380
|
while (keys.hasNext()) {
|
|
380
381
|
val key = keys.next()
|
|
381
|
-
if (key != "key" && key != "type")
|
|
382
|
+
if (key != "key" && key != "type") {
|
|
383
|
+
if (changes.isNull(key)) result.remove(key) else result.put(key, changes.get(key))
|
|
384
|
+
}
|
|
382
385
|
}
|
|
383
386
|
return result
|
|
384
387
|
}
|