@onekeyfe/react-native-native-list 6.7.0-alpha.366 → 6.7.0-alpha.374
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/NativeListIdentityRenderer.kt +10 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +16 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +14 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
- package/docs/SPEC.md +33 -0
- package/ios/RNCNativeListView.swift +18 -0
- package/package.json +3 -3
|
@@ -310,6 +310,16 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
310
310
|
if (item.json.optString("presentation") == "accountSelector" && item.hasExplicitHeight) 8
|
|
311
311
|
else 10
|
|
312
312
|
leadingFrame.bind(descriptor, style, item.key, currentTheme, false, sourceScale)
|
|
313
|
+
// The leading badges (overlay, cornerIcon, token network image) hang past the
|
|
314
|
+
// leading frame, and Android clips a child to its own bounds while its parent
|
|
315
|
+
// clips children: with the row's default clipping the account selector's
|
|
316
|
+
// bottom-right network badge was cut flat on Android only (OK-65694); iOS and
|
|
317
|
+
// Web let it overflow. Stop clipping the row, as the Market and Message
|
|
318
|
+
// renderers do for their network badges.
|
|
319
|
+
if (leadingFrame.requestsUnclippedHost) {
|
|
320
|
+
clipChildren = false
|
|
321
|
+
clipToPadding = false
|
|
322
|
+
}
|
|
313
323
|
leadingFallback.typeface = fonts.bold(context)
|
|
314
324
|
leadingFallback.textSize = sp(13f)
|
|
315
325
|
leadingFallback.setLineSpacing(0f, 1f)
|
|
@@ -42,6 +42,15 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
42
42
|
*/
|
|
43
43
|
var walletTextOverlays = false
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* True once the bound visual lays a badge past this frame (see
|
|
47
|
+
* [nativeListLeadingVisualOverhangsFrame]). This view never clips its children,
|
|
48
|
+
* but a host that clips children clips this view to its own bounds, so such a
|
|
49
|
+
* host must stop clipping or the badge is cut flat (OK-65694).
|
|
50
|
+
*/
|
|
51
|
+
var requestsUnclippedHost = false
|
|
52
|
+
private set
|
|
53
|
+
|
|
45
54
|
private fun isWalletText(data: JSONObject) =
|
|
46
55
|
walletTextOverlays &&
|
|
47
56
|
data.optString("text").isNotEmpty() &&
|
|
@@ -255,6 +264,13 @@ internal class NativeListLeadingVisual(private val reactContext: ThemedReactCont
|
|
|
255
264
|
.optJSONArray("overlays")
|
|
256
265
|
?.let { values -> (0 until minOf(2, values.length())).map { values.getJSONObject(it) } }
|
|
257
266
|
.orEmpty()
|
|
267
|
+
requestsUnclippedHost =
|
|
268
|
+
nativeListLeadingVisualOverhangsFrame(
|
|
269
|
+
kind = kind,
|
|
270
|
+
sourceCount = sources.size,
|
|
271
|
+
hasCornerIcon = badge != null,
|
|
272
|
+
overlayCount = descriptors.size,
|
|
273
|
+
)
|
|
258
274
|
while (overlaySlots.size < descriptors.size) overlaySlots.add(NativeListImageSlot(reactContext))
|
|
259
275
|
descriptors.forEachIndexed { index, data ->
|
|
260
276
|
val frame = previousOverlays.getOrNull(index)?.first ?: FrameLayout(context)
|
|
@@ -34,6 +34,20 @@ internal fun isNativeListWholeRowInteractive(
|
|
|
34
34
|
*/
|
|
35
35
|
internal fun isNativeListTrailingTextClickable(actionKey: String?): Boolean = !actionKey.isNullOrEmpty()
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* A leading visual lays these badges past its own frame: the token network image
|
|
39
|
+
* with its backdrop, a `cornerIcon`, and every overlay (their default offset
|
|
40
|
+
* already overhangs; iOS stops clipping for the same descriptors). Android clips
|
|
41
|
+
* a child to its own bounds whenever its parent clips children, so the host row
|
|
42
|
+
* must stop clipping, or the badge is cut flat (OK-65694).
|
|
43
|
+
*/
|
|
44
|
+
internal fun nativeListLeadingVisualOverhangsFrame(
|
|
45
|
+
kind: String,
|
|
46
|
+
sourceCount: Int,
|
|
47
|
+
hasCornerIcon: Boolean,
|
|
48
|
+
overlayCount: Int,
|
|
49
|
+
): Boolean = kind == "token" && sourceCount > 1 || hasCornerIcon || overlayCount > 0
|
|
50
|
+
|
|
37
51
|
internal fun resolveNativeListSelectorBackgroundColor(
|
|
38
52
|
rowType: String,
|
|
39
53
|
styleBackgroundColor: String?,
|
package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
package com.margelo.nitro.nativelist
|
|
2
|
+
|
|
3
|
+
import org.junit.Assert.assertEquals
|
|
4
|
+
import org.junit.Test
|
|
5
|
+
|
|
6
|
+
class NativeListLeadingVisualClipPolicyTest {
|
|
7
|
+
// OK-65694: the account selector's network badge is laid out past the leading
|
|
8
|
+
// frame. Android clips a child to its own bounds while its parent clips
|
|
9
|
+
// children, so a host row must stop clipping exactly when a bound badge
|
|
10
|
+
// overhangs; a plain image keeps the default clipping.
|
|
11
|
+
@Test
|
|
12
|
+
fun hostStopsClippingOnlyForBadgesLaidOutPastTheFrame() {
|
|
13
|
+
data class Case(
|
|
14
|
+
val kind: String,
|
|
15
|
+
val sourceCount: Int = 1,
|
|
16
|
+
val hasCornerIcon: Boolean = false,
|
|
17
|
+
val overlayCount: Int = 0,
|
|
18
|
+
val expected: Boolean,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
val cases = listOf(
|
|
22
|
+
Case(kind = "account", expected = false),
|
|
23
|
+
Case(kind = "account", overlayCount = 1, expected = true),
|
|
24
|
+
Case(kind = "wallet", overlayCount = 2, expected = true),
|
|
25
|
+
Case(kind = "token", sourceCount = 1, expected = false),
|
|
26
|
+
Case(kind = "token", sourceCount = 2, expected = true),
|
|
27
|
+
Case(kind = "stackedImages", sourceCount = 3, expected = false),
|
|
28
|
+
Case(kind = "network", hasCornerIcon = true, expected = true),
|
|
29
|
+
Case(kind = "icon", sourceCount = 0, expected = false),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
assertEquals(
|
|
33
|
+
cases.map(Case::expected),
|
|
34
|
+
cases.map { case ->
|
|
35
|
+
nativeListLeadingVisualOverhangsFrame(
|
|
36
|
+
kind = case.kind,
|
|
37
|
+
sourceCount = case.sourceCount,
|
|
38
|
+
hasCornerIcon = case.hasCornerIcon,
|
|
39
|
+
overlayCount = case.overlayCount,
|
|
40
|
+
)
|
|
41
|
+
},
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
}
|
package/docs/SPEC.md
CHANGED
|
@@ -304,6 +304,39 @@ the trailing `TextView` non-clickable unless `showTrailing` binds an action
|
|
|
304
304
|
(`setOnClickListener(null)` alone leaves a view clickable). Web already renders
|
|
305
305
|
an action-less accessory as a `span`, so its click reaches the row.
|
|
306
306
|
|
|
307
|
+
### Leading badge overhang (OK-65694)
|
|
308
|
+
|
|
309
|
+
Status: implemented on Android, the only platform that clipped. Android JVM
|
|
310
|
+
policy test (`NativeListLeadingVisualClipPolicyTest`); Android emulator
|
|
311
|
+
acceptance on the example account selector (API 36, 2026-10-27) is recorded in
|
|
312
|
+
the changelog entry. iOS and Web are unchanged.
|
|
313
|
+
|
|
314
|
+
A leading visual lays these badges past its own frame: a token `networkImage`
|
|
315
|
+
with its backdrop, a `cornerIcon`, and every `overlays` entry, whose default
|
|
316
|
+
`offset` of 2 already overhangs (the app's account selector hangs its
|
|
317
|
+
single-network badge 4 units past the 32-unit avatar). Such a badge MUST render
|
|
318
|
+
in full on every platform. iOS stops clipping the visual (`clipsToBounds`) once
|
|
319
|
+
one of those descriptors is bound, and Web keeps the visual `overflow: visible`.
|
|
320
|
+
Android clips a child to its own bounds whenever its parent clips children, so a
|
|
321
|
+
host row that keeps the default `clipChildren` cuts the overhang flat even
|
|
322
|
+
though the visual itself never clips. The Identity renderer therefore stops
|
|
323
|
+
clipping children and padding exactly when the bound leading visual reports an
|
|
324
|
+
overhanging badge (`requestsUnclippedHost`, decided by
|
|
325
|
+
`nativeListLeadingVisualOverhangsFrame`), as the Market and Message renderers
|
|
326
|
+
already do for their network badges; a visual without such a badge keeps the
|
|
327
|
+
row's default clipping.
|
|
328
|
+
|
|
329
|
+
The row's own shape still clips on every platform: iOS masks the cell to its
|
|
330
|
+
corner radius (`masksToBounds`), Web keeps the row `overflow: hidden`, and
|
|
331
|
+
Android keeps `clipToOutline` for a `style.container.cornerRadius` row (its
|
|
332
|
+
parent also clips each row to its bounds). A badge is therefore whole only while
|
|
333
|
+
it stays inside the row's rounded outline, which every app descriptor does: the
|
|
334
|
+
account badge hangs 4 units towards the row's centre and the wallet top-left
|
|
335
|
+
badge (`offsetY` 4) starts inside a 12-unit corner radius with the default
|
|
336
|
+
padding. The example `NativeListRowStylePage` row `identity-badge-rounded`
|
|
337
|
+
combines both badges with `container.cornerRadius` as the rendering check for
|
|
338
|
+
that combination.
|
|
339
|
+
|
|
307
340
|
## Failures, fallback and limits
|
|
308
341
|
|
|
309
342
|
Snapshot validation rejects malformed/duplicate-key input without partial
|
|
@@ -527,13 +527,27 @@ final class NativeListView: UIView {
|
|
|
527
527
|
super.willMove(toWindow: newWindow)
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
+
private func notifyPagerScrollViewReadyIfNeeded() {
|
|
531
|
+
guard !disposed,
|
|
532
|
+
window != nil,
|
|
533
|
+
collectionView.delegate === self,
|
|
534
|
+
collectionView.bounds.width > 0,
|
|
535
|
+
collectionView.bounds.height > 0 else { return }
|
|
536
|
+
NotificationCenter.default.post(
|
|
537
|
+
name: Notification.Name("OneKeyNativeScrollViewDidBecomeReady"),
|
|
538
|
+
object: collectionView
|
|
539
|
+
)
|
|
540
|
+
}
|
|
541
|
+
|
|
530
542
|
override func didMoveToWindow() {
|
|
531
543
|
super.didMoveToWindow()
|
|
532
544
|
updateTopScrollEdge()
|
|
533
545
|
updateSectionIndexAttachment()
|
|
546
|
+
notifyPagerScrollViewReadyIfNeeded()
|
|
534
547
|
}
|
|
535
548
|
|
|
536
549
|
override func layoutSubviews() {
|
|
550
|
+
let hadUsableBounds = (lastLayoutSize?.width ?? 0) > 0 && (lastLayoutSize?.height ?? 0) > 0
|
|
537
551
|
super.layoutSubviews()
|
|
538
552
|
topOverlayHost.frame = CGRect(x: 0, y: 0, width: collectionView.bounds.width,
|
|
539
553
|
height: requestedTopOverlayHeight)
|
|
@@ -550,6 +564,9 @@ final class NativeListView: UIView {
|
|
|
550
564
|
}
|
|
551
565
|
performPendingScrollIfNeeded()
|
|
552
566
|
layoutContainerSlots()
|
|
567
|
+
if !hadUsableBounds && collectionView.bounds.width > 0 && collectionView.bounds.height > 0 {
|
|
568
|
+
notifyPagerScrollViewReadyIfNeeded()
|
|
569
|
+
}
|
|
553
570
|
}
|
|
554
571
|
|
|
555
572
|
// A layout-direction change may arrive without a layout pass (semantic attribute or trait).
|
|
@@ -630,6 +647,7 @@ final class NativeListView: UIView {
|
|
|
630
647
|
dataSource.apply(snapshot, animatingDifferences: false) { [weak self] in
|
|
631
648
|
guard let self else { return }
|
|
632
649
|
self.collectionView.layoutIfNeeded()
|
|
650
|
+
self.notifyPagerScrollViewReadyIfNeeded()
|
|
633
651
|
self.performPendingScrollIfNeeded()
|
|
634
652
|
self.emitVisibleRangeIfNeeded()
|
|
635
653
|
self.checkEndReached()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-native-list",
|
|
3
|
-
"version": "6.7.0-alpha.
|
|
3
|
+
"version": "6.7.0-alpha.374",
|
|
4
4
|
"description": "Template-driven native RecyclerView and UICollectionView for React Native",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"typescript": "^5.9.2"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
|
-
"@onekeyfe/react-native-image": "6.7.0-alpha.
|
|
90
|
-
"@onekeyfe/react-native-native-logger": "6.7.0-alpha.
|
|
89
|
+
"@onekeyfe/react-native-image": "6.7.0-alpha.374",
|
|
90
|
+
"@onekeyfe/react-native-native-logger": "6.7.0-alpha.374",
|
|
91
91
|
"react": "*",
|
|
92
92
|
"react-native": "*",
|
|
93
93
|
"react-native-nitro-modules": "0.37.0"
|