@onekeyfe/react-native-native-list 6.7.0-5 → 6.7.0-51

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.
Files changed (214) hide show
  1. package/README.md +312 -375
  2. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
  3. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +250 -9
  4. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +35 -7
  5. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
  6. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
  7. package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
  8. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
  9. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
  10. package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +47 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
  12. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +152 -33
  13. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
  14. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
  16. package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
  17. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
  18. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
  19. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -287
  20. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
  21. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +7 -0
  22. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
  23. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
  24. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
  25. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1978 -136
  26. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
  27. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
  28. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
  29. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
  30. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
  31. package/docs/ROW_TEMPLATES.md +74 -13
  32. package/docs/SPEC.md +1232 -16
  33. package/docs/STYLE_SPEC.md +14 -0
  34. package/ios/HybridNativeList.swift +21 -2
  35. package/ios/NativeListAccessoryStack.swift +237 -51
  36. package/ios/NativeListActivityDetailsView.swift +30 -11
  37. package/ios/NativeListActivityRenderer.swift +8 -2
  38. package/ios/NativeListButtonGroupRenderer.swift +89 -0
  39. package/ios/NativeListDataRowRenderer.swift +167 -30
  40. package/ios/NativeListDesignAssets.swift +13 -75
  41. package/ios/NativeListGeneratedIcons.swift +55 -0
  42. package/ios/NativeListIconBinding.swift +171 -0
  43. package/ios/NativeListIdentityRenderer.swift +256 -39
  44. package/ios/NativeListLeadingVisual.swift +127 -28
  45. package/ios/NativeListMarketRenderer.swift +120 -31
  46. package/ios/NativeListMediaPlaceholderView.swift +189 -0
  47. package/ios/NativeListMediaPreviewSlot.swift +122 -61
  48. package/ios/NativeListMediaTileRenderer.swift +15 -11
  49. package/ios/NativeListMessageRenderer.swift +34 -1
  50. package/ios/NativeListMetricCardRenderer.swift +4 -2
  51. package/ios/NativeListModels.swift +42 -2
  52. package/ios/NativeListRendererRegistry.swift +1 -0
  53. package/ios/NativeListResolvedText.swift +2 -1
  54. package/ios/NativeListRowHost.swift +14 -0
  55. package/ios/NativeListSectionHeaderRenderer.swift +100 -4
  56. package/ios/RNCNativeListView.swift +1093 -59
  57. package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
  58. package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
  59. package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
  60. package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
  61. package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
  62. package/ios/tests/NativeListLifecycleTests.swift +2915 -4
  63. package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
  64. package/ios/tests/NativeListMediaVisibilityTests.swift +26 -1
  65. package/ios/tests/NativeListSharedIconTests.swift +236 -0
  66. package/lib/module/NativeList.js +236 -38
  67. package/lib/module/NativeList.web.js +167 -46
  68. package/lib/module/index.js +1 -1
  69. package/lib/module/models.js +3 -0
  70. package/lib/module/selection.js +1 -1
  71. package/lib/module/validation.js +1246 -48
  72. package/lib/module/web/NativeListGeneratedIcons.js +31 -0
  73. package/lib/module/web/NativeListWebEngine.js +513 -275
  74. package/lib/module/web/templates/ActivityRowRenderer.js +12 -31
  75. package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
  76. package/lib/module/web/templates/DataRowRenderer.js +40 -5
  77. package/lib/module/web/templates/IdentityRowRenderer.js +158 -6
  78. package/lib/module/web/templates/MarketTableRowRenderer.js +36 -19
  79. package/lib/module/web/templates/MediaTileRowRenderer.js +84 -25
  80. package/lib/module/web/templates/MessageRowRenderer.js +18 -2
  81. package/lib/module/web/templates/RowContainerStyle.js +1 -0
  82. package/lib/module/web/templates/RowRendererRegistry.js +3 -0
  83. package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
  84. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  85. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  86. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  87. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  88. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  89. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  90. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  91. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  92. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  93. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  94. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  95. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  96. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  97. package/lib/typescript/src/NativeList.d.ts +3 -3
  98. package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
  99. package/lib/typescript/src/NativeList.types.d.ts +20 -2
  100. package/lib/typescript/src/index.d.ts +2 -2
  101. package/lib/typescript/src/models.d.ts +126 -17
  102. package/lib/typescript/src/validation.d.ts +20 -0
  103. package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
  104. package/lib/typescript/src/web/NativeListWebEngine.d.ts +32 -1
  105. package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
  106. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
  107. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
  108. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  109. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  110. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  111. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  112. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  113. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  114. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  115. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  116. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  117. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  118. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  119. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  120. package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  121. package/package.json +16 -10
  122. package/react-native-native-list.podspec +2 -6
  123. package/scripts/generate-icons.mjs +150 -0
  124. package/scripts/generate-icons.test.mjs +288 -0
  125. package/scripts/native-list-icons.json +260 -0
  126. package/src/NativeList.nitro.ts +2 -0
  127. package/src/NativeList.tsx +439 -91
  128. package/src/NativeList.types.ts +24 -2
  129. package/src/NativeList.web.tsx +295 -89
  130. package/src/index.ts +2 -0
  131. package/src/models.ts +263 -144
  132. package/src/selection.ts +1 -0
  133. package/src/validation.ts +3013 -152
  134. package/src/web/NativeListGeneratedIcons.ts +28 -0
  135. package/src/web/NativeListWebEngine.ts +818 -343
  136. package/src/web/templates/ActivityRowRenderer.ts +29 -59
  137. package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
  138. package/src/web/templates/DataRowRenderer.ts +93 -20
  139. package/src/web/templates/IdentityRowRenderer.ts +231 -6
  140. package/src/web/templates/MarketTableRowRenderer.ts +53 -33
  141. package/src/web/templates/MediaTileRowRenderer.ts +90 -28
  142. package/src/web/templates/MessageRowRenderer.ts +23 -7
  143. package/src/web/templates/RowContainerStyle.ts +2 -0
  144. package/src/web/templates/RowRendererRegistry.ts +11 -1
  145. package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
  146. package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
  147. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
  148. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
  149. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
  150. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
  151. package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
  152. package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
  153. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
  154. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
  155. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
  156. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
  157. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
  158. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
  159. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
  160. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
  161. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
  162. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
  163. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
  164. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
  165. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
  166. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
  167. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
  168. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
  169. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
  170. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
  171. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
  172. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
  173. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
  174. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
  175. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
  176. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
  177. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
  178. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
  179. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
  180. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
  181. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
  182. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
  183. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
  184. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
  185. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
  186. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
  187. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
  188. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
  189. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
  190. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
  191. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
  192. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
  193. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
  194. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
  195. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
  196. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
  197. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
  198. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
  199. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
  200. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
  201. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
  202. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
  203. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
  204. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
  205. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
  206. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
  207. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
  208. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
  209. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
  210. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
  211. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
  212. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
  213. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
  214. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
