@onekeyfe/react-native-native-list 3.0.157 → 3.0.159

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 (199) hide show
  1. package/README.md +21 -5
  2. package/android/build.gradle +7 -0
  3. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +20 -0
  4. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +711 -0
  5. package/android/src/main/java/com/onekey/nativelist/NativeListActionRenderer.kt +169 -0
  6. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +179 -0
  7. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +264 -0
  8. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +20 -6
  9. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +53 -0
  10. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +487 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListEndAlignment.kt +5 -0
  12. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +820 -0
  13. package/android/src/main/java/com/onekey/nativelist/NativeListImageSlot.kt +147 -0
  14. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +453 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +997 -0
  16. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +268 -0
  17. package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +243 -0
  18. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +232 -0
  19. package/android/src/main/java/com/onekey/nativelist/NativeListMetricCardRenderer.kt +551 -0
  20. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +27 -1
  21. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +475 -0
  22. package/android/src/main/java/com/onekey/nativelist/NativeListRailRenderer.kt +143 -0
  23. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +42 -0
  24. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +415 -0
  25. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +163 -0
  26. package/android/src/main/java/com/onekey/nativelist/NativeListRowHost.kt +70 -0
  27. package/android/src/main/java/com/onekey/nativelist/NativeListScrollPositionTracker.kt +59 -0
  28. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +763 -0
  29. package/android/src/main/java/com/onekey/nativelist/NativeListSystemRenderer.kt +464 -0
  30. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +25 -0
  31. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +432 -124
  32. package/android/src/main/java/com/onekey/nativelist/NativeListWalletGroupRenderer.kt +407 -0
  33. package/android/src/main/res/values/native_scroll_coordinator_ids.xml +5 -0
  34. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListEndAlignmentTest.kt +34 -0
  35. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListScrollPositionTrackerTest.kt +44 -0
  36. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListSelectorBackgroundColorTest.kt +34 -0
  37. package/docs/DESIGN.md +520 -9
  38. package/docs/MIGRATION_BASELINE.md +117 -0
  39. package/docs/ROW_TEMPLATES.md +404 -0
  40. package/docs/SPEC.md +621 -0
  41. package/docs/STYLE_SPEC.md +988 -0
  42. package/docs/images/list-capabilities.svg +39 -0
  43. package/docs/images/row-action.svg +17 -0
  44. package/docs/images/row-activity.svg +24 -0
  45. package/docs/images/row-data.svg +24 -0
  46. package/docs/images/row-identity.svg +25 -0
  47. package/docs/images/row-market.svg +23 -0
  48. package/docs/images/row-media-tile.svg +26 -0
  49. package/docs/images/row-message.svg +20 -0
  50. package/docs/images/row-metric-card.svg +33 -0
  51. package/docs/images/row-rail.svg +18 -0
  52. package/docs/images/row-section-header.svg +19 -0
  53. package/docs/images/row-style-regions.svg +30 -0
  54. package/docs/images/row-system.svg +30 -0
  55. package/docs/images/row-wallet-group.svg +26 -0
  56. package/ios/HybridNativeList.swift +30 -0
  57. package/ios/NativeListAccessoryStack.swift +680 -0
  58. package/ios/NativeListActionRenderer.swift +108 -0
  59. package/ios/NativeListActivityDetailsView.swift +291 -0
  60. package/ios/NativeListActivityRenderer.swift +201 -0
  61. package/ios/NativeListDataRowRenderer.swift +444 -0
  62. package/ios/NativeListIdentityRenderer.swift +685 -0
  63. package/ios/NativeListImageSlot.swift +140 -0
  64. package/ios/NativeListLeadingVisual.swift +372 -0
  65. package/ios/NativeListMarketRenderer.swift +698 -0
  66. package/ios/NativeListMediaPreviewSlot.swift +259 -0
  67. package/ios/NativeListMediaTileRenderer.swift +190 -0
  68. package/ios/NativeListMessageRenderer.swift +168 -0
  69. package/ios/NativeListMetricCardRenderer.swift +420 -0
  70. package/ios/NativeListModels.swift +36 -1
  71. package/ios/NativeListRailRenderer.swift +152 -0
  72. package/ios/NativeListRendererCell.swift +311 -0
  73. package/ios/NativeListRendererRegistry.swift +50 -0
  74. package/ios/NativeListResolvedText.swift +130 -0
  75. package/ios/NativeListRowHost.swift +63 -0
  76. package/ios/NativeListScrollPositionTracker.swift +30 -0
  77. package/ios/NativeListSectionHeaderRenderer.swift +734 -0
  78. package/ios/NativeListSystemRenderer.swift +568 -0
  79. package/ios/NativeListTextLabel.swift +42 -0
  80. package/ios/NativeListTextStyles.swift +236 -0
  81. package/ios/NativeListWalletGroupRenderer.swift +255 -0
  82. package/ios/RNCNativeListView.swift +282 -184
  83. package/ios/tests/NativeListActivityPresentationTests.swift +97 -0
  84. package/ios/tests/NativeListLifecycleTests.swift +241 -0
  85. package/ios/tests/NativeListMediaVisibilityTests.swift +109 -0
  86. package/ios/tests/NativeListScrollPositionTrackerTests.swift +25 -0
  87. package/lib/module/NativeList.js +56 -3
  88. package/lib/module/NativeList.web.js +5 -0
  89. package/lib/module/models.js +54 -0
  90. package/lib/module/validation.js +386 -28
  91. package/lib/module/web/NativeListWebEngine.js +148 -936
  92. package/lib/module/web/templates/ActionRowRenderer.js +97 -0
  93. package/lib/module/web/templates/ActivityRowRenderer.js +95 -0
  94. package/lib/module/web/templates/DataRowRenderer.js +145 -0
  95. package/lib/module/web/templates/IdentityRowRenderer.js +289 -0
  96. package/lib/module/web/templates/MarketRowRenderer.js +310 -0
  97. package/lib/module/web/templates/MediaTileRowRenderer.js +132 -0
  98. package/lib/module/web/templates/MessageRowRenderer.js +165 -0
  99. package/lib/module/web/templates/MetricCardRowRenderer.js +172 -0
  100. package/lib/module/web/templates/RailRowRenderer.js +98 -0
  101. package/lib/module/web/templates/RowContainerStyle.js +100 -0
  102. package/lib/module/web/templates/RowElements.js +93 -0
  103. package/lib/module/web/templates/RowRendererRegistry.js +70 -0
  104. package/lib/module/web/templates/RowText.js +121 -0
  105. package/lib/module/web/templates/RowVisual.js +43 -0
  106. package/lib/module/web/templates/SectionHeaderRowRenderer.js +146 -0
  107. package/lib/module/web/templates/SystemRowRenderer.js +161 -0
  108. package/lib/module/web/templates/WalletGroupRowRenderer.js +96 -0
  109. package/lib/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
  110. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +39 -3
  111. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +6 -0
  112. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +15 -0
  113. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_bool.kt +78 -0
  114. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +26 -0
  115. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +24 -9
  116. package/lib/nitrogen/generated/android/nativelistOnLoad.cpp +2 -0
  117. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +8 -0
  118. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +37 -0
  119. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +23 -2
  120. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +32 -0
  121. package/lib/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  122. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +3 -0
  123. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +54 -0
  124. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +6 -0
  125. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +8 -2
  126. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +6 -0
  127. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +11 -2
  128. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +3 -0
  129. package/lib/typescript/src/NativeList.nitro.d.ts +3 -0
  130. package/lib/typescript/src/NativeList.types.d.ts +14 -1
  131. package/lib/typescript/src/models.d.ts +199 -18
  132. package/lib/typescript/src/web/NativeListWebEngine.d.ts +18 -16
  133. package/lib/typescript/src/web/templates/ActionRowRenderer.d.ts +15 -0
  134. package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +15 -0
  135. package/lib/typescript/src/web/templates/DataRowRenderer.d.ts +15 -0
  136. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +16 -0
  137. package/lib/typescript/src/web/templates/MarketRowRenderer.d.ts +30 -0
  138. package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +15 -0
  139. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +44 -0
  140. package/lib/typescript/src/web/templates/MetricCardRowRenderer.d.ts +15 -0
  141. package/lib/typescript/src/web/templates/RailRowRenderer.d.ts +28 -0
  142. package/lib/typescript/src/web/templates/RowContainerStyle.d.ts +9 -0
  143. package/lib/typescript/src/web/templates/RowElements.d.ts +38 -0
  144. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +83 -0
  145. package/lib/typescript/src/web/templates/RowText.d.ts +9 -0
  146. package/lib/typescript/src/web/templates/RowVisual.d.ts +20 -0
  147. package/lib/typescript/src/web/templates/SectionHeaderRowRenderer.d.ts +15 -0
  148. package/lib/typescript/src/web/templates/SystemRowRenderer.d.ts +16 -0
  149. package/lib/typescript/src/web/templates/WalletGroupRowRenderer.d.ts +20 -0
  150. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
  151. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +39 -3
  152. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +6 -0
  153. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +15 -0
  154. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_bool.kt +78 -0
  155. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +26 -0
  156. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +24 -9
  157. package/nitrogen/generated/android/nativelistOnLoad.cpp +2 -0
  158. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +8 -0
  159. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +37 -0
  160. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +23 -2
  161. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +32 -0
  162. package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  163. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +3 -0
  164. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +54 -0
  165. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +6 -0
  166. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +8 -2
  167. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +6 -0
  168. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +11 -2
  169. package/nitrogen/generated/shared/json/NativeListConfig.json +3 -0
  170. package/package.json +7 -6
  171. package/react-native-native-list.podspec +6 -0
  172. package/scripts/enable-container-slots.mjs +58 -0
  173. package/scripts/enable-container-slots.test.mjs +58 -0
  174. package/src/NativeList.nitro.ts +3 -0
  175. package/src/NativeList.tsx +84 -2
  176. package/src/NativeList.types.ts +14 -1
  177. package/src/NativeList.web.tsx +5 -0
  178. package/src/models.ts +320 -20
  179. package/src/validation.ts +641 -49
  180. package/src/web/NativeListWebEngine.ts +361 -1932
  181. package/src/web/templates/ActionRowRenderer.ts +123 -0
  182. package/src/web/templates/ActivityRowRenderer.ts +159 -0
  183. package/src/web/templates/DataRowRenderer.ts +212 -0
  184. package/src/web/templates/IdentityRowRenderer.ts +527 -0
  185. package/src/web/templates/MarketRowRenderer.ts +467 -0
  186. package/src/web/templates/MediaTileRowRenderer.ts +182 -0
  187. package/src/web/templates/MessageRowRenderer.ts +306 -0
  188. package/src/web/templates/MetricCardRowRenderer.ts +337 -0
  189. package/src/web/templates/RailRowRenderer.ts +136 -0
  190. package/src/web/templates/RowContainerStyle.ts +131 -0
  191. package/src/web/templates/RowElements.ts +160 -0
  192. package/src/web/templates/RowRendererRegistry.ts +111 -0
  193. package/src/web/templates/RowText.ts +181 -0
  194. package/src/web/templates/RowVisual.ts +115 -0
  195. package/src/web/templates/SectionHeaderRowRenderer.ts +243 -0
  196. package/src/web/templates/SystemRowRenderer.ts +282 -0
  197. package/src/web/templates/WalletGroupRowRenderer.ts +131 -0
  198. package/android/src/main/java/com/onekey/nativelist/NativeListRowView.kt +0 -4538
  199. package/ios/NativeListCell.swift +0 -4300
