@onekeyfe/react-native-native-list 3.0.111 → 3.0.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListRowView.kt +543 -26
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +26 -2
- package/ios/NativeListCell.swift +504 -20
- package/ios/NativeListDesignAssets.swift +8 -0
- package/ios/RNCNativeListView.swift +85 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +1 -0
- package/lib/module/validation.js +129 -1
- package/lib/module/web/NativeListWebEngine.js +357 -5
- package/lib/typescript/src/models.d.ts +82 -2
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +26 -1
- package/package.json +2 -2
- package/src/models.ts +121 -3
- package/src/validation.ts +206 -0
- package/src/web/NativeListWebEngine.ts +578 -4
|
@@ -87,6 +87,8 @@ class NativeListView(
|
|
|
87
87
|
var onVisibleRangeChanged: ((String) -> Unit)? = null
|
|
88
88
|
private val density = resources.displayMetrics.density
|
|
89
89
|
private val recyclerView = RecyclerView(context)
|
|
90
|
+
private var configuredTopPaddingPx = 0
|
|
91
|
+
private var configuredBottomPaddingPx = 0
|
|
90
92
|
private val refreshLayout = SwipeRefreshLayout(context)
|
|
91
93
|
private val contentContainer = FrameLayout(context)
|
|
92
94
|
private val adapter = NativeListAdapter(reactContext)
|
|
@@ -318,6 +320,18 @@ class NativeListView(
|
|
|
318
320
|
}
|
|
319
321
|
return
|
|
320
322
|
}
|
|
323
|
+
// Keep the first Market row at its current pixel offset when it is
|
|
324
|
+
// reordered. RecyclerView otherwise follows the previous first key.
|
|
325
|
+
val marketStartOffset = if (
|
|
326
|
+
previous?.items?.firstOrNull()?.type == "market" &&
|
|
327
|
+
next.items.firstOrNull()?.type == "market" &&
|
|
328
|
+
previous.items.firstOrNull()?.key != next.items.firstOrNull()?.key &&
|
|
329
|
+
layoutManager.findFirstVisibleItemPosition() == 0
|
|
330
|
+
) {
|
|
331
|
+
layoutManager.findViewByPosition(0)?.let {
|
|
332
|
+
layoutManager.getDecoratedTop(it) - recyclerView.paddingTop
|
|
333
|
+
}
|
|
334
|
+
} else null
|
|
321
335
|
config = next
|
|
322
336
|
usesSelectorSourceScale = next.items.any { it.usesSelectorSourceScale }
|
|
323
337
|
adapter.usesSelectorSourceScale = usesSelectorSourceScale
|
|
@@ -330,6 +344,9 @@ class NativeListView(
|
|
|
330
344
|
configureSectionIndex(next)
|
|
331
345
|
updateLayout(next)
|
|
332
346
|
adapter.submitList(next.items) {
|
|
347
|
+
if (marketStartOffset != null) {
|
|
348
|
+
layoutManager.scrollToPositionWithOffset(0, marketStartOffset)
|
|
349
|
+
}
|
|
333
350
|
relayoutContents()
|
|
334
351
|
performPendingScrollIfNeeded()
|
|
335
352
|
syncSectionIndexToVisibleRows()
|
|
@@ -872,11 +889,17 @@ class NativeListView(
|
|
|
872
889
|
val bottomPadding = next.contentPaddingBottom ?: defaultPadding
|
|
873
890
|
// OneKey patch: the section index overlays rows and keeps only an accessory-safe inset.
|
|
874
891
|
val indexGutter = if (sectionIndexEntries.isEmpty()) 0 else SECTION_INDEX_CONTENT_INSET_DP
|
|
892
|
+
// A native scroll coordinator may add header insets to this RecyclerView.
|
|
893
|
+
// Content/theme snapshots must replace only the padding owned by NativeList.
|
|
894
|
+
val coordinatorTopPadding = (recyclerView.paddingTop - configuredTopPaddingPx).coerceAtLeast(0)
|
|
895
|
+
val coordinatorBottomPadding = (recyclerView.paddingBottom - configuredBottomPaddingPx).coerceAtLeast(0)
|
|
896
|
+
configuredTopPaddingPx = dp(topPadding)
|
|
897
|
+
configuredBottomPaddingPx = dp(bottomPadding)
|
|
875
898
|
recyclerView.setPaddingRelative(
|
|
876
899
|
dp(horizontalPadding),
|
|
877
|
-
|
|
900
|
+
configuredTopPaddingPx + coordinatorTopPadding,
|
|
878
901
|
dp(horizontalPadding + indexGutter),
|
|
879
|
-
|
|
902
|
+
configuredBottomPaddingPx + coordinatorBottomPadding,
|
|
880
903
|
)
|
|
881
904
|
recyclerView.clipToPadding = false
|
|
882
905
|
recyclerView.isVerticalScrollBarEnabled = sectionIndexEntries.isEmpty()
|
|
@@ -1004,6 +1027,7 @@ class NativeListView(
|
|
|
1004
1027
|
updateSelection(NativeSelectionTarget("row", item.key), item.key)
|
|
1005
1028
|
} else {
|
|
1006
1029
|
val actionKey = when {
|
|
1030
|
+
item.type == "market" && item.json.optString("pressActionKey").isNotEmpty() -> item.json.optString("pressActionKey")
|
|
1007
1031
|
item.type == "action" -> item.json.optString("actionKey")
|
|
1008
1032
|
item.type == "system" && item.json.optString("variant") == "retry" -> item.json.optString("actionKey")
|
|
1009
1033
|
else -> "press"
|