@@ -1,5 +1,6 @@
1
1
  package com.margelo.nitro.nativelist
2
2
 
3
+ import android.graphics.PointF
3
4
  import android.graphics.drawable.GradientDrawable
4
5
  import android.text.Spannable
5
6
  import android.text.SpannableStringBuilder
@@ -8,6 +9,7 @@ import android.text.style.AbsoluteSizeSpan
8
9
  import android.text.style.ForegroundColorSpan
9
10
  import android.util.TypedValue
10
11
  import android.view.Gravity
12
+ import android.view.MotionEvent
11
13
  import android.view.View
12
14
  import android.view.ViewGroup
13
15
  import android.widget.LinearLayout
@@ -28,17 +30,42 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
28
30
  private val mainColumn = LinearLayout(context)
29
31
  private val titleLine = PackedTitleLineLayout(context)
30
32
  private val title = NativeListTextView(context)
33
+ private val titleIcon = OneKeyIconView(context)
34
+ private var titleImage: NativeListImageSlot? = null
31
35
  private val subtitle = NativeListTextView(context)
32
36
  private val tertiary = NativeListTextView(context)
33
37
  private val badgeLine = NativeListTextView(context)
38
+ private val titleSuffixLabels = mutableListOf<NativeListTextView>()
39
+ private val titleSuffixMaxWidths = mutableListOf<Int>()
34
40
  private val trailingColumn = NativeListAccessoryStack(context, fonts)
35
41
  private val semanticBadgeLabels = mutableListOf<TextView>()
36
42
  private val semanticSubtitleLabels = mutableListOf<TextView>()
37
43
  private var walletBadgeLine: View? = null