@@ -0,0 +1,169 @@
1
+ package com.margelo.nitro.nativelist
2
+
3
+ import android.view.Gravity
4
+ import com.facebook.react.uimanager.ThemedReactContext
5
+ import org.json.JSONArray
6
+ import org.json.JSONObject
7
+
8
+ internal class NativeListActionRowView(context: ThemedReactContext) :
9
+ NativeListRendererRowView(context) {
10
+ private val visual = NativeListLeadingVisual(context)
11
+ private val title = NativeListTextView(context)
12
+ private val accessories = NativeListAccessoryStack(context)
13
+ override val assetFields = listOf("icon")
14
+
15
+ init {
16
+ visual.glyphSize = 24
17
+ visual.iconBorder = false
18
+ orientation = HORIZONTAL
19
+ gravity = Gravity.CENTER_VERTICAL
20
+ addView(visual)
21
+ addView(title, LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f))
22
+ addView(accessories)
23
+ accessories.onAction = { key, view, slot, target ->
24
+ emitAction(key, view, "trailingAccessory", slot, target, accessories.anchorInset(view))
25
+ }
26
+ }
27
+
28
+ private val titlePaintFlags = title.paintFlags
29
+ private val fallbackPaintFlags = visual.fallbackTextView.paintFlags
30
+
31
+ override fun defaultHeight(item: NativeListItem, layout: String) =
32
+ when {
33
+ item.json.optString("presentation") == "accountSelector" -> 48
34
+ item.json.has("icon") -> 60
35
+ else -> 44
36
+ }
37
+
38
+ override fun bindContent(
39
+ item: NativeListItem,
40
+ theme: JSONObject?,
41
+ layout: String,
42
+ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
43
+ ) {
44
+ val style = item.json.optJSONObject("style") ?: JSONObject()
45
+ val icon = item.json.optJSONObject("icon")
46
+ val alignment = style.optJSONObject("container")?.optString("contentVerticalAlignment")
47
+ gravity =
48
+ when (alignment) {
49
+ "top" -> Gravity.TOP
50
+ "bottom" -> Gravity.BOTTOM
51
+ else -> Gravity.CENTER_VERTICAL
52
+ }
53
+ val selector = item.json.optString("presentation") == "accountSelector"
54
+ visual.roundedGlyphOrigin = selector && item.hasExplicitHeight
55
+ val descriptors =
56
+ item.json.optJSONObject("checkbox")?.let { JSONArray().put(it) }
57
+ ?: item.json.optJSONArray("trailing")
58
+ ?: JSONArray()
59
+ accessories.bind(item, descriptors, theme, style, sourceScale, checkboxState)
60
+ // Legacy: overhanging selector icons/checkboxes must not be clipped by row padding.
61
+ clipToPadding = !accessories.requestsUnclippedHost
62
+ val hp =
63
+ if (style.has("horizontalPadding")) stylePx(style.optDouble("horizontalPadding"))
64
+ else dp(if (layout == "table") 16 else 12)
65
+ val vp =
66
+ if (style.has("verticalPadding")) stylePx(style.optDouble("verticalPadding")) else dp(8)
67
+ setPadding(hp, vp, if (style.has("horizontalPadding")) hp else accessories.endInset ?: hp, vp)
68
+ val titleParams = title.layoutParams as LayoutParams
69
+ // Legacy: the weighted title abuts the trailing accessories without a gap.
70
+ titleParams.marginEnd = 0
71
+ title.layoutParams = titleParams
72
+ val tone = item.json.optString("tone")
73
+ val token =
74
+ if (selector && tone != "primary") "secondaryText"
75
+ else if (!selector && tone == "danger") "negative" else "primaryText"
76
+ val fallback =
77
+ if (token == "negative") "#C40006D3"
78
+ else if (selector || token == "secondaryText") "#0000009B" else "#000000DF"
79
+ NativeListResolvedText.resolve(
80
+ context,
81
+ item.json.optString("title"),
82
+ style.optJSONObject("title"),
83
+ 16f,
84
+ if (selector && icon == null) "regular" else "medium",
85
+ parseNativeListColor(theme?.optString(token, fallback) ?: fallback),
86
+ 24,
87
+ 1,
88
+ sourceScale,
89
+ )
90
+ .bind(title)
91
+ title.paintFlags = titlePaintFlags
92
+ // Legacy selector typography covered every text in the row, including the
93
+ // trailing accessory text; explicit style fontSize/lineHeight stay as set.
94
+ if (selector && sourceScale) {
95
+ applyNativeListSourceTypography(title, style.optJSONObject("title"))
96
+ accessories.applySourceTypography(style)
97
+ }
98
+ visual.visibility = if (icon == null) GONE else VISIBLE
99
+ // Legacy: the 1px icon outline is kept only for a non-selector icon with an
100
+ // explicit background; selector icons use a plain 8dp rounded fill.
101
+ visual.iconBorder = !selector && icon?.has("backgroundColor") == true
102
+ if (icon != null) {
103
+ val source = JSONObject(icon.toString())
104
+ if (!source.has("backgroundColor"))
105
+ source.put(
106
+ "backgroundColor",
107
+ if (selector) theme?.optString("strongBackground", "#0000000F") ?: "#0000000F"
108
+ else "#00000000",
109
+ )
110
+ val image = JSONObject(style.optJSONObject("image")?.toString() ?: "{}")
111
+ if (selector && !image.has("cornerRadius") && !image.has("shape"))
112
+ image.put("cornerRadius", scaledDp(8f) / resources.displayMetrics.density)
113
+ visual.layoutParams =
114
+ LayoutParams(
115
+ if (image.has("width")) stylePx(image.optDouble("width"))
116
+ else dp(if (selector) 32 else 40),
117
+ if (image.has("height")) stylePx(image.optDouble("height"))
118
+ else dp(if (selector) 32 else 40),
119
+ )
120
+ .apply {
121
+ marginEnd =
122
+ if (style.has("leadingGap")) stylePx(style.optDouble("leadingGap"))
123
+ // Legacy: Yoga rounds the cumulative selector edges, not each gap.
124
+ else if (selector && item.hasExplicitHeight) dp(56) - dp(12) - dp(32)
125
+ else dp(12)
126
+ }
127
+ visual.bind(source, image, item.key, theme, false, sourceScale)
128
+ } else visual.recycle()
129
+ visual.fallbackTextView.paintFlags = fallbackPaintFlags
130
+ // Legacy selector typography also covered the leading fallback text.
131
+ if (selector && sourceScale && icon != null)
132
+ applyNativeListSourceTypography(visual.fallbackTextView, null)
133
+ }
134
+
135
+ override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
136
+ super.onLayout(changed, l, t, r, b)
137
+ val item = tag as? NativeListItem ?: return
138
+ if (
139
+ item.hasExplicitHeight &&
140
+ item.json.optString("presentation") == "accountSelector" &&
141
+ item.json
142
+ .optJSONObject("style")
143
+ ?.optJSONObject("container")
144
+ ?.has("contentVerticalAlignment") != true
145
+ ) {
146
+ for (view in listOf(title, accessories)) if (view.visibility != GONE)
147
+ view.offsetTopAndBottom(
148
+ paddingTop + (height - paddingTop - paddingBottom - view.height + 1) / 2 - view.top
149
+ )
150
+ }
151
+ }
152
+
153
+ override fun bindSelectionContent(
154
+ item: NativeListItem,
155
+ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
156
+ ) {
157
+ accessories.updateSelection(item, checkboxState)
158
+ }
159
+
160
+ override fun recycleContent() {
161
+ visual.recycle()
162
+ accessories.reset()
163
+ }
164
+
165
+ override fun disposeContent() {
166
+ visual.dispose()
167
+ accessories.reset()
168
+ }
169
+ }
@@ -0,0 +1,179 @@
1
+ package com.margelo.nitro.nativelist
2
+
3
+ import android.graphics.drawable.GradientDrawable
4
+ import android.text.Spannable
5
+ import android.text.SpannableStringBuilder
6
+ import android.text.style.AbsoluteSizeSpan
7
+ import android.view.Gravity
8
+ import android.view.View
9
+ import android.widget.LinearLayout
10
+ import com.facebook.react.uimanager.ThemedReactContext
11
+ import kotlin.math.roundToInt
12
+ import org.json.JSONObject
13
+
14
+ /** Bounded rich activity fields; no wallet or transaction semantics live here. */
15
+ internal class NativeListActivityDetailsView(private val reactContext: ThemedReactContext) : LinearLayout(reactContext) {
16
+ var onAction: ((String, View, String, Int) -> Unit)? = null
17
+ private var sourceScale = false
18
+ private val main = LinearLayout(context).apply { orientation = HORIZONTAL; gravity = Gravity.CENTER_VERTICAL }
19
+ private val visual = NativeListLeadingVisual(reactContext)
20
+ private val identity = LinearLayout(context).apply { orientation = VERTICAL }
21
+ private val titleLine = LinearLayout(context).apply { orientation = HORIZONTAL; gravity = Gravity.CENTER_VERTICAL }
22
+ private val title = NativeListTextView(context)
23
+ private val description = NativeListTextView(context)
24
+ private val status = NativeListTextView(context)
25
+ private val amounts = LinearLayout(context).apply { orientation = VERTICAL }
26
+ private val fee = LinearLayout(context).apply { orientation = VERTICAL; gravity = Gravity.END }
27
+ private val feeLabel = NativeListTextView(context)
28
+ private val feeLine = LinearLayout(context).apply { orientation = HORIZONTAL; gravity = Gravity.END }
29
+ private val feePrimary = NativeListTextView(context)
30
+ private val feeSecondary = NativeListTextView(context)
31
+ private val actions = LinearLayout(context).apply { orientation = HORIZONTAL }
32
+ private val amountViews = mutableListOf<AmountView>()
33
+ private val badges = mutableListOf<View>()
34
+
35
+ init {
36
+ orientation = VERTICAL
37
+ titleLine.addView(title, LayoutParams(0, -2, 1f))
38
+ identity.addView(titleLine)
39
+ identity.addView(description)
40
+ identity.addView(status)
41
+ feeLine.addView(feePrimary); feeLine.addView(feeSecondary)
42
+ fee.addView(feeLabel); fee.addView(feeLine)
43
+ main.addView(visual)
44
+ main.addView(identity, LayoutParams(0, -2, 1f))
45
+ main.addView(amounts)
46
+ main.addView(fee)
47
+ addView(main, LayoutParams(-1, -2))
48
+ addView(actions, LayoutParams(-1, -2))
49
+ }
50
+ private fun dp(value: Int) = if (sourceScale) (value * resources.displayMetrics.density).roundToInt() else NativeListScale.dp(resources, value)
51
+ private fun px(value: Double) = (value * resources.displayMetrics.density).roundToInt()
52
+ private fun color(tone: String, theme: JSONObject?): Int {
53
+ val (key, fallback) = when (tone) {
54
+ "positive", "success" -> "positive" to "#218358"
55
+ "negative", "danger" -> "negative" to "#CE2C31"
56
+ "secondary" -> "secondaryText" to "#646464"
57
+ "warning" -> "warning" to "#AB6400"
58
+ "info" -> "info" to "#007BEF"
59
+ else -> "primaryText" to "#202020"
60
+ }
61
+ return parseNativeListColor(theme?.optString(key, fallback) ?: fallback)
62
+ }
63
+ private fun text(label: NativeListTextView, value: String, style: JSONObject?, size: Float,
64
+ ink: Int, line: Int, weight: String = "regular", lines: Int = 1) {
65
+ NativeListResolvedText.resolve(context, value, style, size, weight, ink, line, lines, sourceScale).bind(label)
66
+ }
67
+ fun bind(item: NativeListItem, theme: JSONObject?, sourceScale: Boolean) {
68
+ this.sourceScale = sourceScale
69
+ val data = item.json
70
+ val style = data.optJSONObject("style") ?: JSONObject()
71
+ val image = style.optJSONObject("image") ?: JSONObject()
72
+ val table = data.optString("presentation") == "table"
73
+ val gap = if (style.has("leadingGap")) px(style.optDouble("leadingGap")) else dp(12)
74
+ 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.bind(data.optJSONObject("leading") ?: JSONObject(), image, item.key, theme, false, sourceScale, data.optJSONObject("secondaryLeading"))
77
+ amounts.layoutParams = if (table) LayoutParams(0, -2, 1f).apply { marginStart = gap } else LayoutParams(-2, -2).apply { marginStart = gap }
78
+ text(title, data.optString("title"), style.optJSONObject("title"), 16f, color("primary", theme), 24, "medium")
79
+ text(description, data.optString("description"), style.optJSONObject("description"), 14f, color("secondary", theme), 20, lines = 2)
80
+ text(status, data.optString("status"), style.optJSONObject("status"), 12f, color("secondary", theme), 16)
81
+ description.setOnClickListener(null)
82
+ val descriptionKey = data.optString("descriptionActionKey")
83
+ description.isClickable = descriptionKey.isNotEmpty()
84
+ if (descriptionKey.isNotEmpty()) description.setOnClickListener { onAction?.invoke(descriptionKey, description, "description", 0) }
85
+ for (view in listOf(description, status)) (view.layoutParams as LayoutParams).topMargin = if (style.has("lineGap")) px(style.optDouble("lineGap")) else 0
86
+ badges.forEach(titleLine::removeView); badges.clear()
87
+ val badgeData = data.optJSONArray("badges")
88
+ for (index in 0 until (badgeData?.length() ?: 0)) {
89
+ val descriptor = badgeData!!.getJSONObject(index)
90
+ val label = NativeListTextView(context)
91
+ val ink = color(descriptor.optString("tone"), theme)
92
+ text(label, descriptor.optString("text"), null, 12f, ink, 16, "medium")
93
+ label.setPadding(dp(4), 0, dp(4), 0)
94
+ label.background = GradientDrawable().apply { setColor((ink and 0x00ffffff) or 0x19000000); cornerRadius = dp(4).toFloat() }
95
+ titleLine.addView(label, LayoutParams(-2, -2).apply { marginStart = if (style.has("titleBadgeGap")) px(style.optDouble("titleBadgeGap")) else dp(4) })
96
+ badges.add(label)
97
+ }
98
+ val amountData = data.optJSONArray("amounts")
99
+ val count = amountData?.length() ?: 0
100
+ while (amountViews.size > count) { val child = amountViews.removeAt(amountViews.lastIndex); child.recycle(); amounts.removeView(child) }
101
+ while (amountViews.size < count) { val child = AmountView(); amountViews.add(child); amounts.addView(child) }
102
+ for (index in 0 until count) {
103
+ val descriptor = amountData!!.getJSONObject(index)
104
+ amountViews[index].bind(descriptor, "${item.key}:${descriptor.optString("key")}", style, theme, table)
105
+ amountViews[index].layoutParams = LayoutParams(-1, -2).apply { topMargin = if (index == 0) 0 else if (style.has("trailingGap")) px(style.optDouble("trailingGap")) else dp(2) }
106
+ }
107
+ val feeData = data.optJSONObject("fee")
108
+ fee.visibility = if (feeData == null) GONE else VISIBLE
109
+ fee.alpha = if (feeData?.optBoolean("hidden") == true) 0f else 1f
110
+ fee.layoutParams = LayoutParams(-2, -2).apply { marginStart = gap }
111
+ text(feeLabel, feeData?.optString("label") ?: "", style.optJSONObject("secondaryAmount"), 12f, color("secondary", theme), 16)
112
+ text(feePrimary, feeData?.optString("primary") ?: "", style.optJSONObject("secondaryAmount"), 14f, color("primary", theme), 20)
113
+ text(feeSecondary, feeData?.optString("secondary") ?: "", style.optJSONObject("secondaryAmount"), 12f, color("secondary", theme), 16)
114
+ (feeSecondary.layoutParams as LayoutParams).marginStart = dp(4)
115
+ applySegments(feePrimary, feeData?.optJSONArray("primaryTextSegments"), style.optJSONObject("secondaryAmount")?.optDouble("fontSize", 14.0) ?: 14.0)
116
+ applySegments(feeSecondary, feeData?.optJSONArray("secondaryTextSegments"), style.optJSONObject("secondaryAmount")?.optDouble("fontSize", 12.0) ?: 12.0)
117
+ actions.removeAllViews()
118
+ val actionData = data.optJSONArray("footerActions")
119
+ actions.visibility = if ((actionData?.length() ?: 0) == 0) GONE else VISIBLE
120
+ actions.layoutParams = LayoutParams(-1, -2).apply { marginStart = iw + gap; topMargin = dp(8) }
121
+ for (index in 0 until (actionData?.length() ?: 0)) {
122
+ val descriptor = actionData!!.getJSONObject(index)
123
+ val button = NativeListTextView(context)
124
+ text(button, descriptor.optString("label"), null, 14f, color(descriptor.optString("tone"), theme), 20, "medium")
125
+ button.setPadding(dp(8), dp(4), dp(8), dp(4))
126
+ button.background = GradientDrawable().apply { setColor(parseNativeListColor(theme?.optString("strongBackground", "#F0F0F0") ?: "#F0F0F0")); cornerRadius = dp(8).toFloat() }
127
+ button.isEnabled = !data.optBoolean("disabled") && !descriptor.optBoolean("disabled")
128
+ button.setOnClickListener { onAction?.invoke(descriptor.optString("key"), button, "footerAction", index) }
129
+ actions.addView(button, LayoutParams(-2, -2).apply { marginEnd = dp(8) })
130
+ }
131
+ }
132
+ private fun applySegments(label: NativeListTextView, segments: org.json.JSONArray?, fontSize: Double) {
133
+ if (segments == null || segments.length() == 0) return
134
+ val fullText = (0 until segments.length()).joinToString("") { segments.getJSONObject(it).optString("text") }
135
+ val styled = if (label.text.toString() == fullText) SpannableStringBuilder(label.text) else SpannableStringBuilder(fullText)
136
+ var start = 0
137
+ for (index in 0 until segments.length()) {
138
+ val segment = segments.getJSONObject(index)
139
+ val end = start + segment.optString("text").length
140
+ if (segment.optString("style") == "subscript") {
141
+ // Match NumberSizeableText: shrink the zero count without moving its baseline.
142
+ val size = kotlin.math.ceil(fontSize * 0.6) * label.textSize / fontSize
143
+ styled.setSpan(AbsoluteSizeSpan(size.roundToInt()), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
144
+ }
145
+ start = end
146
+ }
147
+ label.text = styled
148
+ }
149
+ fun recycle() { visual.recycle(); amountViews.forEach { it.recycle() }; description.setOnClickListener(null); actions.removeAllViews() }
150
+ fun dispose() { recycle(); visual.dispose(); amountViews.forEach { it.dispose() } }
151
+
152
+ private inner class AmountView : LinearLayout(context) {
153
+ private val leading = NativeListLeadingVisual(reactContext)
154
+ private val labels = LinearLayout(context).apply { orientation = VERTICAL }
155
+ private val primary = NativeListTextView(context)
156
+ private val secondary = NativeListTextView(context)
157
+ init {
158
+ orientation = HORIZONTAL; gravity = Gravity.CENTER_VERTICAL
159
+ labels.addView(primary); labels.addView(secondary)
160
+ addView(leading); addView(labels, LayoutParams(0, -2, 1f))
161
+ }
162
+ fun bind(data: JSONObject, key: String, style: JSONObject, theme: JSONObject?, table: Boolean) {
163
+ val visualData = data.optJSONObject("leading")
164
+ leading.visibility = if (visualData == null) GONE else VISIBLE
165
+ leading.layoutParams = LayoutParams(dp(20), dp(20)).apply { marginEnd = dp(6) }
166
+ if (visualData != null) leading.bind(visualData, JSONObject().put("width", 20).put("height", 20), key, theme, false, sourceScale) else leading.recycle()
167
+ val primaryStyle = JSONObject(style.optJSONObject("primaryAmount")?.toString() ?: "{}")
168
+ if (!primaryStyle.has("alignment")) primaryStyle.put("alignment", if (table) "start" else "end")
169
+ text(primary, data.optString("text"), primaryStyle, 16f, color(data.optString("tone"), theme), 24, "medium")
170
+ applySegments(primary, data.optJSONArray("textSegments"), primaryStyle.optDouble("fontSize", 16.0))
171
+ val secondaryStyle = JSONObject(style.optJSONObject("secondaryAmount")?.toString() ?: "{}")
172
+ if (!secondaryStyle.has("alignment")) secondaryStyle.put("alignment", if (table) "start" else "end")
173
+ text(secondary, data.optString("secondaryText"), secondaryStyle, 14f, color("secondary", theme), 20)
174
+ applySegments(secondary, data.optJSONArray("secondaryTextSegments"), secondaryStyle.optDouble("fontSize", 14.0))
175
+ }
176
+ fun recycle() { leading.recycle() }
177
+ fun dispose() { leading.dispose() }
178
+ }
179
+ }
@@ -0,0 +1,264 @@
1
+ package com.margelo.nitro.nativelist
2
+
3
+ import android.graphics.drawable.GradientDrawable
4
+ import android.text.TextUtils
5
+ import android.view.Gravity
6
+ import android.widget.LinearLayout
7
+ import com.facebook.react.uimanager.ThemedReactContext
8
+ import org.json.JSONObject
9
+
10
+ internal class NativeListActivityRowView(context: ThemedReactContext) :
11
+ NativeListRendererRowView(context) {
12
+ private val details = NativeListActivityDetailsView(context)
13
+ private val content =
14
+ LinearLayout(context).apply {
15
+ orientation = HORIZONTAL
16
+ gravity = Gravity.CENTER_VERTICAL
17
+ }
18
+ private val visual = NativeListLeadingVisual(context)
19
+ private val column = LinearLayout(context).apply { orientation = VERTICAL }
20
+ private val titleLine =
21
+ LinearLayout(context).apply {
22
+ orientation = HORIZONTAL
23
+ gravity = Gravity.CENTER_VERTICAL
24
+ }
25
+ private val title = NativeListTextView(context)
26
+ private val description = NativeListTextView(context)
27
+ private val status = NativeListTextView(context)
28
+ private val failure = NativeListTextView(context)
29
+ private val amounts =
30
+ LinearLayout(context).apply {
31
+ orientation = VERTICAL
32
+ gravity = Gravity.END
33
+ }
34
+ private val values = List(2) { NativeListTextView(context) }
35
+ private val actions = LinearLayout(context).apply { orientation = HORIZONTAL }
36
+ private val buttons = List(3) { NativeListTextView(context) }
37
+ override val assetFields = listOf("leading", "secondaryLeading", "amounts")
38
+
39
+ init {
40
+ titleLine.addView(title, LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f))
41
+ titleLine.addView(failure)
42
+ column.addView(titleLine)
43
+ column.addView(description)
44
+ column.addView(status)
45
+ values.forEach(amounts::addView)
46
+ buttons.forEach(actions::addView)
47
+ content.addView(visual)
48
+ content.addView(column, LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f))
49
+ content.addView(amounts)
50
+ addView(content, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT))
51
+ addView(actions)
52
+ addView(details, LayoutParams(-1, -2))
53
+ details.visibility = GONE
54
+ details.onAction = { key, view, source, slot -> emitAction(key, view, source, slot) }
55
+ }
56
+
57
+ override fun defaultHeight(item: NativeListItem, layout: String) =
58
+ if (item.json.has("amounts")) 0 else if ((item.json.optJSONArray("footerActions")?.length() ?: 0) > 0) 104 else 60
59
+
60
+ override fun bindContent(
61
+ item: NativeListItem,
62
+ theme: JSONObject?,
63
+ layout: String,
64
+ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
65
+ ) {
66
+ val data = item.json
67
+ val rich = data.has("amounts")
68
+ details.visibility = if (rich) VISIBLE else GONE
69
+ content.visibility = if (rich) GONE else VISIBLE
70
+ actions.visibility = if (rich) GONE else VISIBLE
71
+ if (rich) {
72
+ orientation = VERTICAL
73
+ val style = data.optJSONObject("style") ?: JSONObject()
74
+ val hp = if (style.has("horizontalPadding")) stylePx(style.optDouble("horizontalPadding")) else dp(if (data.optString("presentation") == "table") 16 else 12)
75
+ val vp = if (style.has("verticalPadding")) stylePx(style.optDouble("verticalPadding")) else dp(8)
76
+ setPadding(hp, vp, hp, vp)
77
+ visual.recycle()
78
+ details.bind(item, theme, sourceScale)
79
+ return
80
+ }
81
+ details.recycle()
82
+ val style = data.optJSONObject("style") ?: JSONObject()
83
+ val image = style.optJSONObject("image") ?: JSONObject()
84
+ fun color(name: String, fallback: String) =
85
+ parseNativeListColor(theme?.optString(name, fallback) ?: fallback)
86
+ fun fill(value: Int, radius: Int) =
87
+ GradientDrawable().apply {
88
+ setColor(value)
89
+ cornerRadius = dp(radius).toFloat()
90
+ }
91
+ fun bind(
92
+ view: NativeListTextView,
93
+ value: String,
94
+ slot: String,
95
+ size: Float,
96
+ weight: String = "regular",
97
+ ink: Int = color("secondaryText", "#0000009B"),
98
+ line: Int = 0,
99
+ lines: Int = 1,
100
+ align: String = "start",
101
+ ) {
102
+ val textStyle =
103
+ JSONObject(style.optJSONObject(slot)?.toString() ?: "{}").apply {
104
+ if (!has("alignment")) put("alignment", align)
105
+ }
106
+ NativeListResolvedText.resolve(
107
+ context,
108
+ value,
109
+ textStyle,
110
+ size,
111
+ weight,
112
+ ink,
113
+ line,
114
+ lines,
115
+ sourceScale,
116
+ )
117
+ .bind(view)
118
+ view.ellipsize =
119
+ if (textStyle.optString("truncate") == "clip") null else TextUtils.TruncateAt.END
120
+ }
121
+ orientation = VERTICAL
122
+ val hasFooterActions = (data.optJSONArray("footerActions")?.length() ?: 0) > 0
123
+ gravity =
124
+ when (style.optJSONObject("container")?.optString("contentVerticalAlignment")) {
125
+ "bottom" -> Gravity.BOTTOM
126
+ "top" -> Gravity.TOP
127
+ "center" -> Gravity.CENTER_VERTICAL
128
+ // Legacy: the footer-action column is top/start aligned.
129
+ else -> if (hasFooterActions) Gravity.START else Gravity.CENTER_VERTICAL
130
+ }
131
+ content.gravity =
132
+ when (style.optJSONObject("container")?.optString("contentVerticalAlignment")) {
133
+ "bottom" -> Gravity.BOTTOM
134
+ "top" -> Gravity.TOP
135
+ else -> Gravity.CENTER_VERTICAL
136
+ }
137
+ val hp =
138
+ if (style.has("horizontalPadding")) stylePx(style.optDouble("horizontalPadding"))
139
+ else dp(if (layout == "table") 16 else 12)
140
+ val vp =
141
+ if (style.has("verticalPadding")) stylePx(style.optDouble("verticalPadding")) else dp(8)
142
+ setPadding(hp, vp, hp, vp)
143
+ val iw = if (image.has("width")) stylePx(image.optDouble("width")) else dp(40)
144
+ val ih = if (image.has("height")) stylePx(image.optDouble("height")) else dp(40)
145
+ val gap = if (style.has("leadingGap")) stylePx(style.optDouble("leadingGap")) else dp(12)
146
+ visual.layoutParams = LayoutParams(iw, ih).apply { marginEnd = gap }
147
+ visual.bind(
148
+ // Legacy: a missing visual still reserves an empty, transparent slot.
149
+ data.optJSONObject("leading") ?: JSONObject().put("backgroundColor", "#00000000"),
150
+ image,
151
+ item.key,
152
+ theme,
153
+ false,
154
+ sourceScale,
155
+ data.optJSONObject("secondaryLeading"),
156
+ )
157
+ bind(
158
+ title,
159
+ data.optString("title"),
160
+ "title",
161
+ 16f,
162
+ "medium",
163
+ color("primaryText", "#000000DF"),
164
+ 24,
165
+ )
166
+ bind(description, data.optString("description"), "description", 14f, line = 20, lines = 2)
167
+ val failed = data.optString("status") == "Failed"
168
+ bind(status, if (failed) "" else data.optString("status"), "status", 12f)
169
+ bind(
170
+ failure,
171
+ if (failed) "Failed" else "",
172
+ "status",
173
+ 12f,
174
+ "medium",
175
+ color("negative", "#C40006D3"),
176
+ )
177
+ failure.background = fill(color("criticalBackground", "#F3000D14"), 4)
178
+ failure.setPadding(dp(8), dp(2), dp(8), dp(2))
179
+ (failure.layoutParams as LayoutParams).apply {
180
+ marginStart =
181
+ if (style.has("titleBadgeGap")) stylePx(style.optDouble("titleBadgeGap")) else 0
182
+ }
183
+ for (view in listOf(description, status)) (view.layoutParams as LayoutParams).apply {
184
+ topMargin = if (style.has("lineGap")) stylePx(style.optDouble("lineGap")) else 0
185
+ }
186
+ for ((index, slot) in listOf("primaryAmount", "secondaryAmount").withIndex()) {
187
+ val value = data.optString(slot)
188
+ bind(
189
+ values[index],
190
+ value,
191
+ slot,
192
+ if (index == 0) 16f else 14f,
193
+ if (index == 0) "medium" else "regular",
194
+ if (index == 0)
195
+ color(
196
+ if (value.startsWith("+")) "positive" else "primaryText",
197
+ if (value.startsWith("+")) "#00713FDE" else "#000000DF",
198
+ )
199
+ // Legacy: both amounts default to primaryText; only "+" amounts are positive.
200
+ else color("primaryText", "#000000DF"),
201
+ line = if (index == 0) 24 else 20,
202
+ align = "end",
203
+ )
204
+ values[index].layoutParams =
205
+ LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT).apply {
206
+ if (index > 0)
207
+ topMargin = if (style.has("trailingGap")) stylePx(style.optDouble("trailingGap")) else 0
208
+ }
209
+ }
210
+ val descriptors = data.optJSONArray("footerActions")
211
+ val count = minOf(3, descriptors?.length() ?: 0)
212
+ actions.visibility = if (count == 0) GONE else VISIBLE
213
+ actions.layoutParams =
214
+ LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT).apply {
215
+ marginStart = if (style.has("leadingGap") || image.has("width")) iw + gap else dp(52)
216
+ topMargin = if (style.has("lineGap")) stylePx(style.optDouble("lineGap")) else dp(8)
217
+ bottomMargin = dp(4)
218
+ }
219
+ for ((index, button) in buttons.withIndex()) {
220
+ button.visibility = if (index < count) VISIBLE else GONE
221
+ button.setOnClickListener(null)
222
+ if (index >= count) continue
223
+ val action = descriptors!!.getJSONObject(index)
224
+ NativeListResolvedText.resolve(
225
+ context,
226
+ action.optString("label"),
227
+ null,
228
+ // Legacy footer action: 14sp semibold on a 20dp line.
229
+ 14f,
230
+ "semibold",
231
+ color(
232
+ if (action.optString("tone") == "danger") "negative" else "primaryText",
233
+ if (action.optString("tone") == "danger") "#C40006D3" else "#000000DF",
234
+ ),
235
+ 20,
236
+ 1,
237
+ sourceScale,
238
+ )
239
+ .bind(button)
240
+ button.background = fill(color("strongBackground", "#0000000F"), 8)
241
+ button.setPadding(dp(8), dp(4), dp(8), dp(4))
242
+ button.isEnabled = !data.optBoolean("disabled") && !action.optBoolean("disabled")
243
+ button.layoutParams =
244
+ LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT).apply {
245
+ marginEnd = dp(8)
246
+ }
247
+ button.setOnClickListener {
248
+ emitAction(action.optString("key"), button, "footerAction", index)
249
+ }
250
+ }
251
+ }
252
+
253
+ override fun recycleContent() {
254
+ visual.recycle()
255
+ details.recycle()
256
+ buttons.forEach { it.setOnClickListener(null) }
257
+ }
258
+
259
+ override fun disposeContent() {
260
+ visual.dispose()
261
+ details.dispose()
262
+ buttons.forEach { it.setOnClickListener(null) }
263
+ }
264
+ }