@onekeyfe/react-native-native-list 6.7.0-alpha.359 → 6.7.0-alpha.363
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +0 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +7 -240
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +4 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +3 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +0 -12
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +7 -87
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +1 -135
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +14 -43
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +0 -25
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +2 -17
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +0 -22
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +0 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +0 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +2 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +0 -69
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +1 -55
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +29 -587
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +0 -1
- package/docs/ROW_TEMPLATES.md +9 -60
- package/docs/SPEC.md +15 -317
- package/docs/STYLE_SPEC.md +0 -6
- package/ios/HybridNativeList.swift +0 -10
- package/ios/NativeListAccessoryStack.swift +37 -220
- package/ios/NativeListActivityDetailsView.swift +8 -18
- package/ios/NativeListActivityRenderer.swift +2 -8
- package/ios/NativeListDataRowRenderer.swift +16 -128
- package/ios/NativeListDesignAssets.swift +0 -3
- package/ios/NativeListIdentityRenderer.swift +5 -123
- package/ios/NativeListLeadingVisual.swift +14 -49
- package/ios/NativeListMessageRenderer.swift +1 -34
- package/ios/NativeListModels.swift +2 -16
- package/ios/NativeListRendererRegistry.swift +0 -1
- package/ios/NativeListResolvedText.swift +1 -2
- package/ios/NativeListRowHost.swift +0 -14
- package/ios/NativeListSectionHeaderRenderer.swift +0 -88
- package/ios/RNCNativeListView.swift +29 -335
- package/ios/tests/NativeListActivityPresentationTests.swift +0 -56
- package/ios/tests/NativeListLifecycleTests.swift +3 -1283
- package/lib/module/NativeList.js +21 -39
- package/lib/module/NativeList.web.js +4 -51
- package/lib/module/models.js +0 -1
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +8 -320
- package/lib/module/web/NativeListWebEngine.js +18 -373
- package/lib/module/web/templates/ActivityRowRenderer.js +7 -8
- package/lib/module/web/templates/DataRowRenderer.js +5 -40
- package/lib/module/web/templates/IdentityRowRenderer.js +4 -90
- package/lib/module/web/templates/MessageRowRenderer.js +2 -18
- package/lib/module/web/templates/RowContainerStyle.js +0 -1
- package/lib/module/web/templates/RowRendererRegistry.js +0 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +2 -36
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +0 -9
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +0 -2
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +0 -5
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +0 -6
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +0 -7
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +0 -6
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +0 -1
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +0 -11
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +0 -2
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +0 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +0 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +0 -3
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +0 -1
- package/lib/typescript/src/NativeList.nitro.d.ts +0 -1
- package/lib/typescript/src/NativeList.types.d.ts +0 -8
- package/lib/typescript/src/models.d.ts +9 -101
- package/lib/typescript/src/validation.d.ts +0 -10
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +0 -26
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +3 -9
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +0 -9
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +0 -2
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +0 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +0 -6
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +0 -7
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +0 -6
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +0 -1
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +0 -11
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +0 -2
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +0 -2
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +0 -2
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +0 -3
- package/nitrogen/generated/shared/json/NativeListConfig.json +0 -1
- package/package.json +3 -3
- package/react-native-native-list.podspec +0 -1
- package/src/NativeList.nitro.ts +0 -1
- package/src/NativeList.tsx +24 -72
- package/src/NativeList.types.ts +0 -9
- package/src/NativeList.web.tsx +8 -72
- package/src/models.ts +3 -113
- package/src/selection.ts +0 -1
- package/src/validation.ts +6 -721
- package/src/web/NativeListWebEngine.ts +19 -568
- package/src/web/templates/ActivityRowRenderer.ts +6 -14
- package/src/web/templates/DataRowRenderer.ts +20 -93
- package/src/web/templates/IdentityRowRenderer.ts +5 -150
- package/src/web/templates/MessageRowRenderer.ts +7 -23
- package/src/web/templates/RowContainerStyle.ts +0 -2
- package/src/web/templates/RowRendererRegistry.ts +1 -11
- package/src/web/templates/SectionHeaderRowRenderer.ts +4 -47
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +0 -102
- package/ios/NativeListButtonGroupRenderer.swift +0 -89
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +0 -4
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +0 -3
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +0 -3
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +0 -47
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +0 -14
- package/src/web/templates/ButtonGroupRowRenderer.ts +0 -58
|
@@ -240,9 +240,6 @@ internal class OneKeyIconView(context: android.content.Context) : View(context)
|
|
|
240
240
|
private val selectorIconColors: Map<String, List<Int?>> =
|
|
241
241
|
mapOf(
|
|
242
242
|
"GlobusOutline" to listOf(null),
|
|
243
|
-
"GasSolid" to listOf(null),
|
|
244
|
-
"RefreshCcwOutline" to listOf(null),
|
|
245
|
-
"CryptoCoinOutline" to listOf(null, null),
|
|
246
243
|
"LockSolid" to listOf(null),
|
|
247
244
|
"GoogleIllus" to
|
|
248
245
|
listOf(
|
|
@@ -270,9 +267,6 @@ internal class OneKeyIconView(context: android.content.Context) : View(context)
|
|
|
270
267
|
private val selectorIconViewBoxes =
|
|
271
268
|
mapOf(
|
|
272
269
|
"GlobusOutline" to 24f,
|
|
273
|
-
"GasSolid" to 24f,
|
|
274
|
-
"RefreshCcwOutline" to 24f,
|
|
275
|
-
"CryptoCoinOutline" to 24f,
|
|
276
270
|
"LockSolid" to 24f,
|
|
277
271
|
"GoogleIllus" to 24f,
|
|
278
272
|
"AppleBrand" to 16f,
|
|
@@ -288,9 +282,6 @@ internal class OneKeyIconView(context: android.content.Context) : View(context)
|
|
|
288
282
|
private val actionIconFillTypes =
|
|
289
283
|
mapOf(
|
|
290
284
|
"GlobusOutline" to listOf(Path.FillType.EVEN_ODD),
|
|
291
|
-
"GasSolid" to listOf(Path.FillType.EVEN_ODD),
|
|
292
|
-
"RefreshCcwOutline" to listOf(Path.FillType.WINDING),
|
|
293
|
-
"CryptoCoinOutline" to listOf(Path.FillType.WINDING, Path.FillType.EVEN_ODD),
|
|
294
285
|
"LockSolid" to listOf(Path.FillType.EVEN_ODD),
|
|
295
286
|
"GoogleIllus" to
|
|
296
287
|
listOf(
|
|
@@ -333,19 +324,6 @@ internal class OneKeyIconView(context: android.content.Context) : View(context)
|
|
|
333
324
|
// Exact 24x24 paths from app-monorepo packages/components Icon sources.
|
|
334
325
|
private val iconPaths =
|
|
335
326
|
mapOf(
|
|
336
|
-
"RefreshCcwOutline" to
|
|
337
|
-
listOf(
|
|
338
|
-
"M5 12a7 7 0 0 0 7 7 7.15 7.15 0 0 0 4.955-2h-2.943v-2h6v6h-2v-2.257A9.148 9.148 0 0 1 12 21a9 9 0 0 1-9-9v-1h2v1Zm1-6.754A9.148 9.148 0 0 1 12 3a9 9 0 0 1 9 9v1h-2v-1a7 7 0 0 0-7-7 7.15 7.15 0 0 0-4.955 2H10v2H4V3h2v2.246Z"
|
|
339
|
-
),
|
|
340
|
-
"GasSolid" to
|
|
341
|
-
listOf(
|
|
342
|
-
"M15 9h4v7h1V8.414L17.586 6 19 4.586l3 3V18h-5v-7h-2v8h1v2H2v-2h1V3h12zM6 9v2h6V9z"
|
|
343
|
-
),
|
|
344
|
-
"CryptoCoinOutline" to
|
|
345
|
-
listOf(
|
|
346
|
-
"M11 16.387a4.5 4.5 0 0 1 0-8.775V6h2v1.613a4.5 4.5 0 0 1 2.856 2.067l-1.712 1.032a2.5 2.5 0 1 0 0 2.576l1.712 1.032A4.5 4.5 0 0 1 13 16.386V18h-2z",
|
|
347
|
-
"M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10m-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0",
|
|
348
|
-
),
|
|
349
327
|
// OneKey patch: official selector SVG path geometry.
|
|
350
328
|
"GlobusOutline" to
|
|
351
329
|
listOf(
|
|
@@ -17,7 +17,6 @@ internal object NativeListRendererRegistry {
|
|
|
17
17
|
NativeListRendererKey.ACTIVITY to ::NativeListActivityRowView,
|
|
18
18
|
NativeListRendererKey.SYSTEM to ::NativeListSystemRowView,
|
|
19
19
|
NativeListRendererKey.ACTION to ::NativeListActionRowView,
|
|
20
|
-
NativeListRendererKey.BUTTON_GROUP to ::NativeListButtonGroupRowView,
|
|
21
20
|
)
|
|
22
21
|
|
|
23
22
|
private val keys =
|
|
@@ -34,7 +33,6 @@ internal object NativeListRendererRegistry {
|
|
|
34
33
|
"activity" to NativeListRendererKey.ACTIVITY,
|
|
35
34
|
"system" to NativeListRendererKey.SYSTEM,
|
|
36
35
|
"action" to NativeListRendererKey.ACTION,
|
|
37
|
-
"buttonGroup" to NativeListRendererKey.BUTTON_GROUP,
|
|
38
36
|
)
|
|
39
37
|
|
|
40
38
|
fun key(type: String) = keys.getValue(type)
|
|
@@ -106,8 +106,6 @@ internal abstract class NativeListRendererRowView(protected val reactContext: Th
|
|
|
106
106
|
protected open val pressedColorName = "rowPressedBackground"
|
|
107
107
|
protected open val pressedColorFallback = "#00000017"
|
|
108
108
|
private var current: NativeListItem? = null
|
|
109
|
-
protected val boundItem: NativeListItem?
|
|
110
|
-
get() = current
|
|
111
109
|
private var theme: JSONObject? = null
|
|
112
110
|
private var listLayout = "linear"
|
|
113
111
|
private var itemIndex: Int? = null
|
|
@@ -52,7 +52,7 @@ internal data class NativeListResolvedText(
|
|
|
52
52
|
view.letterSpacing = 0f
|
|
53
53
|
view.gravity = gravity
|
|
54
54
|
view.opticalOffsetY = offset
|
|
55
|
-
view.maxLines =
|
|
55
|
+
view.maxLines = lines
|
|
56
56
|
view.setHorizontallyScrolling(lines == 1 && explicitTruncation)
|
|
57
57
|
view.ellipsize = if (explicitTruncation && !clip) TextUtils.TruncateAt.END else null
|
|
58
58
|
view.setLineSpacing(0f, 1f)
|
|
@@ -87,8 +87,7 @@ internal data class NativeListResolvedText(
|
|
|
87
87
|
sourceScale: Boolean,
|
|
88
88
|
): NativeListResolvedText {
|
|
89
89
|
val density = context.resources.displayMetrics.density
|
|
90
|
-
val
|
|
91
|
-
val maxLines = if (requestedLines == 0) 0 else requestedLines.coerceIn(1, 3)
|
|
90
|
+
val maxLines = (style?.optInt("lines", lines) ?: lines).coerceIn(1, 3)
|
|
92
91
|
val truncation = style?.let { it.has("lines") || it.has("truncate") } == true
|
|
93
92
|
val fontSize =
|
|
94
93
|
if (style?.has("fontSize") == true) (style.optDouble("fontSize") * density).toFloat()
|
|
@@ -26,7 +26,6 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
26
26
|
private val mainColumn = LinearLayout(context)
|
|
27
27
|
private val titleLine = PackedTitleLineLayout(context)
|
|
28
28
|
private val title = DottedUnderlineTextView(context)
|
|
29
|
-
private val leadingBadge = NativeListTextView(context)
|
|
30
29
|
private val titleSpinner = ProgressBar(context, null, android.R.attr.progressBarStyleSmall).apply {
|
|
31
30
|
isIndeterminate = true
|
|
32
31
|
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
|
|
@@ -166,12 +165,6 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
166
165
|
currentTheme = theme
|
|
167
166
|
currentLayout = layout
|
|
168
167
|
removeAllViews()
|
|
169
|
-
if (trailingViews[0].parent === titleLine) {
|
|
170
|
-
titleLine.removeView(trailingViews[0])
|
|
171
|
-
trailingColumn.addView(trailingViews[0], 0)
|
|
172
|
-
}
|
|
173
|
-
titleLine.removeView(leadingBadge)
|
|
174
|
-
leadingBadge.text = ""
|
|
175
168
|
titleLine.removeView(headerTitleIcon)
|
|
176
169
|
trailingColumn.removeView(headerValueIcon)
|
|
177
170
|
paintDefaults.forEach { (view, flags) -> view.paintFlags = flags }
|
|
@@ -195,10 +188,6 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
195
188
|
view.ellipsize = null
|
|
196
189
|
view.setHorizontallyScrolling(false)
|
|
197
190
|
view.opticalOffsetY = 0f
|
|
198
|
-
view.helpBindingGeneration += 1
|
|
199
|
-
view.guardsHelpTouches = false
|
|
200
|
-
view.primaryHelpOnly = false
|
|
201
|
-
view.showsHelpUnderline = false
|
|
202
191
|
view.gravity = Gravity.START
|
|
203
192
|
view.letterSpacing = 0f
|
|
204
193
|
view.fontFeatureSettings = "tnum"
|
|
@@ -302,7 +291,6 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
302
291
|
}
|
|
303
292
|
}
|
|
304
293
|
applyTextStyle(item)
|
|
305
|
-
bindPositionHeaderFields(item, theme)
|
|
306
294
|
titleSpinner.indeterminateTintList = ColorStateList.valueOf(title.currentTextColor)
|
|
307
295
|
style
|
|
308
296
|
.optJSONObject("container")
|
|
@@ -319,57 +307,6 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
319
307
|
applySelectorTypography(item)
|
|
320
308
|
}
|
|
321
309
|
|
|
322
|
-
private fun bindPositionHeaderFields(item: NativeListItem, theme: JSONObject?) {
|
|
323
|
-
val style = item.json.optJSONObject("style") ?: JSONObject()
|
|
324
|
-
item.json.optJSONObject("leadingBadge")?.let { badge ->
|
|
325
|
-
leadingBadge.text = badge.optString("text")
|
|
326
|
-
leadingBadge.textSize = sp(12f)
|
|
327
|
-
leadingBadge.typeface = fonts.medium(context)
|
|
328
|
-
leadingBadge.includeFontPadding = false
|
|
329
|
-
val tones = mapOf("info" to ("info" to "#0F69F6"), "success" to ("positive" to "#008F5A"), "warning" to ("caution" to "#A35E00"), "danger" to ("negative" to "#CE2C31"))
|
|
330
|
-
val tone = tones[badge.optString("tone")]
|
|
331
|
-
if (tone != null) {
|
|
332
|
-
val tint = color(theme, tone.first, tone.second)
|
|
333
|
-
leadingBadge.setTextColor(tint)
|
|
334
|
-
val fallback = (tint and 0x00FFFFFF) or (31 shl 24)
|
|
335
|
-
val fill = if (badge.optString("tone") == "success" && theme?.has("successBackground") == true)
|
|
336
|
-
safeColor(theme.optString("successBackground"), fallback) else fallback
|
|
337
|
-
leadingBadge.background = roundedFill(fill, 4f)
|
|
338
|
-
} else {
|
|
339
|
-
leadingBadge.setTextColor(color(theme, "secondaryText", "#0000009B"))
|
|
340
|
-
leadingBadge.background = roundedFill(color(theme, "strongBackground", "#0000000F"), 4f)
|
|
341
|
-
}
|
|
342
|
-
leadingBadge.setPadding(dp(8), dp(2), dp(8), dp(2))
|
|
343
|
-
TextViewCompat.setLineHeight(leadingBadge, dp(16))
|
|
344
|
-
titleLine.addView(leadingBadge, 0, LayoutParams(LayoutParams.WRAP_CONTENT, dp(20)).apply { marginEnd = dp(8) })
|
|
345
|
-
}
|
|
346
|
-
if (style.has("titleDecoration")) {
|
|
347
|
-
title.showsDottedUnderline = false
|
|
348
|
-
title.showsHelpUnderline = style.optString("titleDecoration") == "dashed"
|
|
349
|
-
title.setPadding(0, 0, 0, if (title.showsHelpUnderline) dp(3) else 0)
|
|
350
|
-
}
|
|
351
|
-
val value = trailingViews[0]
|
|
352
|
-
if (style.optString("valuePlacement") == "afterTitle") {
|
|
353
|
-
trailingColumn.removeView(value)
|
|
354
|
-
title.layoutParams = wrap()
|
|
355
|
-
titleLine.packsChildrenAtStart = false
|
|
356
|
-
titleLine.addView(value, wrap().apply { marginStart = dp(8) })
|
|
357
|
-
}
|
|
358
|
-
item.json.optJSONObject("valueHelp")?.let { help ->
|
|
359
|
-
value.guardsHelpTouches = true
|
|
360
|
-
value.setOnClickListener(null)
|
|
361
|
-
value.isClickable = false
|
|
362
|
-
value.showsHelpUnderline = help.optString("underline") == "dashed"
|
|
363
|
-
if (help.optString("presentation") == "popover") {
|
|
364
|
-
value.setOnClickListener {
|
|
365
|
-
currentItem?.takeUnless { it.json.optBoolean("disabled") }?.let {
|
|
366
|
-
emitAction(it, help.optString("actionKey"), null, value, "trailingAccessory", 0)
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
310
|
private fun applyTextStyle(item: NativeListItem) {
|
|
374
311
|
val style = item.json.optJSONObject("style") ?: return
|
|
375
312
|
for ((slot, view) in
|
|
@@ -474,12 +411,6 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
|
|
|
474
411
|
override fun recycleContent() {
|
|
475
412
|
checkboxControl.reset()
|
|
476
413
|
currentItem = null
|
|
477
|
-
title.setOnClickListener(null)
|
|
478
|
-
title.isClickable = false
|
|
479
|
-
trailingViews[0].helpBindingGeneration += 1
|
|
480
|
-
trailingViews[0].setOnClickListener(null)
|
|
481
|
-
trailingViews[0].isClickable = false
|
|
482
|
-
trailingViews[0].showsHelpUnderline = false
|
|
483
414
|
titleSpinner.visibility = GONE
|
|
484
415
|
}
|
|
485
416
|
|
|
@@ -1,62 +1,9 @@
|
|
|
1
1
|
package com.margelo.nitro.nativelist
|
|
2
2
|
|
|
3
3
|
import android.graphics.Canvas
|
|
4
|
-
import android.graphics.DashPathEffect
|
|
5
|
-
import android.graphics.Paint
|
|
6
|
-
import android.graphics.RectF
|
|
7
|
-
import android.view.MotionEvent
|
|
8
4
|
import android.widget.TextView
|
|
9
5
|
|
|
10
6
|
internal open class NativeListTextView(context: android.content.Context) : TextView(context) {
|
|
11
|
-
var helpBindingGeneration = 0
|
|
12
|
-
var guardsHelpTouches = false
|
|
13
|
-
private var helpDownGeneration = -1
|
|
14
|
-
var primaryHelpOnly = false
|
|
15
|
-
var showsHelpUnderline = false
|
|
16
|
-
set(value) { field = value; invalidate() }
|
|
17
|
-
private val helpPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
|
18
|
-
style = Paint.Style.STROKE
|
|
19
|
-
strokeWidth = resources.displayMetrics.density
|
|
20
|
-
pathEffect = DashPathEffect(floatArrayOf(3 * strokeWidth, 2 * strokeWidth), 0f)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
val helpAnchorBounds: RectF?
|
|
24
|
-
get() {
|
|
25
|
-
if (!primaryHelpOnly) return null
|
|
26
|
-
val textLayout = layout ?: return null
|
|
27
|
-
if (textLayout.lineCount == 0) return null
|
|
28
|
-
return RectF(
|
|
29
|
-
totalPaddingLeft + textLayout.getLineLeft(0),
|
|
30
|
-
(totalPaddingTop + textLayout.getLineTop(0)).toFloat() + opticalOffsetY,
|
|
31
|
-
totalPaddingLeft + textLayout.getLineRight(0),
|
|
32
|
-
(totalPaddingTop + textLayout.getLineBottom(0)).toFloat() + opticalOffsetY,
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
override fun onTouchEvent(event: MotionEvent): Boolean {
|
|
37
|
-
if (primaryHelpOnly && event.actionMasked == MotionEvent.ACTION_DOWN &&
|
|
38
|
-
helpAnchorBounds?.contains(event.x, event.y) != true) return false
|
|
39
|
-
if (guardsHelpTouches) {
|
|
40
|
-
if (event.actionMasked == MotionEvent.ACTION_DOWN) helpDownGeneration = helpBindingGeneration
|
|
41
|
-
if (event.actionMasked == MotionEvent.ACTION_UP && helpDownGeneration != helpBindingGeneration) {
|
|
42
|
-
isPressed = false
|
|
43
|
-
return true
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return super.onTouchEvent(event)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private fun drawHelpUnderline(canvas: Canvas) {
|
|
50
|
-
if (!showsHelpUnderline) return
|
|
51
|
-
val textLayout = layout ?: return
|
|
52
|
-
if (textLayout.lineCount == 0) return
|
|
53
|
-
helpPaint.color = currentTextColor
|
|
54
|
-
val left = totalPaddingLeft + textLayout.getLineLeft(0)
|
|
55
|
-
val right = totalPaddingLeft + textLayout.getLineRight(0)
|
|
56
|
-
val bottom = totalPaddingTop + textLayout.getLineBottom(0) - resources.displayMetrics.density
|
|
57
|
-
canvas.drawLine(left, bottom, right, bottom, helpPaint)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
7
|
var rowHorizontallyScrolling = false
|
|
61
8
|
private set
|
|
62
9
|
|
|
@@ -69,11 +16,10 @@ internal open class NativeListTextView(context: android.content.Context) : TextV
|
|
|
69
16
|
set(value) { field = value; invalidate() }
|
|
70
17
|
|
|
71
18
|
override fun onDraw(canvas: Canvas) {
|
|
72
|
-
if (opticalOffsetY == 0f) { super.onDraw(canvas);
|
|
19
|
+
if (opticalOffsetY == 0f) { super.onDraw(canvas); return }
|
|
73
20
|
val checkpoint = canvas.save()
|
|
74
21
|
canvas.translate(0f, opticalOffsetY)
|
|
75
22
|
super.onDraw(canvas)
|
|
76
|
-
drawHelpUnderline(canvas)
|
|
77
23
|
canvas.restoreToCount(checkpoint)
|
|
78
24
|
}
|
|
79
25
|
}
|