@onekeyfe/react-native-native-list 6.7.0-alpha.359 → 6.7.0-alpha.362
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/HybridNativeList.kt +0 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +7 -240
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +4 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +3 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +0 -12
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +7 -87
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +1 -135
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +14 -43
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +0 -25
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +2 -17
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +0 -22
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +0 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +0 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +2 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +0 -69
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +1 -55
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +21 -585
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +0 -1
- package/docs/ROW_TEMPLATES.md +9 -60
- package/docs/SPEC.md +5 -317
- package/docs/STYLE_SPEC.md +0 -6
- package/ios/HybridNativeList.swift +0 -10
- package/ios/NativeListAccessoryStack.swift +37 -220
- package/ios/NativeListActivityDetailsView.swift +8 -18
- package/ios/NativeListActivityRenderer.swift +2 -8
- package/ios/NativeListDataRowRenderer.swift +16 -128
- package/ios/NativeListDesignAssets.swift +0 -3
- package/ios/NativeListIdentityRenderer.swift +5 -123
- package/ios/NativeListLeadingVisual.swift +14 -49
- package/ios/NativeListMessageRenderer.swift +1 -34
- package/ios/NativeListModels.swift +2 -16
- package/ios/NativeListRendererRegistry.swift +0 -1
- package/ios/NativeListResolvedText.swift +1 -2
- package/ios/NativeListRowHost.swift +0 -14
- package/ios/NativeListSectionHeaderRenderer.swift +0 -88
- package/ios/RNCNativeListView.swift +29 -335
- package/ios/tests/NativeListActivityPresentationTests.swift +0 -56
- package/ios/tests/NativeListLifecycleTests.swift +3 -1283
- package/lib/module/NativeList.js +21 -39
- package/lib/module/NativeList.web.js +4 -51
- package/lib/module/models.js +0 -1
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +8 -320
- package/lib/module/web/NativeListWebEngine.js +18 -373
- package/lib/module/web/templates/ActivityRowRenderer.js +7 -8
- package/lib/module/web/templates/DataRowRenderer.js +5 -40
- package/lib/module/web/templates/IdentityRowRenderer.js +4 -90
- package/lib/module/web/templates/MessageRowRenderer.js +2 -18
- package/lib/module/web/templates/RowContainerStyle.js +0 -1
- package/lib/module/web/templates/RowRendererRegistry.js +0 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +2 -36
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +0 -9
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +0 -2
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +0 -5
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +0 -6
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +0 -7
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +0 -6
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +0 -1
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +0 -11
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +0 -2
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +0 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +0 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +0 -3
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +0 -1
- package/lib/typescript/src/NativeList.nitro.d.ts +0 -1
- package/lib/typescript/src/NativeList.types.d.ts +0 -8
- package/lib/typescript/src/models.d.ts +9 -101
- package/lib/typescript/src/validation.d.ts +0 -10
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +0 -26
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +3 -9
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +0 -9
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +0 -2
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +0 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +0 -6
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +0 -7
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +0 -6
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +0 -1
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +0 -11
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +0 -2
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +0 -2
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +0 -2
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +0 -3
- package/nitrogen/generated/shared/json/NativeListConfig.json +0 -1
- package/package.json +3 -3
- package/react-native-native-list.podspec +0 -1
- package/src/NativeList.nitro.ts +0 -1
- package/src/NativeList.tsx +24 -72
- package/src/NativeList.types.ts +0 -9
- package/src/NativeList.web.tsx +8 -72
- package/src/models.ts +3 -113
- package/src/selection.ts +0 -1
- package/src/validation.ts +6 -721
- package/src/web/NativeListWebEngine.ts +19 -568
- package/src/web/templates/ActivityRowRenderer.ts +6 -14
- package/src/web/templates/DataRowRenderer.ts +20 -93
- package/src/web/templates/IdentityRowRenderer.ts +5 -150
- package/src/web/templates/MessageRowRenderer.ts +7 -23
- package/src/web/templates/RowContainerStyle.ts +0 -2
- package/src/web/templates/RowRendererRegistry.ts +1 -11
- package/src/web/templates/SectionHeaderRowRenderer.ts +4 -47
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +0 -102
- package/ios/NativeListButtonGroupRenderer.swift +0 -89
- 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_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_refresh_ccw_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +0 -3
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +0 -47
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +0 -14
- package/src/web/templates/ButtonGroupRowRenderer.ts +0 -58
|
@@ -22,7 +22,6 @@ internal class NativeListDataRowView(context: ThemedReactContext, fonts: NativeL
|
|
|
22
22
|
gravity = Gravity.CENTER_VERTICAL
|
|
23
23
|
}
|
|
24
24
|
private val cells = List(4) { NativeListTableColumnView(context, fonts) }
|
|
25
|
-
private val trailingAccessories = NativeListAccessoryStack(context, fonts)
|
|
26
25
|
|
|
27
26
|
override fun unselectedBackground(
|
|
28
27
|
item: NativeListItem,
|
|
@@ -55,20 +54,16 @@ internal class NativeListDataRowView(context: ThemedReactContext, fonts: NativeL
|
|
|
55
54
|
addView(visual)
|
|
56
55
|
addView(accessories)
|
|
57
56
|
addView(columns, LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f))
|
|
58
|
-
addView(trailingAccessories)
|
|
59
57
|
accessories.onAction = { key, view, slot, target ->
|
|
60
58
|
emitAction(key, view, "trailingAccessory", slot, target)
|
|
61
59
|
}
|
|
62
|
-
trailingAccessories.onAction = { key, view, slot, target ->
|
|
63
|
-
emitAction(key, view, "trailingAccessory", slot, target)
|
|
64
|
-
}
|
|
65
60
|
}
|
|
66
61
|
|
|
67
62
|
override fun defaultHeight(item: NativeListItem, layout: String): Int {
|
|
68
63
|
val values = item.json.optJSONArray("columns") ?: JSONArray()
|
|
69
64
|
val secondary =
|
|
70
65
|
(0 until values.length()).any {
|
|
71
|
-
|
|
66
|
+
values.getJSONObject(it).optString("secondaryText").isNotEmpty()
|
|
72
67
|
}
|
|
73
68
|
return if (layout == "table") if (secondary) 60 else 52 else if (secondary) 64 else 56
|
|
74
69
|
}
|
|
@@ -132,9 +127,6 @@ internal class NativeListDataRowView(context: ThemedReactContext, fonts: NativeL
|
|
|
132
127
|
val accessoryStyle = JSONObject().put("value", style.optJSONObject("index"))
|
|
133
128
|
accessories.bind(item, descriptors, theme, accessoryStyle, sourceScale, checkboxState)
|
|
134
129
|
accessories.visibility = if (descriptors.length() == 0) GONE else VISIBLE
|
|
135
|
-
val trailing = data.optJSONArray("trailing") ?: JSONArray()
|
|
136
|
-
trailingAccessories.bind(item, trailing, theme, style, sourceScale, checkboxState)
|
|
137
|
-
trailingAccessories.visibility = if (trailing.length() == 0) GONE else VISIBLE
|
|
138
130
|
accessories.layoutParams =
|
|
139
131
|
LayoutParams(dp(32), LayoutParams.WRAP_CONTENT).apply { marginEnd = dp(10) }
|
|
140
132
|
val values = data.getJSONArray("columns")
|
|
@@ -167,7 +159,6 @@ internal class NativeListDataRowView(context: ThemedReactContext, fonts: NativeL
|
|
|
167
159
|
style,
|
|
168
160
|
fixedTableGeometry = unstyled,
|
|
169
161
|
)
|
|
170
|
-
cell.bindTitleIcons(value, theme, sourceScale)
|
|
171
162
|
// Legacy table default: every column is a fixed 40dp, top-aligned block.
|
|
172
163
|
cell.layoutParams =
|
|
173
164
|
LayoutParams(
|
|
@@ -203,20 +194,17 @@ internal class NativeListDataRowView(context: ThemedReactContext, fonts: NativeL
|
|
|
203
194
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
|
|
204
195
|
) {
|
|
205
196
|
accessories.updateSelection(item, checkboxState)
|
|
206
|
-
trailingAccessories.updateSelection(item, checkboxState)
|
|
207
197
|
}
|
|
208
198
|
|
|
209
199
|
override fun recycleContent() {
|
|
210
200
|
visual.recycle()
|
|
211
201
|
accessories.reset()
|
|
212
|
-
trailingAccessories.reset()
|
|
213
202
|
cells.forEach { it.reset() }
|
|
214
203
|
}
|
|
215
204
|
|
|
216
205
|
override fun disposeContent() {
|
|
217
206
|
visual.dispose()
|
|
218
207
|
accessories.reset()
|
|
219
|
-
trailingAccessories.reset()
|
|
220
208
|
}
|
|
221
209
|
|
|
222
210
|
private companion object {
|
|
@@ -227,8 +215,6 @@ internal class NativeListDataRowView(context: ThemedReactContext, fonts: NativeL
|
|
|
227
215
|
private class NativeListTableColumnView(context: android.content.Context, private val fonts: NativeListFonts) : LinearLayout(context) {
|
|
228
216
|
private val primaryLine = LinearLayout(context)
|
|
229
217
|
private val primary = NativeListTextView(context)
|
|
230
|
-
private val titleIcon = OneKeyIconView(context)
|
|
231
|
-
private val secondaryTitleIcon = OneKeyIconView(context)
|
|
232
218
|
private val badges = LinearLayout(context)
|
|
233
219
|
private val secondaryLine = LinearLayout(context)
|
|
234
220
|
private val secondaryLeading = NativeListTextView(context)
|
|
@@ -270,13 +256,6 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
270
256
|
},
|
|
271
257
|
)
|
|
272
258
|
primaryLine.addView(primary, LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT))
|
|
273
|
-
for (icon in listOf(titleIcon, secondaryTitleIcon)) {
|
|
274
|
-
icon.visibility = GONE
|
|
275
|
-
primaryLine.addView(
|
|
276
|
-
icon,
|
|
277
|
-
LayoutParams(dp(20), dp(20)).apply { marginStart = dp(4) },
|
|
278
|
-
)
|
|
279
|
-
}
|
|
280
259
|
primaryLine.addView(
|
|
281
260
|
badges,
|
|
282
261
|
LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT).apply {
|
|
@@ -291,13 +270,6 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
291
270
|
}
|
|
292
271
|
|
|
293
272
|
fun reset() {
|
|
294
|
-
primaryLine.gravity = Gravity.CENTER_VERTICAL
|
|
295
|
-
for (icon in listOf(titleIcon, secondaryTitleIcon)) {
|
|
296
|
-
icon.visibility = GONE
|
|
297
|
-
icon.iconName = ""
|
|
298
|
-
icon.contentDescription = null
|
|
299
|
-
icon.setOnClickListener(null)
|
|
300
|
-
}
|
|
301
273
|
primaryLine.layoutParams.width = LayoutParams.WRAP_CONTENT
|
|
302
274
|
primaryLine.layoutParams.height = LayoutParams.WRAP_CONTENT
|
|
303
275
|
secondaryLine.layoutParams.height = LayoutParams.WRAP_CONTENT
|
|
@@ -320,26 +292,6 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
320
292
|
badges.visibility = GONE
|
|
321
293
|
}
|
|
322
294
|
|
|
323
|
-
fun bindTitleIcons(column: JSONObject, theme: JSONObject?, sourceScale: Boolean) {
|
|
324
|
-
for ((field, icon) in listOf(
|
|
325
|
-
"titleIcon" to titleIcon,
|
|
326
|
-
"secondaryTitleIcon" to secondaryTitleIcon,
|
|
327
|
-
)) {
|
|
328
|
-
val descriptor = column.optJSONObject(field) ?: continue
|
|
329
|
-
icon.iconName = descriptor.optString("name")
|
|
330
|
-
icon.glyphSizeDp = 20
|
|
331
|
-
icon.useSourceScale = sourceScale
|
|
332
|
-
icon.tintColor = parseNativeListColor(
|
|
333
|
-
descriptor.optString("tintColor").takeIf(String::isNotEmpty)
|
|
334
|
-
?: theme?.optString("iconSubdued", "#00000072") ?: "#00000072"
|
|
335
|
-
)
|
|
336
|
-
icon.contentDescription = descriptor.optString("accessibilityLabel").takeIf(String::isNotEmpty)
|
|
337
|
-
icon.visibility = VISIBLE
|
|
338
|
-
}
|
|
339
|
-
if (primary.maxLines > 1 && (titleIcon.visibility == VISIBLE || secondaryTitleIcon.visibility == VISIBLE))
|
|
340
|
-
primaryLine.gravity = Gravity.TOP
|
|
341
|
-
}
|
|
342
|
-
|
|
343
295
|
fun bind(
|
|
344
296
|
column: JSONObject,
|
|
345
297
|
rowBadges: JSONArray?,
|
|
@@ -374,7 +326,7 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
374
326
|
.bind(view)
|
|
375
327
|
if (resolved.optString("truncate") != "clip") view.ellipsize = TextUtils.TruncateAt.END
|
|
376
328
|
}
|
|
377
|
-
bindText(primary,
|
|
329
|
+
bindText(primary, column.optString("text"), "columns", primarySize, "medium", primaryColor, 20)
|
|
378
330
|
bindText(
|
|
379
331
|
secondaryLeading,
|
|
380
332
|
column.optString("secondaryLeadingText"),
|
|
@@ -386,15 +338,13 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
386
338
|
)
|
|
387
339
|
bindText(
|
|
388
340
|
secondary,
|
|
389
|
-
|
|
341
|
+
column.optString("secondaryText"),
|
|
390
342
|
"columnSecondary",
|
|
391
343
|
12f,
|
|
392
344
|
"regular",
|
|
393
345
|
secondaryColor,
|
|
394
346
|
16,
|
|
395
347
|
)
|
|
396
|
-
primary.text = dataSegments(primary.text, column.optJSONArray("textSegments"), primary.textSize)
|
|
397
|
-
secondary.text = dataSegments(secondary.text, column.optJSONArray("secondaryTextSegments"), secondary.textSize)
|
|
398
348
|
if (rowBadges != null && rowBadges.length() > 0) {
|
|
399
349
|
badges.visibility = VISIBLE
|
|
400
350
|
for (index in 0 until minOf(2, rowBadges.length())) {
|
|
@@ -427,7 +377,7 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
427
377
|
secondaryLeading.visibility = VISIBLE
|
|
428
378
|
secondaryLine.visibility = VISIBLE
|
|
429
379
|
}
|
|
430
|
-
val secondaryText =
|
|
380
|
+
val secondaryText = column.optString("secondaryText")
|
|
431
381
|
if (secondaryText.isNotEmpty()) {
|
|
432
382
|
secondary.visibility = VISIBLE
|
|
433
383
|
secondaryLine.visibility = VISIBLE
|
|
@@ -454,9 +404,7 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
454
404
|
) {
|
|
455
405
|
reset()
|
|
456
406
|
gravity = Gravity.START
|
|
457
|
-
val value = android.text.SpannableStringBuilder(
|
|
458
|
-
nativeListDataColumnText(column, "text"), column.optJSONArray("textSegments"),
|
|
459
|
-
sp(16f) * resources.displayMetrics.scaledDensity))
|
|
407
|
+
val value = android.text.SpannableStringBuilder(column.optString("text"))
|
|
460
408
|
value.setSpan(
|
|
461
409
|
android.text.style.ForegroundColorSpan(primaryColor),
|
|
462
410
|
0,
|
|
@@ -480,12 +428,10 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
480
428
|
android.text.Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
|
|
481
429
|
)
|
|
482
430
|
}
|
|
483
|
-
val secondaryText =
|
|
431
|
+
val secondaryText = column.optString("secondaryText")
|
|
484
432
|
if (secondaryText.isNotEmpty()) {
|
|
485
433
|
val start = value.length
|
|
486
|
-
value.append("\n")
|
|
487
|
-
value.append(dataSegments(secondaryText, column.optJSONArray("secondaryTextSegments"),
|
|
488
|
-
sp(16f) * resources.displayMetrics.scaledDensity))
|
|
434
|
+
value.append("\n$secondaryText")
|
|
489
435
|
value.setSpan(
|
|
490
436
|
android.text.style.ForegroundColorSpan(secondaryColor),
|
|
491
437
|
start,
|
|
@@ -515,24 +461,6 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
515
461
|
primary.visibility = VISIBLE
|
|
516
462
|
}
|
|
517
463
|
|
|
518
|
-
private fun dataSegments(fallback: CharSequence, segments: JSONArray?, fontSizePx: Float): CharSequence {
|
|
519
|
-
if (segments == null || segments.length() == 0) return fallback
|
|
520
|
-
val value = android.text.SpannableStringBuilder(fallback)
|
|
521
|
-
var offset = 0
|
|
522
|
-
for (index in 0 until segments.length()) {
|
|
523
|
-
val segment = segments.getJSONObject(index)
|
|
524
|
-
val end = offset + segment.optString("text").length
|
|
525
|
-
if (segment.optString("style") == "subscript" && end > offset) {
|
|
526
|
-
val density = resources.displayMetrics.density
|
|
527
|
-
val size = (kotlin.math.ceil(fontSizePx / density * 0.6f) * density).roundToInt()
|
|
528
|
-
value.setSpan(android.text.style.AbsoluteSizeSpan(size), offset, end,
|
|
529
|
-
android.text.Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
530
|
-
}
|
|
531
|
-
offset = end
|
|
532
|
-
}
|
|
533
|
-
return value
|
|
534
|
-
}
|
|
535
|
-
|
|
536
464
|
private fun applyStyle(style: JSONObject) {
|
|
537
465
|
style.optJSONObject("columns")?.let {
|
|
538
466
|
if (it.has("alignment")) {
|
|
@@ -557,11 +485,3 @@ private class NativeListTableColumnView(context: android.content.Context, privat
|
|
|
557
485
|
|
|
558
486
|
private fun sp(value: Float): Float = NativeListScale.font(resources, value)
|
|
559
487
|
}
|
|
560
|
-
|
|
561
|
-
private fun nativeListDataColumnText(column: JSONObject, field: String): String {
|
|
562
|
-
val segments = column.optJSONArray("${field}Segments")
|
|
563
|
-
if (segments == null || segments.length() == 0) return column.optString(field)
|
|
564
|
-
return buildString {
|
|
565
|
-
for (index in 0 until segments.length()) append(segments.getJSONObject(index).optString("text"))
|
|
566
|
-
}
|
|
567
|
-
}
|
|
@@ -28,12 +28,9 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
28
28
|
private val mainColumn = LinearLayout(context)
|
|
29
29
|
private val titleLine = PackedTitleLineLayout(context)
|
|
30
30
|
private val title = NativeListTextView(context)
|
|
31
|
-
private val titleIcon = OneKeyIconView(context)
|
|
32
31
|
private val subtitle = NativeListTextView(context)
|
|
33
32
|
private val tertiary = NativeListTextView(context)
|
|
34
33
|
private val badgeLine = NativeListTextView(context)
|
|
35
|
-
private val titleSuffixLabels = mutableListOf<NativeListTextView>()
|
|
36
|
-
private val titleSuffixMaxWidths = mutableListOf<Int>()
|
|
37
34
|
private val trailingColumn = NativeListAccessoryStack(context, fonts)
|
|
38
35
|
private val semanticBadgeLabels = mutableListOf<TextView>()
|
|
39
36
|
private val semanticSubtitleLabels = mutableListOf<TextView>()
|
|
@@ -86,7 +83,6 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
86
83
|
titleLine.orientation = HORIZONTAL
|
|
87
84
|
titleLine.gravity = Gravity.CENTER_VERTICAL
|
|
88
85
|
titleLine.addView(title, LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f))
|
|
89
|
-
titleLine.addView(titleIcon, LayoutParams(dp(20), dp(20)).apply { marginStart = dp(4) })
|
|
90
86
|
titleLine.addView(badgeLine)
|
|
91
87
|
trailingColumn.onAction = { key, view, slot, target ->
|
|
92
88
|
emitAction(key, view, "trailingAccessory", slot, target, trailingColumn.anchorInset(view))
|
|
@@ -115,7 +111,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
115
111
|
|
|
116
112
|
private fun showText(view: TextView, text: String, lines: Int) {
|
|
117
113
|
view.text = text
|
|
118
|
-
view.maxLines =
|
|
114
|
+
view.maxLines = lines
|
|
119
115
|
view.visibility = if (text.isEmpty()) GONE else VISIBLE
|
|
120
116
|
}
|
|
121
117
|
|
|
@@ -140,25 +136,9 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
140
136
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
|
|
141
137
|
) {
|
|
142
138
|
currentItem = item
|
|
143
|
-
val longPressActionKey = item.json.optString("longPressActionKey")
|
|
144
|
-
setOnLongClickListener(
|
|
145
|
-
if (longPressActionKey.isNotEmpty())
|
|
146
|
-
OnLongClickListener {
|
|
147
|
-
if (!isEnabled || !item.isRowPressEnabled || currentItem?.key != item.key) false
|
|
148
|
-
else {
|
|
149
|
-
emitAction(longPressActionKey, this, "row")
|
|
150
|
-
true
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
else null
|
|
154
|
-
)
|
|
155
|
-
isLongClickable = longPressActionKey.isNotEmpty()
|
|
156
139
|
currentTheme = theme
|
|
157
140
|
removeAllViews()
|
|
158
141
|
mainColumn.removeAllViews()
|
|
159
|
-
titleSuffixLabels.forEach(titleLine::removeView)
|
|
160
|
-
titleSuffixLabels.clear()
|
|
161
|
-
titleSuffixMaxWidths.clear()
|
|
162
142
|
semanticBadgeLabels.clear()
|
|
163
143
|
semanticSubtitleLabels.clear()
|
|
164
144
|
walletBadgeLine = null
|
|
@@ -177,12 +157,8 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
177
157
|
mainColumn.gravity = Gravity.CENTER_VERTICAL
|
|
178
158
|
titleLine.gravity = Gravity.CENTER_VERTICAL
|
|
179
159
|
titleLine.packsChildrenAtStart = false
|
|
180
|
-
titleLine.leadingTextMaxWidth = Int.MAX_VALUE
|
|
181
160
|
titleLine.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
|
|
182
161
|
title.layoutParams = LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f)
|
|
183
|
-
titleIcon.visibility = GONE
|
|
184
|
-
titleIcon.contentDescription = null
|
|
185
|
-
titleIcon.setOnClickListener(null)
|
|
186
162
|
for (view in listOf(title, subtitle, tertiary, badgeLine)) {
|
|
187
163
|
view.text = ""
|
|
188
164
|
view.visibility = GONE
|
|
@@ -318,19 +294,6 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
318
294
|
private fun addLeading(visual: JSONObject?, sizeDp: Int, spacingDp: Int = 12) {
|
|
319
295
|
// Legacy: a missing visual still reserves an empty, transparent leading slot.
|
|
320
296
|
val descriptor = visual ?: JSONObject().put("backgroundColor", "#00000000")
|
|
321
|
-
val overlays = descriptor.optJSONArray("overlays")
|
|
322
|
-
if (overlays != null && (0 until minOf(2, overlays.length())).any { index ->
|
|
323
|
-
val overlay = overlays.optJSONObject(index) ?: return@any false
|
|
324
|
-
overlay.optInt("offsetX", overlay.optInt("offset", 2)) > 0 ||
|
|
325
|
-
overlay.optInt("offsetY", overlay.optInt("offset", 2)) > 0
|
|
326
|
-
}) {
|
|
327
|
-
// The badge extends beyond the avatar and the row's padded content box.
|
|
328
|
-
clipChildren = false
|
|
329
|
-
clipToPadding = false
|
|
330
|
-
}
|
|
331
|
-
leadingFrame.bitmapBorderWidth =
|
|
332
|
-
if (descriptor.optString("borderColor").isNotEmpty() &&
|
|
333
|
-
descriptor.optString("borderStyle") != "dashed") dp(1) else 0
|
|
334
297
|
if (visual == null) leadingFrame.recycle()
|
|
335
298
|
val item = currentItem!!
|
|
336
299
|
val style = item.json.optJSONObject("style")?.optJSONObject("image") ?: JSONObject()
|
|
@@ -393,58 +356,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
393
356
|
}
|
|
394
357
|
|
|
395
358
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
396
|
-
val ratio = currentItem?.json?.optJSONObject("style")
|
|
397
|
-
?.optDouble("leadingContentMaxWidthRatio", Double.NaN) ?: Double.NaN
|
|
398
|
-
titleLine.leadingTextMaxWidth =
|
|
399
|
-
if (ratio.isFinite() && ratio > 0.0 && ratio <= 1.0 && leadingFrame.parent === this) {
|
|
400
|
-
val inner = (MeasureSpec.getSize(widthMeasureSpec) - paddingLeft - paddingRight)
|
|
401
|
-
.coerceAtLeast(0)
|
|
402
|
-
val leading = leadingFrame.layoutParams as LayoutParams
|
|
403
|
-
val icon = if (titleIcon.visibility == VISIBLE) dp(24) else 0
|
|
404
|
-
(inner * ratio).roundToInt()
|
|
405
|
-
.minus(leading.width + leading.marginEnd + icon)
|
|
406
|
-
.coerceAtLeast(0)
|
|
407
|
-
} else Int.MAX_VALUE
|
|
408
|
-
titleSuffixLabels.forEachIndexed { index, label ->
|
|
409
|
-
label.maxWidth = titleSuffixMaxWidths[index]
|
|
410
|
-
}
|
|
411
359
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
|
412
|
-
if (titleSuffixLabels.isNotEmpty()) {
|
|
413
|
-
val fixedWidth =
|
|
414
|
-
(1 until titleLine.childCount).sumOf { index ->
|
|
415
|
-
val view = titleLine.getChildAt(index)
|
|
416
|
-
if (view.visibility == GONE || titleSuffixLabels.any { it === view }) 0
|
|
417
|
-
else {
|
|
418
|
-
val margins = view.layoutParams as MarginLayoutParams
|
|
419
|
-
view.measuredWidth + margins.leftMargin + margins.rightMargin
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
val suffixMargins = titleSuffixLabels.sumOf {
|
|
423
|
-
val margins = it.layoutParams as MarginLayoutParams
|
|
424
|
-
margins.leftMargin + margins.rightMargin
|
|
425
|
-
}
|
|
426
|
-
val available =
|
|
427
|
-
(titleLine.measuredWidth - fixedWidth - suffixMargins - dp(80)).coerceAtLeast(0)
|
|
428
|
-
val desired = titleSuffixLabels.mapIndexed { index, label ->
|
|
429
|
-
label.paint.measureText(label.text.toString()).roundToInt()
|
|
430
|
-
.coerceAtMost(titleSuffixMaxWidths[index])
|
|
431
|
-
}
|
|
432
|
-
val total = desired.sum()
|
|
433
|
-
var remaining = available
|
|
434
|
-
var changed = false
|
|
435
|
-
titleSuffixLabels.forEachIndexed { index, label ->
|
|
436
|
-
val share =
|
|
437
|
-
if (total <= available) desired[index]
|
|
438
|
-
else if (index == titleSuffixLabels.lastIndex) remaining
|
|
439
|
-
else (desired[index].toLong() * available / total).toInt()
|
|
440
|
-
remaining -= share
|
|
441
|
-
if (label.maxWidth != share) {
|
|
442
|
-
label.maxWidth = share
|
|
443
|
-
changed = true
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
if (changed) super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
|
447
|
-
}
|
|
448
360
|
val item = currentItem ?: return
|
|
449
361
|
if (
|
|
450
362
|
item.hasExplicitHeight &&
|
|
@@ -670,48 +582,6 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
670
582
|
titleLine.packsChildrenAtStart = true
|
|
671
583
|
title.ellipsize = TextUtils.TruncateAt.END
|
|
672
584
|
showText(title, item.json.optString("title"), item.json.optInt("titleLines", 1))
|
|
673
|
-
item.json.optJSONArray("titleSuffixes")?.let { suffixes ->
|
|
674
|
-
for (index in 0 until suffixes.length()) {
|
|
675
|
-
val suffix = suffixes.optJSONObject(index) ?: continue
|
|
676
|
-
val label = NativeListTextView(context).apply {
|
|
677
|
-
text = suffix.optString("text")
|
|
678
|
-
typeface = fonts.regular(context)
|
|
679
|
-
textSize = sp(12f)
|
|
680
|
-
includeFontPadding = false
|
|
681
|
-
maxLines = 1
|
|
682
|
-
ellipsize = TextUtils.TruncateAt.END
|
|
683
|
-
setTextColor(
|
|
684
|
-
color(
|
|
685
|
-
theme,
|
|
686
|
-
if (suffix.optString("tone") == "disabled") "disabledText" else "secondaryText",
|
|
687
|
-
"#0000009B",
|
|
688
|
-
)
|
|
689
|
-
)
|
|
690
|
-
}
|
|
691
|
-
TextViewCompat.setLineHeight(label, dp(16))
|
|
692
|
-
val maxWidth =
|
|
693
|
-
if (suffix.has("maxWidth")) stylePx(suffix.optDouble("maxWidth")) else Int.MAX_VALUE
|
|
694
|
-
label.maxWidth = maxWidth
|
|
695
|
-
titleSuffixMaxWidths.add(maxWidth)
|
|
696
|
-
titleSuffixLabels.add(label)
|
|
697
|
-
titleLine.addView(
|
|
698
|
-
label,
|
|
699
|
-
titleLine.childCount - 1,
|
|
700
|
-
LayoutParams(LayoutParams.WRAP_CONTENT, dp(16)).apply { marginStart = dp(8) },
|
|
701
|
-
)
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
item.json.optJSONObject("titleIcon")?.let { icon ->
|
|
705
|
-
titleIcon.iconName = icon.optString("name")
|
|
706
|
-
titleIcon.glyphSizeDp = 20
|
|
707
|
-
titleIcon.useSourceScale = sourceScale
|
|
708
|
-
titleIcon.tintColor = safeColor(
|
|
709
|
-
icon.optString("tintColor").takeIf(String::isNotEmpty),
|
|
710
|
-
color(theme, "iconSubdued", "#00000072"),
|
|
711
|
-
)
|
|
712
|
-
titleIcon.contentDescription = icon.optString("accessibilityLabel").takeIf(String::isNotEmpty)
|
|
713
|
-
titleIcon.visibility = VISIBLE
|
|
714
|
-
}
|
|
715
585
|
if (item.json.optString("presentation") == "accountSelector") {
|
|
716
586
|
title.typeface = fonts.regular(context)
|
|
717
587
|
}
|
|
@@ -831,10 +701,6 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
831
701
|
.let { kinds ->
|
|
832
702
|
kinds.containsAll(listOf("value", "checkbox")) ||
|
|
833
703
|
kinds == listOf("valuePair", "menu") ||
|
|
834
|
-
kinds == listOf("valuePair", "chevron") ||
|
|
835
|
-
(kinds == listOf("icon", "chevron") &&
|
|
836
|
-
accessories.getJSONObject(0).optString("name") == "RefreshCcwOutline" &&
|
|
837
|
-
accessories.getJSONObject(0).optString("actionKey").isEmpty()) ||
|
|
838
704
|
(kinds == listOf("icon", "icon") &&
|
|
839
705
|
accessories.getJSONObject(0).optString("name") == "PencilOutline" &&
|
|
840
706
|
accessories.getJSONObject(1).optString("name") == "DragOutline")
|
|
@@ -27,7 +27,6 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
27
27
|
private val cornerBackdrop = View(context)
|
|
28
28
|
private val slots = mutableListOf<NativeListImageSlot>()
|
|
29
29
|
private val overlaySlots = mutableListOf<NativeListImageSlot>()
|
|
30
|
-
private val overlayFallbackIcons = mutableListOf<OneKeyIconView>()
|
|
31
30
|
private val overlays = mutableListOf<Pair<FrameLayout, JSONObject>>()
|
|
32
31
|
private var visual = JSONObject()
|
|
33
32
|
private var style = JSONObject()
|
|
@@ -151,8 +150,6 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
151
150
|
}
|
|
152
151
|
val placeholder = theme?.optString("strongBackground", "#0000000F") ?: "#0000000F"
|
|
153
152
|
val fallbackIcon = visual.optJSONObject("fallbackIcon")
|
|
154
|
-
val fallbackBackground = fallbackIcon?.optString("backgroundColor")
|
|
155
|
-
?.takeIf(String::isNotEmpty) ?: placeholder
|
|
156
153
|
val sourceFallback =
|
|
157
154
|
sources.firstOrNull()?.first?.optString("loadingStrategy", "none")?.let { it != "none" } ==
|
|
158
155
|
true && (visual.has("fallbackText") || fallbackIcon != null)
|
|
@@ -173,7 +170,7 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
173
170
|
val restored = fallbackKey?.let(NativeListSourceFallbackState::has) == true
|
|
174
171
|
fallback.textSize = if (sourceScale) 13f else NativeListScale.font(resources, 13f)
|
|
175
172
|
fallback.text = visual.optString("fallbackText").take(2)
|
|
176
|
-
fallback.setTextColor(color(
|
|
173
|
+
fallback.setTextColor(color("#00000072"))
|
|
177
174
|
fallback.visibility =
|
|
178
175
|
if (kind != "icon" && fallbackIcon == null && (sources.isEmpty() || restored)) VISIBLE
|
|
179
176
|
else GONE
|
|
@@ -187,9 +184,7 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
187
184
|
color(
|
|
188
185
|
visual.optString("backgroundColor", if (sources.isEmpty()) placeholder else "#00000000")
|
|
189
186
|
)
|
|
190
|
-
val backgroundColor =
|
|
191
|
-
if (sources.isEmpty() && fallbackIcon?.has("backgroundColor") == true || restored) color(fallbackBackground)
|
|
192
|
-
else if (sourceFallback) color(placeholder) else visualBackground
|
|
187
|
+
val backgroundColor = if (sourceFallback) color(placeholder) else visualBackground
|
|
193
188
|
background =
|
|
194
189
|
fill(backgroundColor, 0f).apply {
|
|
195
190
|
if (kind == "icon" && iconBorder) setStroke(1, color("#0000001F"))
|
|
@@ -206,7 +201,7 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
206
201
|
slot.recycle()
|
|
207
202
|
slot.view.visibility = GONE
|
|
208
203
|
} else {
|
|
209
|
-
slot.view.visibility = if (index > 0 ||
|
|
204
|
+
slot.view.visibility = if (index > 0 || sourceFallback) INVISIBLE else VISIBLE
|
|
210
205
|
slot.bind(
|
|
211
206
|
sources[index].first,
|
|
212
207
|
"$key:leading:$index",
|
|
@@ -225,7 +220,7 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
225
220
|
else NativeListSourceFallbackState.remember(it)
|
|
226
221
|
}
|
|
227
222
|
(background as? GradientDrawable)?.setColor(
|
|
228
|
-
if (loaded) visualBackground else color(
|
|
223
|
+
if (loaded) visualBackground else color(placeholder)
|
|
229
224
|
)
|
|
230
225
|
fallback.visibility = if (!loaded && fallbackIcon == null) VISIBLE else GONE
|
|
231
226
|
icon.visibility = if (!loaded && fallbackIcon != null) VISIBLE else GONE
|
|
@@ -261,18 +256,8 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
261
256
|
?.let { values -> (0 until minOf(2, values.length())).map { values.getJSONObject(it) } }
|
|
262
257
|
.orEmpty()
|
|
263
258
|
while (overlaySlots.size < descriptors.size) overlaySlots.add(NativeListImageSlot(reactContext))
|
|
264
|
-
while (overlayFallbackIcons.size < descriptors.size)
|
|
265
|
-
overlayFallbackIcons.add(OneKeyIconView(context))
|
|
266
259
|
descriptors.forEachIndexed { index, data ->
|
|
267
260
|
val frame = previousOverlays.getOrNull(index)?.first ?: FrameLayout(context)
|
|
268
|
-
val image = data.optJSONObject("image")
|
|
269
|
-
val fallbackData = data.optJSONObject("fallbackIcon")
|
|
270
|
-
val fallbackGlyph = overlayFallbackIcons[index].apply {
|
|
271
|
-
visibility = GONE
|
|
272
|
-
iconName = fallbackData?.optString("name") ?: ""
|
|
273
|
-
tintColor = color(fallbackData?.optString("tintColor", "#0000009B") ?: "#0000009B")
|
|
274
|
-
useSourceScale = sourceScale
|
|
275
|
-
}
|
|
276
261
|
frame.background =
|
|
277
262
|
fill(
|
|
278
263
|
color(data.optString("backgroundColor", "#00000000")),
|
|
@@ -284,15 +269,11 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
284
269
|
frame.outlineProvider = ViewOutlineProvider.BACKGROUND
|
|
285
270
|
frame.clipToOutline = true
|
|
286
271
|
val child: View =
|
|
287
|
-
image?.let {
|
|
272
|
+
data.optJSONObject("image")?.let { image ->
|
|
288
273
|
val slot = overlaySlots[index]
|
|
289
274
|
slot.view.visibility = INVISIBLE
|
|
290
|
-
|
|
291
|
-
data.optInt("width", data.optInt("size", 20)) == overlayHeight(data)
|
|
292
|
-
slot.bind(source, "$key:overlay:$index", placeholder = placeholder,
|
|
293
|
-
round = circularImage) {
|
|
275
|
+
slot.bind(image, "$key:overlay:$index", placeholder = placeholder) {
|
|
294
276
|
slot.view.visibility = if (it) VISIBLE else INVISIBLE
|
|
295
|
-
fallbackGlyph.visibility = if (!it && fallbackData != null) VISIBLE else GONE
|
|
296
277
|
}
|
|
297
278
|
slot.view
|
|
298
279
|
}
|
|
@@ -309,13 +290,8 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
309
290
|
if (walletText) androidx.core.widget.TextViewCompat.setLineHeight(this, dp(16))
|
|
310
291
|
else setLineSpacing(0f, 1f)
|
|
311
292
|
typeface =
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
"medium" -> fonts.medium(context)
|
|
315
|
-
"semibold" -> fonts.semibold(context)
|
|
316
|
-
"bold" -> fonts.bold(context)
|
|
317
|
-
else -> if (isWalletText(data)) fonts.regular(context) else fonts.medium(context)
|
|
318
|
-
}
|
|
293
|
+
if (isWalletText(data)) fonts.regular(context)
|
|
294
|
+
else fonts.medium(context)
|
|
319
295
|
setTextColor(color(data.optString("tintColor", "#0000009B")))
|
|
320
296
|
}
|
|
321
297
|
} else {
|
|
@@ -329,13 +305,11 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
329
305
|
val inset = data.optInt("padding", 0)
|
|
330
306
|
if (isWalletText(data)) frame.setPadding(dp(2), 0, dp(2), 0)
|
|
331
307
|
else frame.setPadding(dp(inset), dp(inset), dp(inset), dp(inset))
|
|
332
|
-
frame
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
(fallbackGlyph.parent as? android.view.ViewGroup)?.removeView(fallbackGlyph)
|
|
338
|
-
frame.addView(fallbackGlyph, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
308
|
+
if (child.parent !== frame) {
|
|
309
|
+
frame.removeAllViews()
|
|
310
|
+
// A reused slot view may still belong to a frame dropped by an earlier bind.
|
|
311
|
+
(child.parent as? android.view.ViewGroup)?.removeView(child)
|
|
312
|
+
frame.addView(child, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
339
313
|
}
|
|
340
314
|
if (frame.parent == null) addView(frame)
|
|
341
315
|
overlays.add(frame to data)
|
|
@@ -393,11 +367,8 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
393
367
|
)
|
|
394
368
|
}
|
|
395
369
|
place(fallback, 0, 0, w, h)
|
|
396
|
-
val explicitFallbackSize = visual.optJSONObject("fallbackIcon")
|
|
397
|
-
?.optDouble("size", Double.NaN)?.takeIf { it.isFinite() && it > 0.0 }
|
|
398
370
|
val iconSize =
|
|
399
|
-
if (
|
|
400
|
-
else if (sources.isNotEmpty() && visual.optJSONObject("fallbackIcon") != null)
|
|
371
|
+
if (sources.isNotEmpty() && visual.optJSONObject("fallbackIcon") != null)
|
|
401
372
|
(minOf(w, h) *
|
|
402
373
|
if (visual.optJSONObject("fallbackIcon")?.optString("name") == "GlobusOutline") 1.2f
|
|
403
374
|
else 1f)
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
package com.margelo.nitro.nativelist
|
|
2
2
|
|
|
3
3
|
import android.graphics.Color
|
|
4
|
-
import android.graphics.Canvas
|
|
5
4
|
import android.graphics.Outline
|
|
6
|
-
import android.graphics.Paint
|
|
7
5
|
import android.graphics.drawable.GradientDrawable
|
|
8
6
|
import android.view.Gravity
|
|
9
7
|
import android.view.View
|
|
@@ -213,7 +211,6 @@ internal class NativeListMessageRowView(context: ThemedReactContext, fonts: Nati
|
|
|
213
211
|
NativeListRendererRowView(context, fonts) {
|
|
214
212
|
override val assetFields = listOf("leading", "thumbnail")
|
|
215
213
|
private val views = NativeListMessageRenderer.Views(context, fonts)
|
|
216
|
-
private val warningBorderPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
|
217
214
|
|
|
218
215
|
override fun bindContent(
|
|
219
216
|
item: NativeListItem,
|
|
@@ -232,27 +229,5 @@ internal class NativeListMessageRowView(context: ThemedReactContext, fonts: Nati
|
|
|
232
229
|
|
|
233
230
|
override fun recycleContent() = views.recycle()
|
|
234
231
|
|
|
235
|
-
override fun appearance() {
|
|
236
|
-
super.appearance()
|
|
237
|
-
if (boundItem?.json?.optString("presentation") == "inlineWarning") {
|
|
238
|
-
foreground = null
|
|
239
|
-
clipToOutline = false
|
|
240
|
-
(background as? GradientDrawable)?.cornerRadius = 0f
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
override fun dispatchDraw(canvas: Canvas) {
|
|
245
|
-
super.dispatchDraw(canvas)
|
|
246
|
-
val item = boundItem ?: return
|
|
247
|
-
if (item.json.optString("presentation") != "inlineWarning") return
|
|
248
|
-
val container = item.json.optJSONObject("style")?.optJSONObject("container") ?: return
|
|
249
|
-
val borderWidth = container.optDouble("borderWidth", 0.0).toFloat()
|
|
250
|
-
if (borderWidth <= 0) return
|
|
251
|
-
val pixels = (borderWidth * resources.displayMetrics.density).coerceAtLeast(1f)
|
|
252
|
-
warningBorderPaint.color = parseNativeListColor(container.optString("borderColor", "#00000000"))
|
|
253
|
-
canvas.drawRect(0f, 0f, width.toFloat(), pixels, warningBorderPaint)
|
|
254
|
-
canvas.drawRect(0f, height - pixels, width.toFloat(), height.toFloat(), warningBorderPaint)
|
|
255
|
-
}
|
|
256
|
-
|
|
257
232
|
override fun disposeContent() = views.dispose()
|
|
258
233
|
}
|
|
@@ -13,7 +13,7 @@ internal fun isNativeListRowPressEnabled(
|
|
|
13
13
|
variant: String,
|
|
14
14
|
disabled: Boolean,
|
|
15
15
|
pressDisabled: Boolean,
|
|
16
|
-
): Boolean = !disabled && !pressDisabled &&
|
|
16
|
+
): Boolean = !disabled && !pressDisabled && (type != "system" || variant == "retry")
|
|
17
17
|
|
|
18
18
|
internal fun isNativeListWholeRowInteractive(
|
|
19
19
|
type: String,
|
|
@@ -57,7 +57,7 @@ private fun updateLengthPrefixed(digest: MessageDigest, value: String) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// Template type alone partitions reuse; data keys and styles never select a renderer.
|
|
60
|
-
internal enum class NativeListRendererKey { MESSAGE, RAIL, MEDIA_TILE, ACTION, SYSTEM, ACTIVITY, DATA_ROW, METRIC_CARD, MARKET, IDENTITY, SECTION_HEADER, WALLET_GROUP
|
|
60
|
+
internal enum class NativeListRendererKey { MESSAGE, RAIL, MEDIA_TILE, ACTION, SYSTEM, ACTIVITY, DATA_ROW, METRIC_CARD, MARKET, IDENTITY, SECTION_HEADER, WALLET_GROUP }
|
|
61
61
|
|
|
62
62
|
internal data class NativeListItem(
|
|
63
63
|
val key: String,
|
|
@@ -142,7 +142,6 @@ internal data class NativeListItem(
|
|
|
142
142
|
|
|
143
143
|
internal data class NativeListConfig(
|
|
144
144
|
val generation: Int,
|
|
145
|
-
val structuralTransition: StructuralTransition?,
|
|
146
145
|
val layout: String,
|
|
147
146
|
val orientation: String,
|
|
148
147
|
val gridColumns: Int,
|
|
@@ -169,22 +168,9 @@ internal data class NativeListConfig(
|
|
|
169
168
|
val fixedFooter: NativeListItem?,
|
|
170
169
|
val items: List<NativeListItem>,
|
|
171
170
|
) {
|
|
172
|
-
internal data class StructuralTransition(
|
|
173
|
-
val id: String,
|
|
174
|
-
val durationMs: Long,
|
|
175
|
-
val anchorKey: String?,
|
|
176
|
-
)
|
|
177
171
|
companion object {
|
|
178
172
|
fun parse(snapshotJson: String): NativeListConfig {
|
|
179
173
|
val root = JSONObject(snapshotJson)
|
|
180
|
-
val transition = root.optJSONObject("structuralTransition")
|
|
181
|
-
val structuralTransition = transition?.optString("id")?.takeIf(String::isNotEmpty)?.let { id ->
|
|
182
|
-
StructuralTransition(
|
|
183
|
-
id = id,
|
|
184
|
-
durationMs = transition.optDouble("durationMs", 220.0).coerceIn(0.0, 2000.0).toLong(),
|
|
185
|
-
anchorKey = transition.optString("anchorKey").takeIf(String::isNotEmpty),
|
|
186
|
-
)
|
|
187
|
-
}
|
|
188
174
|
require(root.getInt("schemaVersion") == 1) { "Unsupported schemaVersion" }
|
|
189
175
|
val layout = root.getJSONObject("layout")
|
|
190
176
|
val selection = root.optJSONObject("selection")
|
|
@@ -207,7 +193,6 @@ internal data class NativeListConfig(
|
|
|
207
193
|
val fixedFooter = root.optJSONObject("fixedFooter")?.let(NativeListItem::parse)
|
|
208
194
|
return NativeListConfig(
|
|
209
195
|
generation = root.getInt("generation"),
|
|
210
|
-
structuralTransition = structuralTransition,
|
|
211
196
|
layout = layout.getString("kind"),
|
|
212
197
|
orientation = layout.optString("orientation", "vertical"),
|
|
213
198
|
gridColumns = layout.optInt("gridColumns", 1).coerceIn(1, 7),
|