@onekeyfe/react-native-native-list 6.7.0-2 → 6.7.0-21
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 +14 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +245 -9
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +35 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +147 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +51 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
- package/docs/ROW_TEMPLATES.md +70 -11
- package/docs/SPEC.md +1235 -20
- package/docs/STYLE_SPEC.md +6 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +235 -39
- package/ios/NativeListActivityDetailsView.swift +30 -11
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +155 -27
- package/ios/NativeListDesignAssets.swift +9 -0
- package/ios/NativeListIdentityRenderer.swift +239 -31
- package/ios/NativeListLeadingVisual.swift +119 -22
- package/ios/NativeListMarketRenderer.swift +113 -18
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListModels.swift +42 -2
- package/ios/NativeListRendererRegistry.swift +1 -0
- package/ios/NativeListResolvedText.swift +2 -1
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +88 -0
- package/ios/RNCNativeListView.swift +1052 -58
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/icon.svg +1 -0
- package/ios/tests/NativeListAccessoryStackTests.swift +89 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
- package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
- package/ios/tests/NativeListLifecycleTests.swift +2789 -3
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/lib/module/NativeList.js +223 -36
- package/lib/module/NativeList.web.js +260 -33
- package/lib/module/index.js +1 -1
- package/lib/module/models.js +3 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +1386 -81
- package/lib/module/web/NativeListWebEngine.js +914 -80
- package/lib/module/web/templates/ActivityRowRenderer.js +487 -7
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +40 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +145 -5
- package/lib/module/web/templates/MarketRowRenderer.js +8 -3
- package/lib/module/web/templates/MarketTableRowRenderer.js +577 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
- package/lib/module/web/templates/MessageRowRenderer.js +18 -2
- package/lib/module/web/templates/RowContainerStyle.js +1 -0
- package/lib/module/web/templates/RowRendererRegistry.js +8 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +70 -3
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/lib/typescript/src/NativeList.d.ts +3 -3
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
- package/lib/typescript/src/NativeList.types.d.ts +29 -1
- package/lib/typescript/src/NativeList.web.d.ts +2 -2
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +196 -17
- package/lib/typescript/src/validation.d.ts +20 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +58 -1
- package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
- package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +10 -4
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/package.json +3 -3
- package/react-native-native-list.podspec +1 -0
- package/src/NativeList.nitro.ts +2 -0
- package/src/NativeList.tsx +418 -89
- package/src/NativeList.types.ts +34 -1
- package/src/NativeList.web.tsx +417 -66
- package/src/index.ts +2 -0
- package/src/models.ts +355 -143
- package/src/selection.ts +1 -0
- package/src/validation.ts +3315 -166
- package/src/web/NativeListWebEngine.ts +1473 -113
- package/src/web/templates/ActivityRowRenderer.ts +732 -8
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +217 -6
- package/src/web/templates/MarketRowRenderer.ts +19 -3
- package/src/web/templates/MarketTableRowRenderer.ts +755 -0
- package/src/web/templates/MediaTileRowRenderer.ts +313 -5
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +21 -6
- package/src/web/templates/SectionHeaderRowRenderer.ts +89 -5
|
@@ -4,6 +4,7 @@ import org.json.JSONArray
|
|
|
4
4
|
import org.json.JSONObject
|
|
5
5
|
import java.nio.ByteBuffer
|
|
6
6
|
import java.security.MessageDigest
|
|
7
|
+
import kotlin.math.roundToInt
|
|
7
8
|
import java.util.Locale
|
|
8
9
|
|
|
9
10
|
internal data class NativeSelectionTarget(val scope: String, val key: String?)
|
|
@@ -13,7 +14,7 @@ internal fun isNativeListRowPressEnabled(
|
|
|
13
14
|
variant: String,
|
|
14
15
|
disabled: Boolean,
|
|
15
16
|
pressDisabled: Boolean,
|
|
16
|
-
): Boolean = !disabled && !pressDisabled && (type != "system" || variant == "retry")
|
|
17
|
+
): Boolean = !disabled && !pressDisabled && type != "buttonGroup" && (type != "system" || variant == "retry")
|
|
17
18
|
|
|
18
19
|
internal fun isNativeListWholeRowInteractive(
|
|
19
20
|
type: String,
|
|
@@ -27,6 +28,118 @@ internal fun isNativeListWholeRowInteractive(
|
|
|
27
28
|
pressDisabled = pressDisabled,
|
|
28
29
|
)
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* A trailing text accessory (value, value pair, progress, radio, switch) owns its
|
|
33
|
+
* tap only when it carries an action key; otherwise the touch belongs to the row
|
|
34
|
+
* press, so a value such as a network balance is part of the row's hit area.
|
|
35
|
+
*/
|
|
36
|
+
internal fun isNativeListTrailingTextClickable(actionKey: String?): Boolean = !actionKey.isNullOrEmpty()
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A leading visual lays these badges past its own frame: the token network image
|
|
40
|
+
* with its backdrop, a `cornerIcon`, and every overlay (their default offset
|
|
41
|
+
* already overhangs; iOS stops clipping for the same descriptors). Android clips
|
|
42
|
+
* a child to its own bounds whenever its parent clips children, so the host row
|
|
43
|
+
* must stop clipping, or the badge is cut flat (OK-65694).
|
|
44
|
+
*/
|
|
45
|
+
internal fun nativeListLeadingVisualOverhangsFrame(
|
|
46
|
+
kind: String,
|
|
47
|
+
sourceCount: Int,
|
|
48
|
+
hasCornerIcon: Boolean,
|
|
49
|
+
overlayCount: Int,
|
|
50
|
+
): Boolean = kind == "token" && sourceCount > 1 || hasCornerIcon || overlayCount > 0
|
|
51
|
+
|
|
52
|
+
/**
|
|
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.
|
|
62
|
+
*/
|
|
63
|
+
internal fun nativeListActivityHostClips(leadingOverhangs: Boolean): Boolean = !leadingOverhangs
|
|
64
|
+
|
|
65
|
+
internal data class NativeListSlotFrame(val x: Int, val y: Int, val width: Int, val height: Int)
|
|
66
|
+
|
|
67
|
+
/** Side of one member of an Activity token pair inside a [frame]-unit box (24 in 40). */
|
|
68
|
+
internal fun nativeListLeadingPairMemberSize(frame: Int): Int = (frame * 0.6f).roundToInt()
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Frame of image source [index] of a leading visual inside its [width]×[height]
|
|
72
|
+
* box (SPEC "Activity leading pair", OK-66071). [networkIndex] is the token
|
|
73
|
+
* `networkImage` badge and [pairIndex] the Activity `secondaryLeading` token;
|
|
74
|
+
* either is null when absent. A pair draws the primary at the top-left and the
|
|
75
|
+
* secondary at the bottom-right, both [nativeListLeadingPairMemberSize] wide and
|
|
76
|
+
* the secondary inset by its [pairRing]; the badge keeps its corner geometry
|
|
77
|
+
* above them. A lone token, or a token with only a badge, fills the box. Any
|
|
78
|
+
* other multi-source visual (stackedImages) steps 0.72-sized images diagonally.
|
|
79
|
+
*/
|
|
80
|
+
internal fun nativeListLeadingSlotFrame(
|
|
81
|
+
index: Int,
|
|
82
|
+
sourceCount: Int,
|
|
83
|
+
networkIndex: Int?,
|
|
84
|
+
pairIndex: Int?,
|
|
85
|
+
width: Int,
|
|
86
|
+
height: Int,
|
|
87
|
+
badgeSize: Int,
|
|
88
|
+
badgeOverhang: Int,
|
|
89
|
+
pairRing: Int,
|
|
90
|
+
): NativeListSlotFrame {
|
|
91
|
+
if (index == networkIndex)
|
|
92
|
+
return NativeListSlotFrame(
|
|
93
|
+
width - badgeSize + badgeOverhang,
|
|
94
|
+
height - badgeSize + badgeOverhang,
|
|
95
|
+
badgeSize,
|
|
96
|
+
badgeSize,
|
|
97
|
+
)
|
|
98
|
+
if (pairIndex != null) {
|
|
99
|
+
val member = nativeListLeadingPairMemberSize(height)
|
|
100
|
+
return if (index == pairIndex)
|
|
101
|
+
NativeListSlotFrame(width - member - pairRing, height - member - pairRing, member, member)
|
|
102
|
+
else NativeListSlotFrame(0, 0, member, member)
|
|
103
|
+
}
|
|
104
|
+
if (sourceCount == 1 || networkIndex != null) return NativeListSlotFrame(0, 0, width, height)
|
|
105
|
+
val side = (height * 0.72f).roundToInt()
|
|
106
|
+
val x = (index * (width - side).toFloat() / maxOf(1, sourceCount - 1)).roundToInt()
|
|
107
|
+
return NativeListSlotFrame(x, (height - side) / 2, side, side)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
internal data class NativeListTrailingDescriptor(
|
|
111
|
+
val kind: String,
|
|
112
|
+
val name: String = "",
|
|
113
|
+
val actionKey: String = "",
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Identity trailing accessories stack vertically unless they form one of the
|
|
118
|
+
* pairs every platform lays out side by side. The `valuePair` + `DotVerSolid`
|
|
119
|
+
* menu icon pair (the Swap token selector's balance and row menu) matches
|
|
120
|
+
* iOS `configureTrailingStack`; stacking it put the menu under the balance and
|
|
121
|
+
* clipped both inside the fixed row height on Android only.
|
|
122
|
+
*/
|
|
123
|
+
internal fun nativeListIdentityTrailingIsHorizontal(
|
|
124
|
+
accessories: List<NativeListTrailingDescriptor>,
|
|
125
|
+
): Boolean {
|
|
126
|
+
val kinds = accessories.map { it.kind }
|
|
127
|
+
if (kinds.containsAll(listOf("value", "checkbox"))) return true
|
|
128
|
+
if (accessories.size != 2) return false
|
|
129
|
+
val (first, second) = accessories
|
|
130
|
+
return kinds == listOf("valuePair", "menu") ||
|
|
131
|
+
kinds == listOf("valuePair", "chevron") ||
|
|
132
|
+
(kinds == listOf("valuePair", "icon") &&
|
|
133
|
+
second.name == "DotVerSolid" &&
|
|
134
|
+
second.actionKey == "menu") ||
|
|
135
|
+
(kinds == listOf("icon", "chevron") &&
|
|
136
|
+
first.name == "RefreshCcwOutline" &&
|
|
137
|
+
first.actionKey.isEmpty()) ||
|
|
138
|
+
(kinds == listOf("icon", "icon") &&
|
|
139
|
+
first.name == "PencilOutline" &&
|
|
140
|
+
second.name == "DragOutline")
|
|
141
|
+
}
|
|
142
|
+
|
|
30
143
|
internal fun resolveNativeListSelectorBackgroundColor(
|
|
31
144
|
rowType: String,
|
|
32
145
|
styleBackgroundColor: String?,
|
|
@@ -57,7 +170,7 @@ private fun updateLengthPrefixed(digest: MessageDigest, value: String) {
|
|
|
57
170
|
}
|
|
58
171
|
|
|
59
172
|
// 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 }
|
|
173
|
+
internal enum class NativeListRendererKey { MESSAGE, RAIL, MEDIA_TILE, ACTION, SYSTEM, ACTIVITY, DATA_ROW, METRIC_CARD, MARKET, IDENTITY, SECTION_HEADER, WALLET_GROUP, BUTTON_GROUP }
|
|
61
174
|
|
|
62
175
|
internal data class NativeListItem(
|
|
63
176
|
val key: String,
|
|
@@ -142,6 +255,8 @@ internal data class NativeListItem(
|
|
|
142
255
|
|
|
143
256
|
internal data class NativeListConfig(
|
|
144
257
|
val generation: Int,
|
|
258
|
+
val structuralTransition: StructuralTransition?,
|
|
259
|
+
val disclosure: Disclosure?,
|
|
145
260
|
val layout: String,
|
|
146
261
|
val orientation: String,
|
|
147
262
|
val gridColumns: Int,
|
|
@@ -168,9 +283,36 @@ internal data class NativeListConfig(
|
|
|
168
283
|
val fixedFooter: NativeListItem?,
|
|
169
284
|
val items: List<NativeListItem>,
|
|
170
285
|
) {
|
|
286
|
+
internal data class StructuralTransition(
|
|
287
|
+
val id: String,
|
|
288
|
+
val durationMs: Long,
|
|
289
|
+
val anchorKey: String?,
|
|
290
|
+
)
|
|
291
|
+
internal data class Disclosure(
|
|
292
|
+
val expanded: Boolean,
|
|
293
|
+
val expandedTrailingInset: Double,
|
|
294
|
+
)
|
|
171
295
|
companion object {
|
|
172
296
|
fun parse(snapshotJson: String): NativeListConfig {
|
|
173
297
|
val root = JSONObject(snapshotJson)
|
|
298
|
+
val transition = root.optJSONObject("structuralTransition")
|
|
299
|
+
val structuralTransition = transition?.optString("id")?.takeIf(String::isNotEmpty)?.let { id ->
|
|
300
|
+
StructuralTransition(
|
|
301
|
+
id = id,
|
|
302
|
+
durationMs = transition.optDouble("durationMs", 220.0).coerceIn(0.0, 2000.0).toLong(),
|
|
303
|
+
anchorKey = transition.optString("anchorKey").takeIf(String::isNotEmpty),
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
val disclosureJson = root.optJSONObject("disclosure")
|
|
307
|
+
require(!root.has("disclosure") || disclosureJson != null) { "Invalid disclosure" }
|
|
308
|
+
val disclosure = disclosureJson?.let { value ->
|
|
309
|
+
require(value.opt("expanded") is Boolean) { "Invalid disclosure.expanded" }
|
|
310
|
+
require(!value.has("expandedTrailingInset") ||
|
|
311
|
+
value.opt("expandedTrailingInset") is Number) { "Invalid disclosure.expandedTrailingInset" }
|
|
312
|
+
val inset = value.optDouble("expandedTrailingInset", 0.0)
|
|
313
|
+
require(inset.isFinite() && inset >= 0.0) { "Invalid disclosure.expandedTrailingInset" }
|
|
314
|
+
Disclosure(value.getBoolean("expanded"), inset)
|
|
315
|
+
}
|
|
174
316
|
require(root.getInt("schemaVersion") == 1) { "Unsupported schemaVersion" }
|
|
175
317
|
val layout = root.getJSONObject("layout")
|
|
176
318
|
val selection = root.optJSONObject("selection")
|
|
@@ -193,6 +335,8 @@ internal data class NativeListConfig(
|
|
|
193
335
|
val fixedFooter = root.optJSONObject("fixedFooter")?.let(NativeListItem::parse)
|
|
194
336
|
return NativeListConfig(
|
|
195
337
|
generation = root.getInt("generation"),
|
|
338
|
+
structuralTransition = structuralTransition,
|
|
339
|
+
disclosure = disclosure,
|
|
196
340
|
layout = layout.getString("kind"),
|
|
197
341
|
orientation = layout.optString("orientation", "vertical"),
|
|
198
342
|
gridColumns = layout.optInt("gridColumns", 1).coerceIn(1, 7),
|
|
@@ -235,7 +379,9 @@ internal fun mergeRow(original: JSONObject, changes: JSONObject): JSONObject {
|
|
|
235
379
|
val keys = changes.keys()
|
|
236
380
|
while (keys.hasNext()) {
|
|
237
381
|
val key = keys.next()
|
|
238
|
-
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
|
+
}
|
|
239
385
|
}
|
|
240
386
|
return result
|
|
241
387
|
}
|
|
@@ -240,6 +240,9 @@ internal class OneKeyIconView(context: android.content.Context) : View(context)
|
|
|
240
240
|
private val selectorIconColors: Map<String, List<Int?>> =
|
|
241
241
|
mapOf(
|
|
242
242
|
"GlobusOutline" to listOf(null),
|
|
243
|
+
"GasSolid" to listOf(null),
|
|
244
|
+
"RefreshCcwOutline" to listOf(null),
|
|
245
|
+
"CryptoCoinOutline" to listOf(null, null),
|
|
243
246
|
"LockSolid" to listOf(null),
|
|
244
247
|
"GoogleIllus" to
|
|
245
248
|
listOf(
|
|
@@ -267,6 +270,9 @@ internal class OneKeyIconView(context: android.content.Context) : View(context)
|
|
|
267
270
|
private val selectorIconViewBoxes =
|
|
268
271
|
mapOf(
|
|
269
272
|
"GlobusOutline" to 24f,
|
|
273
|
+
"GasSolid" to 24f,
|
|
274
|
+
"RefreshCcwOutline" to 24f,
|
|
275
|
+
"CryptoCoinOutline" to 24f,
|
|
270
276
|
"LockSolid" to 24f,
|
|
271
277
|
"GoogleIllus" to 24f,
|
|
272
278
|
"AppleBrand" to 16f,
|
|
@@ -281,7 +287,16 @@ internal class OneKeyIconView(context: android.content.Context) : View(context)
|
|
|
281
287
|
// use EVEN_ODD. Other existing icons retain their prior rendering behavior.
|
|
282
288
|
private val actionIconFillTypes =
|
|
283
289
|
mapOf(
|
|
290
|
+
// Asset-list icons the app passes by name (OK-66072 audit): absent entries drew nothing.
|
|
291
|
+
"DotVerSolid" to listOf(Path.FillType.WINDING),
|
|
292
|
+
"Document2Outline" to listOf(Path.FillType.WINDING, Path.FillType.EVEN_ODD),
|
|
293
|
+
"WalletOutline" to listOf(Path.FillType.WINDING, Path.FillType.EVEN_ODD),
|
|
294
|
+
"PlusLargeOutline" to listOf(Path.FillType.WINDING),
|
|
295
|
+
"TicketOutline" to listOf(Path.FillType.WINDING, Path.FillType.EVEN_ODD),
|
|
284
296
|
"GlobusOutline" to listOf(Path.FillType.EVEN_ODD),
|
|
297
|
+
"GasSolid" to listOf(Path.FillType.EVEN_ODD),
|
|
298
|
+
"RefreshCcwOutline" to listOf(Path.FillType.WINDING),
|
|
299
|
+
"CryptoCoinOutline" to listOf(Path.FillType.WINDING, Path.FillType.EVEN_ODD),
|
|
285
300
|
"LockSolid" to listOf(Path.FillType.EVEN_ODD),
|
|
286
301
|
"GoogleIllus" to
|
|
287
302
|
listOf(
|
|
@@ -324,6 +339,42 @@ internal class OneKeyIconView(context: android.content.Context) : View(context)
|
|
|
324
339
|
// Exact 24x24 paths from app-monorepo packages/components Icon sources.
|
|
325
340
|
private val iconPaths =
|
|
326
341
|
mapOf(
|
|
342
|
+
"DotVerSolid" to
|
|
343
|
+
listOf(
|
|
344
|
+
"M14 18v4h-4v-4zm0-4h-4v-4h4zm0-8h-4V2h4z"
|
|
345
|
+
),
|
|
346
|
+
"Document2Outline" to
|
|
347
|
+
listOf(
|
|
348
|
+
"M12 16H8v-2h4zm4-4H8v-2h8zm0-4H8V6h8z",
|
|
349
|
+
"M20 22H4V2h16zM6 20h12V4H6z"
|
|
350
|
+
),
|
|
351
|
+
"WalletOutline" to
|
|
352
|
+
listOf(
|
|
353
|
+
"M15.5 13.25a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5",
|
|
354
|
+
"M17 8h4v13H7a4 4 0 0 1-4-4V6.5A3.5 3.5 0 0 1 6.5 3H17zM5 17a2 2 0 0 0 2 2h12v-9H6.5c-.537 0-1.045-.12-1.5-.337zM6.5 5a1.5 1.5 0 1 0 0 3H15V5z"
|
|
355
|
+
),
|
|
356
|
+
"PlusLargeOutline" to
|
|
357
|
+
listOf(
|
|
358
|
+
"M13 11h8v2h-8v8h-2v-8H3v-2h8V3h2z"
|
|
359
|
+
),
|
|
360
|
+
"TicketOutline" to
|
|
361
|
+
listOf(
|
|
362
|
+
"M16 17.01h-2V15h2zm0-4h-2V11h2zm0-4h-2V7h2z",
|
|
363
|
+
"m22 9.927-.629.252c-1.661.665-1.661 2.977 0 3.642l.629.252V20H2v-5.927l.629-.252c1.661-.665 1.661-2.977 0-3.642L2 9.927V4h20zM4 8.636c2.5 1.52 2.499 5.207 0 6.727V18h16v-2.637c-2.499-1.52-2.5-5.208 0-6.727V6H4z"
|
|
364
|
+
),
|
|
365
|
+
"RefreshCcwOutline" to
|
|
366
|
+
listOf(
|
|
367
|
+
"M5 12a7 7 0 0 0 7 7 7.15 7.15 0 0 0 4.955-2h-2.943v-2h6v6h-2v-2.257A9.148 9.148 0 0 1 12 21a9 9 0 0 1-9-9v-1h2v1Zm1-6.754A9.148 9.148 0 0 1 12 3a9 9 0 0 1 9 9v1h-2v-1a7 7 0 0 0-7-7 7.15 7.15 0 0 0-4.955 2H10v2H4V3h2v2.246Z"
|
|
368
|
+
),
|
|
369
|
+
"GasSolid" to
|
|
370
|
+
listOf(
|
|
371
|
+
"M15 9h4v7h1V8.414L17.586 6 19 4.586l3 3V18h-5v-7h-2v8h1v2H2v-2h1V3h12zM6 9v2h6V9z"
|
|
372
|
+
),
|
|
373
|
+
"CryptoCoinOutline" to
|
|
374
|
+
listOf(
|
|
375
|
+
"M11 16.387a4.5 4.5 0 0 1 0-8.775V6h2v1.613a4.5 4.5 0 0 1 2.856 2.067l-1.712 1.032a2.5 2.5 0 1 0 0 2.576l1.712 1.032A4.5 4.5 0 0 1 13 16.386V18h-2z",
|
|
376
|
+
"M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10m-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0",
|
|
377
|
+
),
|
|
327
378
|
// OneKey patch: official selector SVG path geometry.
|
|
328
379
|
"GlobusOutline" to
|
|
329
380
|
listOf(
|
|
@@ -17,6 +17,7 @@ internal object NativeListRendererRegistry {
|
|
|
17
17
|
NativeListRendererKey.ACTIVITY to ::NativeListActivityRowView,
|
|
18
18
|
NativeListRendererKey.SYSTEM to ::NativeListSystemRowView,
|
|
19
19
|
NativeListRendererKey.ACTION to ::NativeListActionRowView,
|
|
20
|
+
NativeListRendererKey.BUTTON_GROUP to ::NativeListButtonGroupRowView,
|
|
20
21
|
)
|
|
21
22
|
|
|
22
23
|
private val keys =
|
|
@@ -33,6 +34,7 @@ internal object NativeListRendererRegistry {
|
|
|
33
34
|
"activity" to NativeListRendererKey.ACTIVITY,
|
|
34
35
|
"system" to NativeListRendererKey.SYSTEM,
|
|
35
36
|
"action" to NativeListRendererKey.ACTION,
|
|
37
|
+
"buttonGroup" to NativeListRendererKey.BUTTON_GROUP,
|
|
36
38
|
)
|
|
37
39
|
|
|
38
40
|
fun key(type: String) = keys.getValue(type)
|
|
@@ -106,6 +106,8 @@ internal abstract class NativeListRendererRowView(protected val reactContext: Th
|
|
|
106
106
|
protected open val pressedColorName = "rowPressedBackground"
|
|
107
107
|
protected open val pressedColorFallback = "#00000017"
|
|
108
108
|
private var current: NativeListItem? = null
|
|
109
|
+
protected val boundItem: NativeListItem?
|
|
110
|
+
get() = current
|
|
109
111
|
private var theme: JSONObject? = null
|
|
110
112
|
private var listLayout = "linear"
|
|
111
113
|
private var itemIndex: Int? = null
|
|
@@ -52,7 +52,7 @@ internal data class NativeListResolvedText(
|
|
|
52
52
|
view.letterSpacing = 0f
|
|
53
53
|
view.gravity = gravity
|
|
54
54
|
view.opticalOffsetY = offset
|
|
55
|
-
view.maxLines = lines
|
|
55
|
+
view.maxLines = if (lines == 0) Int.MAX_VALUE else lines
|
|
56
56
|
view.setHorizontallyScrolling(lines == 1 && explicitTruncation)
|
|
57
57
|
view.ellipsize = if (explicitTruncation && !clip) TextUtils.TruncateAt.END else null
|
|
58
58
|
view.setLineSpacing(0f, 1f)
|
|
@@ -87,7 +87,8 @@ internal data class NativeListResolvedText(
|
|
|
87
87
|
sourceScale: Boolean,
|
|
88
88
|
): NativeListResolvedText {
|
|
89
89
|
val density = context.resources.displayMetrics.density
|
|
90
|
-
val
|
|
90
|
+
val requestedLines = style?.optInt("lines", lines) ?: lines
|
|
91
|
+
val maxLines = if (requestedLines == 0) 0 else requestedLines.coerceIn(1, 3)
|
|
91
92
|
val truncation = style?.let { it.has("lines") || it.has("truncate") } == true
|
|
92
93
|
val fontSize =
|
|
93
94
|
if (style?.has("fontSize") == true) (style.optDouble("fontSize") * density).toFloat()
|
|
@@ -26,6 +26,7 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
26
26
|
private val mainColumn = LinearLayout(context)
|
|
27
27
|
private val titleLine = PackedTitleLineLayout(context)
|
|
28
28
|
private val title = DottedUnderlineTextView(context)
|
|
29
|
+
private val leadingBadge = NativeListTextView(context)
|
|
29
30
|
private val titleSpinner = ProgressBar(context, null, android.R.attr.progressBarStyleSmall).apply {
|
|
30
31
|
isIndeterminate = true
|
|
31
32
|
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
|
|
@@ -165,6 +166,12 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
165
166
|
currentTheme = theme
|
|
166
167
|
currentLayout = layout
|
|
167
168
|
removeAllViews()
|
|
169
|
+
if (trailingViews[0].parent === titleLine) {
|
|
170
|
+
titleLine.removeView(trailingViews[0])
|
|
171
|
+
trailingColumn.addView(trailingViews[0], 0)
|
|
172
|
+
}
|
|
173
|
+
titleLine.removeView(leadingBadge)
|
|
174
|
+
leadingBadge.text = ""
|
|
168
175
|
titleLine.removeView(headerTitleIcon)
|
|
169
176
|
trailingColumn.removeView(headerValueIcon)
|
|
170
177
|
paintDefaults.forEach { (view, flags) -> view.paintFlags = flags }
|
|
@@ -188,6 +195,10 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
188
195
|
view.ellipsize = null
|
|
189
196
|
view.setHorizontallyScrolling(false)
|
|
190
197
|
view.opticalOffsetY = 0f
|
|
198
|
+
view.helpBindingGeneration += 1
|
|
199
|
+
view.guardsHelpTouches = false
|
|
200
|
+
view.primaryHelpOnly = false
|
|
201
|
+
view.showsHelpUnderline = false
|
|
191
202
|
view.gravity = Gravity.START
|
|
192
203
|
view.letterSpacing = 0f
|
|
193
204
|
view.fontFeatureSettings = "tnum"
|
|
@@ -291,6 +302,7 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
291
302
|
}
|
|
292
303
|
}
|
|
293
304
|
applyTextStyle(item)
|
|
305
|
+
bindPositionHeaderFields(item, theme)
|
|
294
306
|
titleSpinner.indeterminateTintList = ColorStateList.valueOf(title.currentTextColor)
|
|
295
307
|
style
|
|
296
308
|
.optJSONObject("container")
|
|
@@ -307,6 +319,57 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
307
319
|
applySelectorTypography(item)
|
|
308
320
|
}
|
|
309
321
|
|
|
322
|
+
private fun bindPositionHeaderFields(item: NativeListItem, theme: JSONObject?) {
|
|
323
|
+
val style = item.json.optJSONObject("style") ?: JSONObject()
|
|
324
|
+
item.json.optJSONObject("leadingBadge")?.let { badge ->
|
|
325
|
+
leadingBadge.text = badge.optString("text")
|
|
326
|
+
leadingBadge.textSize = sp(12f)
|
|
327
|
+
leadingBadge.typeface = fonts.medium(context)
|
|
328
|
+
leadingBadge.includeFontPadding = false
|
|
329
|
+
val tones = mapOf("info" to ("info" to "#0F69F6"), "success" to ("positive" to "#008F5A"), "warning" to ("caution" to "#A35E00"), "danger" to ("negative" to "#CE2C31"))
|
|
330
|
+
val tone = tones[badge.optString("tone")]
|
|
331
|
+
if (tone != null) {
|
|
332
|
+
val tint = color(theme, tone.first, tone.second)
|
|
333
|
+
leadingBadge.setTextColor(tint)
|
|
334
|
+
val fallback = (tint and 0x00FFFFFF) or (31 shl 24)
|
|
335
|
+
val fill = if (badge.optString("tone") == "success" && theme?.has("successBackground") == true)
|
|
336
|
+
safeColor(theme.optString("successBackground"), fallback) else fallback
|
|
337
|
+
leadingBadge.background = roundedFill(fill, 4f)
|
|
338
|
+
} else {
|
|
339
|
+
leadingBadge.setTextColor(color(theme, "secondaryText", "#0000009B"))
|
|
340
|
+
leadingBadge.background = roundedFill(color(theme, "strongBackground", "#0000000F"), 4f)
|
|
341
|
+
}
|
|
342
|
+
leadingBadge.setPadding(dp(8), dp(2), dp(8), dp(2))
|
|
343
|
+
TextViewCompat.setLineHeight(leadingBadge, dp(16))
|
|
344
|
+
titleLine.addView(leadingBadge, 0, LayoutParams(LayoutParams.WRAP_CONTENT, dp(20)).apply { marginEnd = dp(8) })
|
|
345
|
+
}
|
|
346
|
+
if (style.has("titleDecoration")) {
|
|
347
|
+
title.showsDottedUnderline = false
|
|
348
|
+
title.showsHelpUnderline = style.optString("titleDecoration") == "dashed"
|
|
349
|
+
title.setPadding(0, 0, 0, if (title.showsHelpUnderline) dp(3) else 0)
|
|
350
|
+
}
|
|
351
|
+
val value = trailingViews[0]
|
|
352
|
+
if (style.optString("valuePlacement") == "afterTitle") {
|
|
353
|
+
trailingColumn.removeView(value)
|
|
354
|
+
title.layoutParams = wrap()
|
|
355
|
+
titleLine.packsChildrenAtStart = false
|
|
356
|
+
titleLine.addView(value, wrap().apply { marginStart = dp(8) })
|
|
357
|
+
}
|
|
358
|
+
item.json.optJSONObject("valueHelp")?.let { help ->
|
|
359
|
+
value.guardsHelpTouches = true
|
|
360
|
+
value.setOnClickListener(null)
|
|
361
|
+
value.isClickable = false
|
|
362
|
+
value.showsHelpUnderline = help.optString("underline") == "dashed"
|
|
363
|
+
if (help.optString("presentation") == "popover") {
|
|
364
|
+
value.setOnClickListener {
|
|
365
|
+
currentItem?.takeUnless { it.json.optBoolean("disabled") }?.let {
|
|
366
|
+
emitAction(it, help.optString("actionKey"), null, value, "trailingAccessory", 0)
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
310
373
|
private fun applyTextStyle(item: NativeListItem) {
|
|
311
374
|
val style = item.json.optJSONObject("style") ?: return
|
|
312
375
|
for ((slot, view) in
|
|
@@ -411,6 +474,12 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
411
474
|
override fun recycleContent() {
|
|
412
475
|
checkboxControl.reset()
|
|
413
476
|
currentItem = null
|
|
477
|
+
title.setOnClickListener(null)
|
|
478
|
+
title.isClickable = false
|
|
479
|
+
trailingViews[0].helpBindingGeneration += 1
|
|
480
|
+
trailingViews[0].setOnClickListener(null)
|
|
481
|
+
trailingViews[0].isClickable = false
|
|
482
|
+
trailingViews[0].showsHelpUnderline = false
|
|
414
483
|
titleSpinner.visibility = GONE
|
|
415
484
|
}
|
|
416
485
|
|
|
@@ -1,9 +1,62 @@
|
|
|
1
1
|
package com.margelo.nitro.nativelist
|
|
2
2
|
|
|
3
3
|
import android.graphics.Canvas
|
|
4
|
+
import android.graphics.DashPathEffect
|
|
5
|
+
import android.graphics.Paint
|
|
6
|
+
import android.graphics.RectF
|
|
7
|
+
import android.view.MotionEvent
|
|
4
8
|
import android.widget.TextView
|
|
5
9
|
|
|
6
10
|
internal open class NativeListTextView(context: android.content.Context) : TextView(context) {
|
|
11
|
+
var helpBindingGeneration = 0
|
|
12
|
+
var guardsHelpTouches = false
|
|
13
|
+
private var helpDownGeneration = -1
|
|
14
|
+
var primaryHelpOnly = false
|
|
15
|
+
var showsHelpUnderline = false
|
|
16
|
+
set(value) { field = value; invalidate() }
|
|
17
|
+
private val helpPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
|
18
|
+
style = Paint.Style.STROKE
|
|
19
|
+
strokeWidth = resources.displayMetrics.density
|
|
20
|
+
pathEffect = DashPathEffect(floatArrayOf(3 * strokeWidth, 2 * strokeWidth), 0f)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
val helpAnchorBounds: RectF?
|
|
24
|
+
get() {
|
|
25
|
+
if (!primaryHelpOnly) return null
|
|
26
|
+
val textLayout = layout ?: return null
|
|
27
|
+
if (textLayout.lineCount == 0) return null
|
|
28
|
+
return RectF(
|
|
29
|
+
totalPaddingLeft + textLayout.getLineLeft(0),
|
|
30
|
+
(totalPaddingTop + textLayout.getLineTop(0)).toFloat() + opticalOffsetY,
|
|
31
|
+
totalPaddingLeft + textLayout.getLineRight(0),
|
|
32
|
+
(totalPaddingTop + textLayout.getLineBottom(0)).toFloat() + opticalOffsetY,
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override fun onTouchEvent(event: MotionEvent): Boolean {
|
|
37
|
+
if (primaryHelpOnly && event.actionMasked == MotionEvent.ACTION_DOWN &&
|
|
38
|
+
helpAnchorBounds?.contains(event.x, event.y) != true) return false
|
|
39
|
+
if (guardsHelpTouches) {
|
|
40
|
+
if (event.actionMasked == MotionEvent.ACTION_DOWN) helpDownGeneration = helpBindingGeneration
|
|
41
|
+
if (event.actionMasked == MotionEvent.ACTION_UP && helpDownGeneration != helpBindingGeneration) {
|
|
42
|
+
isPressed = false
|
|
43
|
+
return true
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return super.onTouchEvent(event)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private fun drawHelpUnderline(canvas: Canvas) {
|
|
50
|
+
if (!showsHelpUnderline) return
|
|
51
|
+
val textLayout = layout ?: return
|
|
52
|
+
if (textLayout.lineCount == 0) return
|
|
53
|
+
helpPaint.color = currentTextColor
|
|
54
|
+
val left = totalPaddingLeft + textLayout.getLineLeft(0)
|
|
55
|
+
val right = totalPaddingLeft + textLayout.getLineRight(0)
|
|
56
|
+
val bottom = totalPaddingTop + textLayout.getLineBottom(0) - resources.displayMetrics.density
|
|
57
|
+
canvas.drawLine(left, bottom, right, bottom, helpPaint)
|
|
58
|
+
}
|
|
59
|
+
|
|
7
60
|
var rowHorizontallyScrolling = false
|
|
8
61
|
private set
|
|
9
62
|
|
|
@@ -16,10 +69,11 @@ internal open class NativeListTextView(context: android.content.Context) : TextV
|
|
|
16
69
|
set(value) { field = value; invalidate() }
|
|
17
70
|
|
|
18
71
|
override fun onDraw(canvas: Canvas) {
|
|
19
|
-
if (opticalOffsetY == 0f) { super.onDraw(canvas); return }
|
|
72
|
+
if (opticalOffsetY == 0f) { super.onDraw(canvas); drawHelpUnderline(canvas); return }
|
|
20
73
|
val checkpoint = canvas.save()
|
|
21
74
|
canvas.translate(0f, opticalOffsetY)
|
|
22
75
|
super.onDraw(canvas)
|
|
76
|
+
drawHelpUnderline(canvas)
|
|
23
77
|
canvas.restoreToCount(checkpoint)
|
|
24
78
|
}
|
|
25
79
|
}
|