38
44
  private var currentItem: NativeListItem? = null
39
45
  private var currentTheme: JSONObject? = null
46
+ private var longPressPoint: PointF? = null
47
+ private var longPressPointEpoch = -1L
40
48
  private val paintDefaults = mutableMapOf<TextView, Int>()
41
49
 
50
+ override fun onRowTouch(event: MotionEvent) {
51
+ when (event.actionMasked) {
52
+ MotionEvent.ACTION_DOWN -> {
53
+ longPressPoint = if (currentItem?.isRowPressEnabled == true) PointF(event.x, event.y) else null
54
+ longPressPointEpoch = bindingEpoch
55
+ }
56
+ MotionEvent.ACTION_MOVE -> {
57
+ if (longPressPointEpoch == bindingEpoch && longPressPoint != null &&
58
+ event.x >= 0 && event.y >= 0 && event.x < width && event.y < height
59
+ ) longPressPoint?.set(event.x, event.y)
60
+ else longPressPoint = null
61
+ }
62
+ MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
63
+ longPressPoint = null
64
+ longPressPointEpoch = -1L
65
+ }
66
+ }
67
+ }
68
+
42
69
  override fun backgroundGroupPosition(
43
70
  item: NativeListItem,
44
71
  layout: String,
@@ -53,7 +80,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
53
80
  "single"
54
81
  else item.json.optString("groupPosition")
55
82
 
56
- override val assetFields = listOf("leading")
83
+ override val assetFields = listOf("leading", "titleImage")
57
84
 
58
85
  override fun usesSourceScale(item: NativeListItem, provided: Boolean) =
59
86
  item.usesSelectorSourceScale || provided
@@ -83,6 +110,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
83
110
  titleLine.orientation = HORIZONTAL
84
111
  titleLine.gravity = Gravity.CENTER_VERTICAL
85
112
  titleLine.addView(title, LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f))
113
+ titleLine.addView(titleIcon, LayoutParams(dp(20), dp(20)).apply { marginStart = dp(4) })
86
114
  titleLine.addView(badgeLine)
87
115
  trailingColumn.onAction = { key, view, slot, target ->
88
116
  emitAction(key, view, "trailingAccessory", slot, target, trailingColumn.anchorInset(view))
@@ -111,7 +139,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
111
139
 
112
140
  private fun showText(view: TextView, text: String, lines: Int) {
113
141
  view.text = text
114
- view.maxLines = lines
142
+ view.maxLines = if (lines == 0) Int.MAX_VALUE else lines
115
143
  view.visibility = if (text.isEmpty()) GONE else VISIBLE
116
144
  }
117
145
 
@@ -135,10 +163,42 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
135
163
  layout: String,
136
164
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
137
165
  ) {
166
+ cancelLongPress()
167
+ longPressPoint = null
168
+ longPressPointEpoch = -1L
138
169
  currentItem = item
170
+ val longPressActionKey = item.json.optString("longPressActionKey")
171
+ val boundEpoch = bindingEpoch
172
+ setOnLongClickListener(
173
+ if (longPressActionKey.isNotEmpty())
174
+ OnLongClickListener {
175
+ val point = longPressPoint
176
+ if (!isEnabled || !item.isRowPressEnabled || currentItem?.key != item.key ||
177
+ bindingEpoch != boundEpoch ||
178
+ (longPressPointEpoch == boundEpoch && point == null)) false
179
+ else {
180
+ val windowPoint = point?.takeIf { longPressPointEpoch == boundEpoch }?.let {
181
+ val location = IntArray(2)
182
+ getLocationInWindow(location)
183
+ PointF(location[0] + it.x, location[1] + it.y)
184
+ }
185
+ onAction?.invoke(item, longPressActionKey, null,
186
+ NativeListActionOrigin(this, this, bindingEpoch, "row",
187
+ windowPointPixels = windowPoint))
188
+ longPressPoint = null
189
+ longPressPointEpoch = -1L
190
+ true
191
+ }
192
+ }
193
+ else null
194
+ )
195
+ isLongClickable = longPressActionKey.isNotEmpty()
139
196
  currentTheme = theme
140
197
  removeAllViews()
141
198
  mainColumn.removeAllViews()
199
+ titleSuffixLabels.forEach(titleLine::removeView)
200
+ titleSuffixLabels.clear()
201
+ titleSuffixMaxWidths.clear()
142
202
  semanticBadgeLabels.clear()
143
203
  semanticSubtitleLabels.clear()
144
204
  walletBadgeLine = null
@@ -157,8 +217,12 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
157
217
  mainColumn.gravity = Gravity.CENTER_VERTICAL
158
218
  titleLine.gravity = Gravity.CENTER_VERTICAL
159
219
  titleLine.packsChildrenAtStart = false
220
+ titleLine.leadingTextMaxWidth = Int.MAX_VALUE
160
221
  titleLine.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
161
222
  title.layoutParams = LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f)
