@onekeyfe/react-native-native-list 6.7.0-3 → 6.7.0-31
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 +4 -0
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +250 -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/NativeListGeneratedIcons.kt +47 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +152 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +1 -1
- 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 +120 -287
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +7 -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 +1170 -13
- package/docs/STYLE_SPEC.md +11 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +237 -51
- package/ios/NativeListActivityDetailsView.swift +30 -11
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +167 -30
- package/ios/NativeListDesignAssets.swift +13 -75
- package/ios/NativeListGeneratedIcons.swift +55 -0
- package/ios/NativeListIconBinding.swift +171 -0
- package/ios/NativeListIdentityRenderer.swift +256 -39
- package/ios/NativeListLeadingVisual.swift +127 -28
- package/ios/NativeListMarketRenderer.swift +120 -31
- package/ios/NativeListMediaPreviewSlot.swift +122 -61
- package/ios/NativeListMediaTileRenderer.swift +7 -3
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListMetricCardRenderer.swift +4 -2
- 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 +100 -4
- package/ios/RNCNativeListView.swift +1052 -58
- package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
- package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -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 +2798 -3
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/ios/tests/NativeListMediaVisibilityTests.swift +26 -1
- package/ios/tests/NativeListSharedIconTests.swift +236 -0
- package/lib/module/NativeList.js +221 -36
- package/lib/module/NativeList.web.js +167 -46
- 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 +1246 -48
- package/lib/module/web/NativeListGeneratedIcons.js +31 -0
- package/lib/module/web/NativeListWebEngine.js +513 -274
- package/lib/module/web/templates/ActivityRowRenderer.js +120 -87
- 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 +158 -6
- package/lib/module/web/templates/MarketTableRowRenderer.js +37 -19
- package/lib/module/web/templates/MediaTileRowRenderer.js +4 -14
- 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 +3 -0
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
- 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 +20 -2
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +126 -17
- package/lib/typescript/src/validation.d.ts +20 -0
- package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +32 -1
- 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/MessageRowRenderer.d.ts +9 -3
- 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 +16 -10
- package/react-native-native-list.podspec +2 -6
- package/scripts/generate-icons.mjs +150 -0
- package/scripts/generate-icons.test.mjs +288 -0
- package/scripts/native-list-icons.json +260 -0
- package/src/NativeList.nitro.ts +2 -0
- package/src/NativeList.tsx +416 -89
- package/src/NativeList.types.ts +24 -2
- package/src/NativeList.web.tsx +295 -89
- package/src/index.ts +2 -0
- package/src/models.ts +263 -144
- package/src/selection.ts +1 -0
- package/src/validation.ts +3013 -152
- package/src/web/NativeListGeneratedIcons.ts +28 -0
- package/src/web/NativeListWebEngine.ts +816 -343
- package/src/web/templates/ActivityRowRenderer.ts +178 -141
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +231 -6
- package/src/web/templates/MarketTableRowRenderer.ts +56 -33
- package/src/web/templates/MediaTileRowRenderer.ts +4 -17
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +11 -1
- package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
- package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
package/README.md
CHANGED
|
@@ -463,3 +463,7 @@ helper directly. These are geometry unit tests, not RecyclerView/UICollectionVie
|
|
|
463
463
|
integration tests. Full-app visibility, unmounted/deferred behavior and
|
|
464
464
|
consumer-owned layout/input cancellation require separate runtime validation;
|
|
465
465
|
see [the scrolling spec](docs/SPEC.md).
|
|
466
|
+
|
|
467
|
+
`webSectionIndexContainerRef` uses the actual View instance type through
|
|
468
|
+
`React.ElementRef<typeof View>`. RN 0.86.2/0.88.0 declaration checks preserve its
|
|
469
|
+
existing nullable ref API without a consumer declaration patch.
|
|
@@ -28,11 +28,19 @@ class HybridNativeList(context: ThemedReactContext) : HybridNativeListSpec() {
|
|
|
28
28
|
set(value) {
|
|
29
29
|
if (field == value) return
|
|
30
30
|
field = value
|
|
31
|
-
|
|
31
|
+
slotHeightsChanged = true
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override var sidecarLayoutJson: String = ""
|
|
35
|
+
set(value) {
|
|
36
|
+
if (field == value) return
|
|
37
|
+
field = value
|
|
38
|
+
dispatchToUi { hostView.setSidecarLayoutJson(value) }
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
private var fontsChanged = false
|
|
35
42
|
private var snapshotChanged = false
|
|
43
|
+
private var slotHeightsChanged = false
|
|
36
44
|
|
|
37
45
|
override var fontFamiliesJson: String = "{}"
|
|
38
46
|
set(value) {
|
|
@@ -44,11 +52,14 @@ class HybridNativeList(context: ThemedReactContext) : HybridNativeListSpec() {
|
|
|
44
52
|
override fun afterUpdate() {
|
|
45
53
|
super.afterUpdate()
|
|
46
54
|
val fonts = if (fontsChanged) fontFamiliesJson else null
|
|
55
|
+
val slotHeights = if (slotHeightsChanged) containerSlotHeightsJson else null
|
|
47
56
|
val snapshot = if (snapshotChanged) snapshotJson else null
|
|
48
57
|
fontsChanged = false
|
|
58
|
+
slotHeightsChanged = false
|
|
49
59
|
snapshotChanged = false
|
|
50
60
|
dispatchToUi {
|
|
51
61
|
fonts?.let { hostView.setFontFamiliesJson(it) }
|
|
62
|
+
slotHeights?.let { hostView.setContainerSlotHeightsJson(it, snapshot) }
|
|
52
63
|
snapshot?.let { hostView.applySnapshot(it) }
|
|
53
64
|
}
|
|
54
65
|
}
|
|
@@ -90,6 +101,8 @@ class HybridNativeList(context: ThemedReactContext) : HybridNativeListSpec() {
|
|
|
90
101
|
set(value) { field = value; hostView.onEndReached = value }
|
|
91
102
|
override var onVisibleRangeChanged: ((payloadJson: String) -> Unit)? = null
|
|
92
103
|
set(value) { field = value; hostView.onVisibleRangeChanged = value }
|
|
104
|
+
override var onStructuralTransitionSettled: ((payloadJson: String) -> Unit)? = null
|
|
105
|
+
set(value) { field = value; hostView.onStructuralTransitionSettled = value }
|
|
93
106
|
|
|
94
107
|
override fun applySnapshot(snapshotJson: String) {
|
|
95
108
|
dispatchToUi { hostView.applySnapshot(snapshotJson) }
|
|
@@ -8,11 +8,14 @@ import android.graphics.drawable.StateListDrawable
|
|
|
8
8
|
import android.text.Spannable
|
|
9
9
|
import android.text.SpannableStringBuilder
|
|
10
10
|
import android.text.TextUtils
|
|
11
|
+
import android.text.TextPaint
|
|
11
12
|
import android.text.style.AbsoluteSizeSpan
|
|
12
13
|
import android.text.style.ForegroundColorSpan
|
|
14
|
+
import android.text.style.MetricAffectingSpan
|
|
13
15
|
import android.util.TypedValue
|
|
14
16
|
import android.view.Gravity
|
|
15
17
|
import android.view.View
|
|
18
|
+
import android.view.MotionEvent
|
|
16
19
|
import android.widget.LinearLayout
|
|
17
20
|
import android.widget.ProgressBar
|
|
18
21
|
import android.widget.TextView
|
|
@@ -29,11 +32,14 @@ import org.json.JSONObject
|
|
|
29
32
|
// Bounded controls only. Event ownership and epochs stay with the row host.
|
|
30
33
|
internal class NativeListAccessoryStack(context: android.content.Context, val fonts: NativeListFonts) : LinearLayout(context) {
|
|
31
34
|
private val trailingViews = List(2) { NativeListTextView(context) }
|
|
35
|
+
private val buttonDownEpochs = IntArray(2) { -1 }
|
|
36
|
+
private var bindingEpoch = 0
|
|
32
37
|
private val trailingIcons = List(2) { OneKeyIconView(context) }
|
|
33
38
|
private val checkbox = OneKeyCheckboxView(context)
|
|
34
39
|
private val spinner = ProgressBar(context)
|
|
35
40
|
private var boundCheckboxData: JSONObject? = null
|
|
36
41
|
private val semanticValueViews = mutableListOf<TextView>()
|
|
42
|
+
private val segmentedValuePairs = mutableMapOf<TextView, JSONObject>()
|
|
37
43
|
private var selectorUsesSourceScale = false
|
|
38
44
|
private var checkboxUsesSelectorStyle = false
|
|
39
45
|
private var checkboxCheckedColor = Color.BLACK
|
|
@@ -66,6 +72,19 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
66
72
|
info.viewIdResourceName = host.getTag(com.facebook.react.R.id.react_test_id) as? String
|
|
67
73
|
}
|
|
68
74
|
}
|
|
75
|
+
private val buttonAccessibilityDelegate =
|
|
76
|
+
object : View.AccessibilityDelegate() {
|
|
77
|
+
override fun onInitializeAccessibilityNodeInfo(
|
|
78
|
+
host: View,
|
|
79
|
+
info: android.view.accessibility.AccessibilityNodeInfo,
|
|
80
|
+
) {
|
|
81
|
+
super.onInitializeAccessibilityNodeInfo(host, info)
|
|
82
|
+
info.className = android.widget.Button::class.java.name
|
|
83
|
+
info.isEnabled = host.isEnabled
|
|
84
|
+
info.isClickable = host.isEnabled && host.isClickable
|
|
85
|
+
info.viewIdResourceName = host.getTag(com.facebook.react.R.id.react_test_id) as? String
|
|
86
|
+
}
|
|
87
|
+
}
|
|
69
88
|
|
|
70
89
|
private val trailingPaintFlags = trailingViews.map { it.paintFlags }
|
|
71
90
|
|
|
@@ -103,6 +122,9 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
103
122
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
|
|
104
123
|
horizontal: Boolean = false,
|
|
105
124
|
) {
|
|
125
|
+
val iconUpdate = NativeListIconUpdate(this)
|
|
126
|
+
try {
|
|
127
|
+
|
|
106
128
|
selectorUsesSourceScale = sourceScale
|
|
107
129
|
reset()
|
|
108
130
|
tag = item
|
|
@@ -130,7 +152,12 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
130
152
|
(checkbox.layoutParams as LayoutParams).marginStart = dp(12)
|
|
131
153
|
for ((index, key) in listOf("value", "valueSecondary").withIndex()) {
|
|
132
154
|
style.optJSONObject(key)?.let { value ->
|
|
133
|
-
semanticValueViews.getOrNull(index)?.let {
|
|
155
|
+
semanticValueViews.getOrNull(index)?.let { view ->
|
|
156
|
+
applyStyledText(view, value)
|
|
157
|
+
if (value.has("fontSize")) segmentedValuePairs[view]?.let { accessory ->
|
|
158
|
+
restorePairSubscriptSizes(view, accessory, value.optDouble("fontSize").toFloat())
|
|
159
|
+
}
|
|
160
|
+
}
|
|
134
161
|
}
|
|
135
162
|
}
|
|
136
163
|
if (style.has("trailingGap")) {
|
|
@@ -146,8 +173,17 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
146
173
|
}
|
|
147
174
|
}
|
|
148
175
|
}
|
|
176
|
+
val pairedChevron = horizontal && (kinds == listOf("valuePair", "chevron") ||
|
|
177
|
+
(kinds == listOf("icon", "chevron") &&
|
|
178
|
+
descriptors.getJSONObject(0).optString("name") == "RefreshCcwOutline" &&
|
|
179
|
+
descriptors.getJSONObject(0).optString("actionKey").isEmpty()))
|
|
180
|
+
if (pairedChevron) {
|
|
181
|
+
(trailingIcons[1].layoutParams as LayoutParams).marginEnd = 0
|
|
182
|
+
}
|
|
149
183
|
visibility =
|
|
150
184
|
if ((0 until childCount).any { getChildAt(it).visibility != GONE }) VISIBLE else GONE
|
|
185
|
+
|
|
186
|
+
} finally { iconUpdate.finish() }
|
|
151
187
|
}
|
|
152
188
|
|
|
153
189
|
fun updateSelection(
|
|
@@ -167,32 +203,53 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
167
203
|
|
|
168
204
|
fun anchorInset(view: View): Int =
|
|
169
205
|
if (
|
|
170
|
-
|
|
171
|
-
view
|
|
172
|
-
(
|
|
206
|
+
view in trailingIcons &&
|
|
207
|
+
(view.layoutParams as MarginLayoutParams).marginStart < 0 &&
|
|
208
|
+
((tag as? NativeListItem)?.json?.optString("presentation") == "accountSelector" ||
|
|
209
|
+
(tag as? NativeListItem)?.json?.optJSONArray("trailing")?.let { trailing ->
|
|
210
|
+
(0 until trailing.length()).any { index ->
|
|
211
|
+
trailing.optJSONObject(index)?.optString("buttonStyle") == "tertiary"
|
|
212
|
+
}
|
|
213
|
+
} == true)
|
|
173
214
|
)
|
|
174
215
|
dp(7)
|
|
175
216
|
else 0
|
|
176
217
|
|
|
177
218
|
fun reset() {
|
|
219
|
+
bindingEpoch += 1
|
|
178
220
|
tag = null
|
|
179
221
|
endInset = null
|
|
180
222
|
requestsUnclippedHost = false
|
|
181
223
|
clipChildren = true
|
|
182
224
|
clipToPadding = true
|
|
183
225
|
semanticValueViews.clear()
|
|
226
|
+
segmentedValuePairs.clear()
|
|
184
227
|
boundCheckboxData = null
|
|
185
228
|
trailingViews.forEachIndexed { index, v ->
|
|
229
|
+
buttonDownEpochs[index] = -1
|
|
186
230
|
v.paintFlags = trailingPaintFlags[index]
|
|
187
231
|
v.visibility = GONE
|
|
188
232
|
v.text = ""
|
|
189
233
|
v.layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
|
|
190
234
|
v.setOnClickListener(null)
|
|
235
|
+
// A clickable value consumes the row press; reset it until an action binds.
|
|
236
|
+
v.setOnTouchListener(null)
|
|
237
|
+
v.isPressed = false
|
|
238
|
+
v.isClickable = false
|
|
239
|
+
v.isEnabled = true
|
|
240
|
+
v.alpha = 1f
|
|
241
|
+
v.contentDescription = null
|
|
242
|
+
v.setTag(com.facebook.react.R.id.react_test_id, null)
|
|
243
|
+
v.accessibilityDelegate = null
|
|
191
244
|
v.background = null
|
|
192
245
|
v.setPadding(0, 0, 0, 0)
|
|
193
246
|
// Legacy trailing text: END gravity, one line, no ellipsis.
|
|
194
247
|
v.gravity = Gravity.END
|
|
195
248
|
v.opticalOffsetY = 0f
|
|
249
|
+
v.helpBindingGeneration += 1
|
|
250
|
+
v.guardsHelpTouches = false
|
|
251
|
+
v.primaryHelpOnly = false
|
|
252
|
+
v.showsHelpUnderline = false
|
|
196
253
|
v.maxLines = 1
|
|
197
254
|
v.setHorizontallyScrolling(false)
|
|
198
255
|
v.ellipsize = null
|
|
@@ -252,6 +309,83 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
252
309
|
for (index in 0 until minOf(2, accessories.length())) {
|
|
253
310
|
val accessory = accessories.getJSONObject(index)
|
|
254
311
|
when (accessory.optString("kind")) {
|
|
312
|
+
"button" -> {
|
|
313
|
+
if (textIndex !in trailingViews.indices) continue
|
|
314
|
+
val view = trailingViews[textIndex]
|
|
315
|
+
val buttonIndex = textIndex
|
|
316
|
+
val epoch = bindingEpoch
|
|
317
|
+
val disabled =
|
|
318
|
+
item.json.optBoolean("disabled", false) || accessory.optBoolean("disabled", false)
|
|
319
|
+
showTrailing(textIndex, accessory.optString("label"), false)
|
|
320
|
+
view.typeface = fonts.medium(context)
|
|
321
|
+
view.gravity = Gravity.CENTER
|
|
322
|
+
view.setTextColor(
|
|
323
|
+
safeColor(
|
|
324
|
+
accessory.optString("textColor").takeIf(String::isNotEmpty),
|
|
325
|
+
color(theme, "primaryText", "#000000DF"),
|
|
326
|
+
)
|
|
327
|
+
)
|
|
328
|
+
view.layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, dp(30))
|
|
329
|
+
view.setPadding(dp(11), dp(4), dp(11), dp(4))
|
|
330
|
+
view.background =
|
|
331
|
+
StateListDrawable().apply {
|
|
332
|
+
fun fill(value: Int) =
|
|
333
|
+
GradientDrawable().apply {
|
|
334
|
+
setColor(value)
|
|
335
|
+
cornerRadius = dp(15).toFloat()
|
|
336
|
+
setStroke(dp(1), Color.TRANSPARENT)
|
|
337
|
+
}
|
|
338
|
+
addState(
|
|
339
|
+
intArrayOf(android.R.attr.state_pressed),
|
|
340
|
+
fill(safeColor(accessory.optString("pressedBackgroundColor").takeIf(String::isNotEmpty),
|
|
341
|
+
color(theme, "rowPressedBackground", "#00000017"))),
|
|
342
|
+
)
|
|
343
|
+
addState(
|
|
344
|
+
intArrayOf(),
|
|
345
|
+
fill(safeColor(accessory.optString("backgroundColor").takeIf(String::isNotEmpty),
|
|
346
|
+
color(theme, "strongBackground", "#0000000F"))),
|
|
347
|
+
)
|
|
348
|
+
}
|
|
349
|
+
view.setTag(
|
|
350
|
+
com.facebook.react.R.id.react_test_id,
|
|
351
|
+
accessory.optString("testID").takeIf(String::isNotEmpty),
|
|
352
|
+
)
|
|
353
|
+
view.accessibilityDelegate = buttonAccessibilityDelegate
|
|
354
|
+
view.contentDescription =
|
|
355
|
+
accessory.optString("accessibilityLabel").ifEmpty { accessory.optString("label") }
|
|
356
|
+
view.isEnabled = !disabled
|
|
357
|
+
view.alpha = if (disabled) 0.4f else 1f
|
|
358
|
+
view.isClickable = true
|
|
359
|
+
view.setOnTouchListener { _, event ->
|
|
360
|
+
when (event.actionMasked) {
|
|
361
|
+
MotionEvent.ACTION_DOWN -> {
|
|
362
|
+
buttonDownEpochs[buttonIndex] = epoch
|
|
363
|
+
false
|
|
364
|
+
}
|
|
365
|
+
MotionEvent.ACTION_UP -> {
|
|
366
|
+
if (buttonDownEpochs[buttonIndex] != bindingEpoch) {
|
|
367
|
+
view.isPressed = false
|
|
368
|
+
true
|
|
369
|
+
} else false
|
|
370
|
+
}
|
|
371
|
+
MotionEvent.ACTION_CANCEL -> {
|
|
372
|
+
buttonDownEpochs[buttonIndex] = -1
|
|
373
|
+
false
|
|
374
|
+
}
|
|
375
|
+
else -> false
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
view.setOnClickListener {
|
|
379
|
+
if (epoch != bindingEpoch) return@setOnClickListener
|
|
380
|
+
(tag as? NativeListItem)?.takeUnless { it.json.optBoolean("disabled", false) }
|
|
381
|
+
?.takeUnless { accessory.optBoolean("disabled", false) }
|
|
382
|
+
?.let {
|
|
383
|
+
emitAction(it, accessory.optString("actionKey"), null, view,
|
|
384
|
+
"trailingAccessory", index)
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
textIndex++
|
|
388
|
+
}
|
|
255
389
|
"value" -> {
|
|
256
390
|
showTrailing(
|
|
257
391
|
textIndex,
|
|
@@ -264,6 +398,21 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
264
398
|
}
|
|
265
399
|
"valuePair" -> {
|
|
266
400
|
showTrailingValuePair(textIndex, accessory, theme)
|
|
401
|
+
accessory.optJSONObject("primaryHelp")?.let { help ->
|
|
402
|
+
val view = trailingViews[textIndex]
|
|
403
|
+
val epoch = bindingEpoch
|
|
404
|
+
view.primaryHelpOnly = true
|
|
405
|
+
view.guardsHelpTouches = true
|
|
406
|
+
view.showsHelpUnderline = help.optString("underline") == "dashed"
|
|
407
|
+
if (help.optString("presentation") == "popover") {
|
|
408
|
+
view.setOnClickListener {
|
|
409
|
+
if (epoch == bindingEpoch && !item.json.optBoolean("disabled")) {
|
|
410
|
+
emitAction(item, help.optString("actionKey"), null, view, "trailingAccessory", index)
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
segmentedValuePairs[trailingViews[textIndex]] = accessory
|
|
267
416
|
semanticValueViews.add(trailingViews[textIndex++])
|
|
268
417
|
}
|
|
269
418
|
"checkbox" -> bindCheckbox(item, accessory, checkboxState)
|
|
@@ -410,19 +559,23 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
410
559
|
TextViewCompat.setLineHeight(view, dp(if (primary) 24 else 20))
|
|
411
560
|
textColor?.let(view::setTextColor)
|
|
412
561
|
view.visibility = VISIBLE
|
|
413
|
-
|
|
562
|
+
val clickActionKey = actionKey?.takeIf(::isNativeListTrailingTextClickable)
|
|
563
|
+
view.isClickable = clickActionKey != null
|
|
564
|
+
if (clickActionKey != null) {
|
|
414
565
|
view.setOnClickListener {
|
|
415
566
|
(tag as? NativeListItem)
|
|
416
567
|
?.takeUnless { item -> item.json.optBoolean("disabled", false) }
|
|
417
|
-
?.let { item -> emitAction(item,
|
|
568
|
+
?.let { item -> emitAction(item, clickActionKey, null, view, "trailingAccessory", index) }
|
|
418
569
|
}
|
|
419
570
|
}
|
|
420
571
|
}
|
|
421
572
|
|
|
422
573
|
private fun showTrailingValuePair(index: Int, accessory: JSONObject, theme: JSONObject?) {
|
|
423
574
|
if (index !in trailingViews.indices) return
|
|
424
|
-
val
|
|
425
|
-
val
|
|
575
|
+
val primarySegments = accessory.optJSONArray("primaryTextSegments")
|
|
576
|
+
val secondarySegments = accessory.optJSONArray("secondaryTextSegments")
|
|
577
|
+
val primary = segmentTextOrFallback(primarySegments, accessory.optString("primary"))
|
|
578
|
+
val secondary = segmentTextOrFallback(secondarySegments, accessory.optString("secondary"))
|
|
426
579
|
if (primary.isEmpty() && secondary.isEmpty()) return
|
|
427
580
|
val value = SpannableStringBuilder()
|
|
428
581
|
val primaryStart = value.length
|
|
@@ -442,6 +595,15 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
442
595
|
value.length,
|
|
443
596
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
|
|
444
597
|
)
|
|
598
|
+
if (primary.isNotEmpty() && accessory.optString("primaryFontWeight") == "medium") {
|
|
599
|
+
value.setSpan(
|
|
600
|
+
ValuePairTypefaceSpan(fonts.medium(context)),
|
|
601
|
+
primaryStart,
|
|
602
|
+
value.length,
|
|
603
|
+
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
|
|
604
|
+
)
|
|
605
|
+
}
|
|
606
|
+
applyPairSubscriptSizes(value, primarySegments, primaryStart, 16f)
|
|
445
607
|
if (primary.isNotEmpty() && secondary.isNotEmpty()) value.append('\n')
|
|
446
608
|
val secondaryStart = value.length
|
|
447
609
|
value.append(secondary)
|
|
@@ -462,6 +624,7 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
462
624
|
value.length,
|
|
463
625
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
|
|
464
626
|
)
|
|
627
|
+
applyPairSubscriptSizes(value, secondarySegments, secondaryStart, 14f)
|
|
465
628
|
val view = trailingViews[index]
|
|
466
629
|
view.text = value
|
|
467
630
|
view.maxLines = 2
|
|
@@ -473,6 +636,48 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
473
636
|
view.visibility = VISIBLE
|
|
474
637
|
}
|
|
475
638
|
|
|
639
|
+
private fun segmentTextOrFallback(segments: JSONArray?, fallback: String): String {
|
|
640
|
+
if (segments == null || segments.length() == 0) return fallback
|
|
641
|
+
return buildString {
|
|
642
|
+
for (index in 0 until segments.length()) append(segments.getJSONObject(index).optString("text"))
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
private fun applyPairSubscriptSizes(
|
|
647
|
+
value: SpannableStringBuilder,
|
|
648
|
+
segments: JSONArray?,
|
|
649
|
+
start: Int,
|
|
650
|
+
baseSize: Float,
|
|
651
|
+
) {
|
|
652
|
+
if (segments == null) return
|
|
653
|
+
var offset = start
|
|
654
|
+
for (index in 0 until segments.length()) {
|
|
655
|
+
val segment = segments.getJSONObject(index)
|
|
656
|
+
val end = offset + segment.optString("text").length
|
|
657
|
+
if (end > offset && segment.optString("style") == "subscript")
|
|
658
|
+
value.setSpan(
|
|
659
|
+
AbsoluteSizeSpan(sp(kotlin.math.ceil(baseSize * 0.6).toFloat()).roundToInt(), true),
|
|
660
|
+
offset,
|
|
661
|
+
end,
|
|
662
|
+
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
|
|
663
|
+
)
|
|
664
|
+
offset = end
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
private fun restorePairSubscriptSizes(view: TextView, accessory: JSONObject, baseSize: Float) {
|
|
669
|
+
val primary = accessory.optJSONArray("primaryTextSegments")
|
|
670
|
+
val secondary = accessory.optJSONArray("secondaryTextSegments")
|
|
671
|
+
if ((primary?.length() ?: 0) == 0 && (secondary?.length() ?: 0) == 0) return
|
|
672
|
+
val value = SpannableStringBuilder(view.text)
|
|
673
|
+
applyPairSubscriptSizes(value, primary, 0, baseSize)
|
|
674
|
+
val primaryText = segmentTextOrFallback(primary, accessory.optString("primary"))
|
|
675
|
+
val secondaryStart = primaryText.length + if (primaryText.isNotEmpty() &&
|
|
676
|
+
segmentTextOrFallback(secondary, accessory.optString("secondary")).isNotEmpty()) 1 else 0
|
|
677
|
+
applyPairSubscriptSizes(value, secondary, secondaryStart, baseSize)
|
|
678
|
+
view.text = value
|
|
679
|
+
}
|
|
680
|
+
|
|
476
681
|
private fun showTrailingMenu(index: Int, actionKey: String) {
|
|
477
682
|
showTrailing(index, "⋮", true, actionKey)
|
|
478
683
|
if (index !in trailingViews.indices) return
|
|
@@ -512,7 +717,26 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
512
717
|
)
|
|
513
718
|
icon.accessibilityDelegate = selectorAccessibilityDelegate
|
|
514
719
|
icon.contentDescription = data.optString("accessibilityLabel").takeIf { it.isNotEmpty() }
|
|
515
|
-
if (
|
|
720
|
+
if (data.optString("buttonStyle") == "tertiary") {
|
|
721
|
+
icon.glyphSizeDp = 24
|
|
722
|
+
icon.layoutParams = LayoutParams(dp(38), dp(38)).apply {
|
|
723
|
+
gravity = Gravity.CENTER_VERTICAL
|
|
724
|
+
marginStart = -dp(7)
|
|
725
|
+
marginEnd = -dp(7)
|
|
726
|
+
}
|
|
727
|
+
icon.background = StateListDrawable().apply {
|
|
728
|
+
addState(intArrayOf(android.R.attr.state_pressed),
|
|
729
|
+
roundedFill(color(theme, "rowPressedBackground", "#00000017"), 19f).apply {
|
|
730
|
+
setStroke(dp(1), Color.TRANSPARENT)
|
|
731
|
+
})
|
|
732
|
+
addState(intArrayOf(), roundedFill(Color.TRANSPARENT, 19f).apply {
|
|
733
|
+
setStroke(dp(1), Color.TRANSPARENT)
|
|
734
|
+
})
|
|
735
|
+
}
|
|
736
|
+
clipChildren = false
|
|
737
|
+
clipToPadding = false
|
|
738
|
+
requestsUnclippedHost = true
|
|
739
|
+
} else if (item.json.optString("presentation") == "accountSelector") {
|
|
516
740
|
icon.glyphSizeDp = 24
|
|
517
741
|
val isSourceMenu = item.hasExplicitHeight && icon.iconName == "DotHorOutline"
|
|
518
742
|
val size = if (item.hasExplicitHeight && icon.iconName == "PlusSmallOutline") 36 else 38
|
|
@@ -538,6 +762,13 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
538
762
|
addState(intArrayOf(), roundedFill(Color.TRANSPARENT, 19f))
|
|
539
763
|
}
|
|
540
764
|
}
|
|
765
|
+
} else if (icon.iconName == "RefreshCcwOutline" && data.optString("actionKey").isEmpty()) {
|
|
766
|
+
icon.glyphSizeDp = 16
|
|
767
|
+
icon.isClickable = false
|
|
768
|
+
icon.isFocusable = false
|
|
769
|
+
icon.layoutParams = LayoutParams(dp(16), dp(16)).apply {
|
|
770
|
+
gravity = Gravity.CENTER_VERTICAL
|
|
771
|
+
}
|
|
541
772
|
} else if (icon.iconName == "ChevronRightSmallOutline") {
|
|
542
773
|
icon.glyphSizeDp = null
|
|
543
774
|
// ListItem.DrillIn is a 24dp icon with mx=-6, for a 12dp layout footprint.
|
|
@@ -709,3 +940,13 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
709
940
|
cornerRadius = scaledDp(radiusDp)
|
|
710
941
|
}
|
|
711
942
|
}
|
|
943
|
+
|
|
944
|
+
private class ValuePairTypefaceSpan(private val face: Typeface) : MetricAffectingSpan() {
|
|
945
|
+
override fun updateDrawState(paint: TextPaint) {
|
|
946
|
+
paint.typeface = face
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
override fun updateMeasureState(paint: TextPaint) {
|
|
950
|
+
paint.typeface = face
|
|
951
|
+
}
|
|
952
|
+
}
|
|
@@ -16,7 +16,11 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
16
16
|
var onAction: ((String, View, String, Int) -> Unit)? = null
|
|
17
17
|
private var sourceScale = false
|
|
18
18
|
private val main = LinearLayout(context).apply { orientation = HORIZONTAL; gravity = Gravity.CENTER_VERTICAL }
|
|
19
|
+
private val identityColumn = LinearLayout(context).apply { orientation = HORIZONTAL; gravity = Gravity.CENTER_VERTICAL }
|
|
19
20
|
private val visual = NativeListLeadingVisual(reactContext, fonts)
|
|
21
|
+
/** Whether the bound leading visual lays a badge past its frame; see [setClipping]. */
|
|
22
|
+
var leadingOverhangs = false
|
|
23
|
+
private set
|
|
20
24
|
private val identity = LinearLayout(context).apply { orientation = VERTICAL }
|
|
21
25
|
private val titleLine = LinearLayout(context).apply { orientation = HORIZONTAL; gravity = Gravity.CENTER_VERTICAL }
|
|
22
26
|
private val title = NativeListTextView(context)
|
|
@@ -40,13 +44,26 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
40
44
|
identity.addView(status)
|
|
41
45
|
feeLine.addView(feePrimary); feeLine.addView(feeSecondary)
|
|
42
46
|
fee.addView(feeLabel); fee.addView(feeLine)
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
identityColumn.addView(visual)
|
|
48
|
+
identityColumn.addView(identity, LayoutParams(0, -2, 1f))
|
|
49
|
+
main.addView(identityColumn, LayoutParams(0, -2, 1f))
|
|
45
50
|
main.addView(amounts)
|
|
46
51
|
main.addView(fee)
|
|
47
52
|
addView(main, LayoutParams(-1, -2))
|
|
48
53
|
addView(actions, LayoutParams(-1, -2))
|
|
49
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Android clips a child to its own bounds while its parent clips children, so
|
|
57
|
+
* every view between the leading visual and the row host stops clipping when
|
|
58
|
+
* the visual's network badge overhangs its box (SPEC "Leading badge overhang",
|
|
59
|
+
* OK-66275); the host row applies the same policy to itself.
|
|
60
|
+
*/
|
|
61
|
+
private fun setClipping(clips: Boolean) {
|
|
62
|
+
for (group in listOf(identityColumn, main, this)) {
|
|
63
|
+
group.clipChildren = clips
|
|
64
|
+
group.clipToPadding = clips
|
|
65
|
+
}
|
|
66
|
+
}
|
|
50
67
|
private fun dp(value: Int) = if (sourceScale) (value * resources.displayMetrics.density).roundToInt() else NativeListScale.dp(resources, value)
|
|
51
68
|
private fun px(value: Double) = (value * resources.displayMetrics.density).roundToInt()
|
|
52
69
|
private fun color(tone: String, theme: JSONObject?): Int {
|
|
@@ -70,10 +87,15 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
70
87
|
val style = data.optJSONObject("style") ?: JSONObject()
|
|
71
88
|
val image = style.optJSONObject("image") ?: JSONObject()
|
|
72
89
|
val table = data.optString("presentation") == "table"
|
|
90
|
+
val hideLeading = data.optBoolean("hideLeading")
|
|
73
91
|
val gap = if (style.has("leadingGap")) px(style.optDouble("leadingGap")) else dp(12)
|
|
74
92
|
val iw = if (image.has("width")) px(image.optDouble("width")) else dp(40)
|
|
75
|
-
visual.layoutParams = LayoutParams(iw, if (image.has("height")) px(image.optDouble("height")) else dp(40)).apply { marginEnd = gap }
|
|
76
|
-
visual.
|
|
93
|
+
visual.layoutParams = LayoutParams(iw, if (image.has("height")) px(image.optDouble("height")) else dp(40)).apply { marginEnd = if (hideLeading) 0 else gap }
|
|
94
|
+
visual.visibility = if (hideLeading) GONE else VISIBLE
|
|
95
|
+
if (hideLeading) visual.recycle()
|
|
96
|
+
else visual.bind(data.optJSONObject("leading") ?: JSONObject(), image, item.key, theme, false, sourceScale, data.optJSONObject("secondaryLeading"))
|
|
97
|
+
leadingOverhangs = !hideLeading && visual.requestsUnclippedHost
|
|
98
|
+
setClipping(nativeListActivityHostClips(leadingOverhangs))
|
|
77
99
|
amounts.layoutParams = if (table) LayoutParams(0, -2, 1f).apply { marginStart = gap } else LayoutParams(-2, -2).apply { marginStart = gap }
|
|
78
100
|
text(title, data.optString("title"), style.optJSONObject("title"), 16f, color("primary", theme), 24, "medium")
|
|
79
101
|
text(description, data.optString("description"), style.optJSONObject("description"), 14f, color("secondary", theme), 20, lines = 2)
|
|
@@ -107,7 +129,9 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
107
129
|
val feeData = data.optJSONObject("fee")
|
|
108
130
|
fee.visibility = if (feeData == null) GONE else VISIBLE
|
|
109
131
|
fee.alpha = if (feeData?.optBoolean("hidden") == true) 0f else 1f
|
|
110
|
-
fee.layoutParams = LayoutParams(-2, -2).apply { marginStart = gap }
|
|
132
|
+
fee.layoutParams = (if (table) LayoutParams(0, -2, 0.6f) else LayoutParams(-2, -2)).apply { marginStart = gap }
|
|
133
|
+
feeLabel.layoutParams.width = if (table) LayoutParams.WRAP_CONTENT else LayoutParams.MATCH_PARENT
|
|
134
|
+
feeLine.layoutParams.width = if (table) LayoutParams.WRAP_CONTENT else LayoutParams.MATCH_PARENT
|
|
111
135
|
text(feeLabel, feeData?.optString("label") ?: "", style.optJSONObject("secondaryAmount"), 12f, color("secondary", theme), 16)
|
|
112
136
|
text(feePrimary, feeData?.optString("primary") ?: "", style.optJSONObject("secondaryAmount"), 14f, color("primary", theme), 20)
|
|
113
137
|
text(feeSecondary, feeData?.optString("secondary") ?: "", style.optJSONObject("secondaryAmount"), 12f, color("secondary", theme), 16)
|
|
@@ -117,7 +141,7 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
117
141
|
actions.removeAllViews()
|
|
118
142
|
val actionData = data.optJSONArray("footerActions")
|
|
119
143
|
actions.visibility = if ((actionData?.length() ?: 0) == 0) GONE else VISIBLE
|
|
120
|
-
actions.layoutParams = LayoutParams(-1, -2).apply { marginStart = iw + gap; topMargin = dp(8) }
|
|
144
|
+
actions.layoutParams = LayoutParams(-1, -2).apply { marginStart = if (hideLeading) 0 else iw + gap; topMargin = dp(8) }
|
|
121
145
|
for (index in 0 until (actionData?.length() ?: 0)) {
|
|
122
146
|
val descriptor = actionData!!.getJSONObject(index)
|
|
123
147
|
val button = NativeListTextView(context)
|
|
@@ -146,7 +170,11 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
146
170
|
}
|
|
147
171
|
label.text = styled
|
|
148
172
|
}
|
|
149
|
-
fun recycle() {
|
|
173
|
+
fun recycle() {
|
|
174
|
+
visual.recycle(); visual.visibility = VISIBLE; amountViews.forEach { it.recycle() }; description.setOnClickListener(null); actions.removeAllViews()
|
|
175
|
+
leadingOverhangs = false
|
|
176
|
+
setClipping(true)
|
|
177
|
+
}
|
|
150
178
|
fun dispose() { recycle(); visual.dispose(); amountViews.forEach { it.dispose() } }
|
|
151
179
|
|
|
152
180
|
private inner class AmountView : LinearLayout(context) {
|
|
@@ -54,6 +54,13 @@ internal class NativeListActivityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
54
54
|
details.onAction = { key, view, source, slot -> emitAction(key, view, source, slot) }
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/** Host clipping for the current bind; see [nativeListActivityHostClips]. */
|
|
58
|
+
private fun setHostClipping(clips: Boolean) {
|
|
59
|
+
content.clipChildren = clips
|
|
60
|
+
clipChildren = clips
|
|
61
|
+
clipToPadding = clips
|
|
62
|
+
}
|
|
63
|
+
|
|
57
64
|
override fun defaultHeight(item: NativeListItem, layout: String) =
|
|
58
65
|
if (item.json.has("amounts")) 0 else if ((item.json.optJSONArray("footerActions")?.length() ?: 0) > 0) 104 else 60
|
|
59
66
|
|
|
@@ -76,11 +83,17 @@ internal class NativeListActivityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
76
83
|
setPadding(hp, vp, hp, vp)
|
|
77
84
|
visual.recycle()
|
|
78
85
|
details.bind(item, theme, sourceScale)
|
|
86
|
+
// The rich row's leading visual lives on the details view, where its
|
|
87
|
+
// network badge overhangs the box (OK-66275): this host must stop clipping
|
|
88
|
+
// as well, and a view reused from a badge row clips again when the bound
|
|
89
|
+
// row has no badge.
|
|
90
|
+
setHostClipping(nativeListActivityHostClips(details.leadingOverhangs))
|
|
79
91
|
return
|
|
80
92
|
}
|
|
81
93
|
details.recycle()
|
|
82
94
|
val style = data.optJSONObject("style") ?: JSONObject()
|
|
83
95
|
val image = style.optJSONObject("image") ?: JSONObject()
|
|
96
|
+
val hideLeading = data.optBoolean("hideLeading")
|
|
84
97
|
fun color(name: String, fallback: String) =
|
|
85
98
|
parseNativeListColor(theme?.optString(name, fallback) ?: fallback)
|
|
86
99
|
fun fill(value: Int, radius: Int) =
|
|
@@ -143,8 +156,10 @@ internal class NativeListActivityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
143
156
|
val iw = if (image.has("width")) stylePx(image.optDouble("width")) else dp(40)
|
|
144
157
|
val ih = if (image.has("height")) stylePx(image.optDouble("height")) else dp(40)
|
|
145
158
|
val gap = if (style.has("leadingGap")) stylePx(style.optDouble("leadingGap")) else dp(12)
|
|
146
|
-
visual.layoutParams = LayoutParams(iw, ih).apply { marginEnd = gap }
|
|
147
|
-
visual.
|
|
159
|
+
visual.layoutParams = LayoutParams(iw, ih).apply { marginEnd = if (hideLeading) 0 else gap }
|
|
160
|
+
visual.visibility = if (hideLeading) GONE else VISIBLE
|
|
161
|
+
if (hideLeading) visual.recycle()
|
|
162
|
+
else visual.bind(
|
|
148
163
|
// Legacy: a missing visual still reserves an empty, transparent slot.
|
|
149
164
|
data.optJSONObject("leading") ?: JSONObject().put("backgroundColor", "#00000000"),
|
|
150
165
|
image,
|
|
@@ -154,6 +169,13 @@ internal class NativeListActivityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
154
169
|
sourceScale,
|
|
155
170
|
data.optJSONObject("secondaryLeading"),
|
|
156
171
|
)
|
|
172
|
+
// The token network badge hangs 4dp past the 40dp visual and Android clips a
|
|
173
|
+
// child to its own bounds while its parent clips children, so with the
|
|
174
|
+
// default clipping the history rows showed the badge cut flat (OK-66071).
|
|
175
|
+
// Stop clipping the content row and this row's padding exactly when the
|
|
176
|
+
// bound visual reports such a badge (SPEC "Leading badge overhang"), as the
|
|
177
|
+
// Identity renderer does.
|
|
178
|
+
setHostClipping(nativeListActivityHostClips(!hideLeading && visual.requestsUnclippedHost))
|
|
157
179
|
bind(
|
|
158
180
|
title,
|
|
159
181
|
data.optString("title"),
|
|
@@ -212,7 +234,7 @@ internal class NativeListActivityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
212
234
|
actions.visibility = if (count == 0) GONE else VISIBLE
|
|
213
235
|
actions.layoutParams =
|
|
214
236
|
LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT).apply {
|
|
215
|
-
marginStart = if (style.has("leadingGap") || image.has("width")) iw + gap else dp(52)
|
|
237
|
+
marginStart = if (hideLeading) 0 else if (style.has("leadingGap") || image.has("width")) iw + gap else dp(52)
|
|
216
238
|
topMargin = if (style.has("lineGap")) stylePx(style.optDouble("lineGap")) else dp(8)
|
|
217
239
|
bottomMargin = dp(4)
|
|
218
240
|
}
|
|
@@ -240,9 +240,10 @@ internal class NativeListAdapter(
|
|
|
240
240
|
|
|
241
241
|
private fun isMarketQuoteUpdate(oldItem: NativeListItem, newItem: NativeListItem): Boolean {
|
|
242
242
|
if (oldItem.type != "market" || newItem.type != "market") return false
|
|
243
|
+
if (!hasSameMarketMetricStructure(oldItem, newItem)) return false
|
|
243
244
|
fun stableContent(item: NativeListItem): String {
|
|
244
245
|
val value = JSONObject(item.json.toString())
|
|
245
|
-
listOf("revision", "price", "priceSegments", "change", "accessibilityLabel")
|
|
246
|
+
listOf("revision", "price", "priceSegments", "change", "accessibilityLabel", "metrics")
|
|
246
247
|
.forEach(value::remove)
|
|
247
248
|
return value.toString()
|
|
248
249
|
}
|
|
@@ -256,3 +257,18 @@ internal const val SELECTION_PAYLOAD = "selection"
|
|
|
256
257
|
// OneKey patch: internal payload, never exposed through the serialized row contract.
|
|
257
258
|
internal const val SELECTION_ECHO_PAYLOAD = "selectionEcho"
|
|
258
259
|
internal const val MARKET_QUOTE_PAYLOAD = "marketQuote"
|
|
260
|
+
|
|
261
|
+
internal fun hasSameMarketMetricStructure(before: NativeListItem, after: NativeListItem): Boolean {
|
|
262
|
+
val old = before.json.optJSONArray("metrics")
|
|
263
|
+
val next = after.json.optJSONArray("metrics")
|
|
264
|
+
val oldCount = old?.length() ?: 0
|
|
265
|
+
if (oldCount != (next?.length() ?: 0)) return false
|
|
266
|
+
for (index in 0 until oldCount) {
|
|
267
|
+
val previous = old?.optJSONObject(index) ?: return false
|
|
268
|
+
val current = next?.optJSONObject(index) ?: return false
|
|
269
|
+
if (previous.optString("key") != current.optString("key") ||
|
|
270
|
+
previous.optInt("weight", 1) != current.optInt("weight", 1) ||
|
|
271
|
+
previous.optString("alignment", "end") != current.optString("alignment", "end")) return false
|
|
272
|
+
}
|
|
273
|
+
return true
|
|
274
|
+
}
|