223
+ titleIcon.visibility = GONE
224
+ titleIcon.contentDescription = null
225
+ titleIcon.setOnClickListener(null)
162
226
  for (view in listOf(title, subtitle, tertiary, badgeLine)) {
163
227
  view.text = ""
164
228
  view.visibility = GONE
@@ -199,6 +263,29 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
199
263
  leadingActionIcon.useSourceScale = sourceScale
200
264
  leadingActionIcon.setOnClickListener(null)
201
265
  bindIdentity(item, theme, item.json.optBoolean("selected"), checkboxState)
266
+ val titleImageDescriptor = item.json.optJSONObject("titleImage")
267
+ val titleImageSource = titleImageDescriptor?.optJSONObject("image")
268
+ if (titleImageSource != null && titleImageSource.optString("uri").isNotEmpty()) {
269
+ if (item.json.optString("presentation") == "walletSidebar") {
270
+ titleLine.packsChildrenAtStart = true
271
+ title.layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
272
+ }
273
+ val slot = titleImage ?: NativeListImageSlot(reactContext).also { titleImage = it }
274
+ // Reinsert after icons so newly added suffixes cannot precede the image.
275
+ titleLine.removeView(slot.view)
276
+ titleLine.addView(slot.view, titleLine.indexOfChild(titleIcon) + 1)
277
+ val size = stylePx(titleImageSource.optDouble("width"))
278
+ slot.view.layoutParams = LayoutParams(size, size).apply { marginStart = dp(4) }
279
+ slot.view.visibility = VISIBLE
280
+ slot.view.contentDescription = titleImageDescriptor.optString("accessibilityLabel").takeIf(String::isNotEmpty)
281
+ slot.view.importantForAccessibility = if (slot.view.contentDescription == null)
282
+ View.IMPORTANT_FOR_ACCESSIBILITY_NO else View.IMPORTANT_FOR_ACCESSIBILITY_YES
283
+ slot.bind(titleImageSource, "${item.key}:titleImage", placeholder = "#00000000", round = true)
284
+ } else {
285
+ titleImage?.recycle()
286
+ titleImage?.view?.visibility = GONE
287
+ titleImage?.view?.contentDescription = null
288
+ }
202
289
  TextViewCompat.setLineHeight(
203
290
  title,
204
291
  dp(if (item.json.optString("presentation") == "walletSidebar") 16 else 24),
@@ -294,6 +381,19 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
294
381
  private fun addLeading(visual: JSONObject?, sizeDp: Int, spacingDp: Int = 12) {
295
382
  // Legacy: a missing visual still reserves an empty, transparent leading slot.
296
383
  val descriptor = visual ?: JSONObject().put("backgroundColor", "#00000000")
384
+ val overlays = descriptor.optJSONArray("overlays")
385
+ if (overlays != null && (0 until minOf(2, overlays.length())).any { index ->
386
+ val overlay = overlays.optJSONObject(index) ?: return@any false
387
+ overlay.optInt("offsetX", overlay.optInt("offset", 2)) > 0 ||
388
+ overlay.optInt("offsetY", overlay.optInt("offset", 2)) > 0
389
+ }) {
390
+ // The badge extends beyond the avatar and the row's padded content box.
391
+ clipChildren = false
392
+ clipToPadding = false
393
+ }
394
+ leadingFrame.bitmapBorderWidth =
395
+ if (descriptor.optString("borderColor").isNotEmpty() &&
396
+ descriptor.optString("borderStyle") != "dashed") dp(1) else 0
297
397
  if (visual == null) leadingFrame.recycle()
298
398
  val item = currentItem!!
299
399
  val style = item.json.optJSONObject("style")?.optJSONObject("image") ?: JSONObject()
@@ -310,6 +410,16 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
310
410
  if (item.json.optString("presentation") == "accountSelector" && item.hasExplicitHeight) 8
311
411
  else 10
312
412
  leadingFrame.bind(descriptor, style, item.key, currentTheme, false, sourceScale)
413
+ // The leading badges (overlay, cornerIcon, token network image) hang past the
414
+ // leading frame, and Android clips a child to its own bounds while its parent
415
+ // clips children: with the row's default clipping the account selector's
416
+ // bottom-right network badge was cut flat on Android only (OK-65694); iOS and
417
+ // Web let it overflow. Stop clipping the row, as the Market and Message
418
+ // renderers do for their network badges.
419
+ if (leadingFrame.requestsUnclippedHost) {
420
+ clipChildren = false
421
+ clipToPadding = false
422
+ }
313
423
  leadingFallback.typeface = fonts.bold(context)
314
424
  leadingFallback.textSize = sp(13f)
315
425
  leadingFallback.setLineSpacing(0f, 1f)
@@ -356,7 +466,61 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
356
466
  }
357
467
 
358
468
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
469
+ val ratio = currentItem?.json?.optJSONObject("style")
470
+ ?.optDouble("leadingContentMaxWidthRatio", Double.NaN) ?: Double.NaN
471
+ titleLine.leadingTextMaxWidth =
472
+ if (ratio.isFinite() && ratio > 0.0 && ratio <= 1.0 && leadingFrame.parent === this) {
473
+ val inner = (MeasureSpec.getSize(widthMeasureSpec) - paddingLeft - paddingRight)
474
+ .coerceAtLeast(0)
475
+ val leading = leadingFrame.layoutParams as LayoutParams
476
+ val imageWidth = titleImage?.view?.takeIf { it.visibility == VISIBLE }?.let {
477
+ it.layoutParams.width + dp(4)
478
+ } ?: 0
479
+ val icon = (if (titleIcon.visibility == VISIBLE) dp(24) else 0) + imageWidth
480
+ (inner * ratio).roundToInt()
481
+ .minus(leading.width + leading.marginEnd + icon)
482
+ .coerceAtLeast(0)
483
+ } else Int.MAX_VALUE
484
+ titleSuffixLabels.forEachIndexed { index, label ->
485
+ label.maxWidth = titleSuffixMaxWidths[index]
486
+ }
359
487
  super.onMeasure(widthMeasureSpec, heightMeasureSpec)
488
+ if (titleSuffixLabels.isNotEmpty()) {
489
+ val fixedWidth =
490
+ (1 until titleLine.childCount).sumOf { index ->
491
+ val view = titleLine.getChildAt(index)
492
+ if (view.visibility == GONE || titleSuffixLabels.any { it === view }) 0
493
+ else {
494
+ val margins = view.layoutParams as MarginLayoutParams
495
+ view.measuredWidth + margins.leftMargin + margins.rightMargin
496
+ }
497
+ }
498
+ val suffixMargins = titleSuffixLabels.sumOf {
499
+ val margins = it.layoutParams as MarginLayoutParams
500
+ margins.leftMargin + margins.rightMargin
501
+ }
502
+ val available =
503
+ (titleLine.measuredWidth - fixedWidth - suffixMargins - dp(80)).coerceAtLeast(0)
504
+ val desired = titleSuffixLabels.mapIndexed { index, label ->
505
+ label.paint.measureText(label.text.toString()).roundToInt()
506
+ .coerceAtMost(titleSuffixMaxWidths[index])
507
+ }
508
+ val total = desired.sum()
509
+ var remaining = available
510
+ var changed = false
511
+ titleSuffixLabels.forEachIndexed { index, label ->
512
+ val share =
513
+ if (total <= available) desired[index]
514
+ else if (index == titleSuffixLabels.lastIndex) remaining
515
+ else (desired[index].toLong() * available / total).toInt()
516
+ remaining -= share
517
+ if (label.maxWidth != share) {
518
+ label.maxWidth = share
519
+ changed = true
520
+ }
521
+ }
522
+ if (changed) super.onMeasure(widthMeasureSpec, heightMeasureSpec)
523
+ }
360
524
  val item = currentItem ?: return
361
525
  if (
362
526
  item.hasExplicitHeight &&
@@ -414,7 +578,13 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
414
578
  }
415
579
 
416
580
  override fun recycleContent() {
581
+ cancelLongPress()
582
+ longPressPoint = null
583
+ longPressPointEpoch = -1L
417
584
  leadingFrame.recycle()
585
+ titleImage?.recycle()
586
+ titleImage?.view?.visibility = GONE
587
+ titleImage?.view?.contentDescription = null
418
588
  trailingColumn.reset()
419
589
  currentItem = null
420
590
  }
@@ -422,6 +592,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
422
592
  override fun disposeContent() {
423
593
  recycleContent()
424
594
  leadingFrame.dispose()
595
+ titleImage?.dispose()
425
596
  }
426
597
 
427
598
  private fun bindIdentity(
@@ -582,6 +753,48 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
582
753
  titleLine.packsChildrenAtStart = true
583
754
  title.ellipsize = TextUtils.TruncateAt.END
584
755
  showText(title, item.json.optString("title"), item.json.optInt("titleLines", 1))
756
+ item.json.optJSONArray("titleSuffixes")?.let { suffixes ->
757
+ for (index in 0 until suffixes.length()) {
758
+ val suffix = suffixes.optJSONObject(index) ?: continue
759
+ val label = NativeListTextView(context).apply {
760
+ text = suffix.optString("text")
761
+ typeface = fonts.regular(context)
762
+ textSize = sp(12f)
763
+ includeFontPadding = false
764
+ maxLines = 1
765
+ ellipsize = TextUtils.TruncateAt.END
766
+ setTextColor(
767
+ color(
768
+ theme,
769
+ if (suffix.optString("tone") == "disabled") "disabledText" else "secondaryText",
770
+ "#0000009B",
771
+ )
772
+ )
773
+ }
774
+ TextViewCompat.setLineHeight(label, dp(16))
775
+ val maxWidth =
776
+ if (suffix.has("maxWidth")) stylePx(suffix.optDouble("maxWidth")) else Int.MAX_VALUE
777
+ label.maxWidth = maxWidth
778
+ titleSuffixMaxWidths.add(maxWidth)
779
+ titleSuffixLabels.add(label)
780
+ titleLine.addView(
781
+ label,
782
+ titleLine.childCount - 1,
783
+ LayoutParams(LayoutParams.WRAP_CONTENT, dp(16)).apply { marginStart = dp(8) },
784
+ )
785
+ }
786
+ }
787
+ item.json.optJSONObject("titleIcon")?.let { icon ->
788
+ titleIcon.iconName = icon.optString("name")
789
+ titleIcon.glyphSizeDp = 20
790
+ titleIcon.useSourceScale = sourceScale
791
+ titleIcon.tintColor = safeColor(
792
+ icon.optString("tintColor").takeIf(String::isNotEmpty),
793
+ color(theme, "iconSubdued", "#00000072"),
794
+ )
795
+ titleIcon.contentDescription = icon.optString("accessibilityLabel").takeIf(String::isNotEmpty)
796
+ titleIcon.visibility = VISIBLE
797
+ }
585
798
  if (item.json.optString("presentation") == "accountSelector") {
586
799
  title.typeface = fonts.regular(context)
587
800
  }
@@ -696,15 +909,16 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
696
909
  sourceScale,
697
910
  checkboxState,
698
911
  horizontal =
699
- (0 until accessories.length())
700
- .map { accessories.getJSONObject(it).optString("kind") }
701
- .let { kinds ->
702
- kinds.containsAll(listOf("value", "checkbox")) ||
703
- kinds == listOf("valuePair", "menu") ||
704
- (kinds == listOf("icon", "icon") &&
705
- accessories.getJSONObject(0).optString("name") == "PencilOutline" &&
706
- accessories.getJSONObject(1).optString("name") == "DragOutline")
707
- },
912
+ nativeListIdentityTrailingIsHorizontal(
913
+ (0 until accessories.length()).map { index ->
914
+ val accessory = accessories.getJSONObject(index)
915
+ NativeListTrailingDescriptor(
916
+ kind = accessory.optString("kind"),
917
+ name = accessory.optString("name"),
918
+ actionKey = accessory.optString("actionKey"),
919
+ )
920
+ }
921
+ ),
708
922
  )
709
923
  trailingColumn.endInset?.let { setPadding(paddingLeft, paddingTop, it, paddingBottom) }
710
924
  }