@onekeyfe/react-native-native-list 6.8.0-13 → 6.8.0-15

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 (45) hide show
  1. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +18 -4
  2. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +21 -7
  3. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +3 -2
  4. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +8 -1
  5. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
  6. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
  7. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
  8. package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
  9. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
  10. package/docs/SPEC.md +113 -2
  11. package/docs/STYLE_SPEC.md +7 -1
  12. package/ios/NativeListAccessoryStack.swift +22 -0
  13. package/ios/NativeListDataRowRenderer.swift +12 -5
  14. package/ios/NativeListIdentityRenderer.swift +36 -58
  15. package/ios/NativeListLeadingVisual.swift +8 -0
  16. package/ios/NativeListMarketRenderer.swift +6 -2
  17. package/ios/NativeListModels.swift +7 -0
  18. package/ios/NativeListResolvedText.swift +9 -7
  19. package/ios/NativeListSectionHeaderRenderer.swift +9 -43
  20. package/ios/NativeListTextStyles.swift +72 -12
  21. package/ios/RNCNativeListView.swift +124 -20
  22. package/ios/tests/NativeListLifecycleTests.swift +105 -0
  23. package/lib/module/validation.js +21 -10
  24. package/lib/module/web/NativeListWebEngine.js +213 -23
  25. package/lib/module/web/templates/ActivityRowRenderer.js +1 -1
  26. package/lib/module/web/templates/IdentityRowRenderer.js +12 -1
  27. package/lib/module/web/templates/MarketRowRenderer.js +2 -0
  28. package/lib/module/web/templates/MediaTileRowRenderer.js +1 -0
  29. package/lib/module/web/templates/RowElements.js +2 -2
  30. package/lib/module/web/templates/RowText.js +2 -0
  31. package/lib/typescript/src/models.d.ts +15 -1
  32. package/lib/typescript/src/web/NativeListWebEngine.d.ts +8 -1
  33. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +6 -2
  34. package/lib/typescript/src/web/templates/RowVisual.d.ts +1 -1
  35. package/package.json +1 -1
  36. package/src/models.ts +15 -0
  37. package/src/validation.ts +67 -4
  38. package/src/web/NativeListWebEngine.ts +382 -27
  39. package/src/web/templates/ActivityRowRenderer.ts +1 -1
  40. package/src/web/templates/IdentityRowRenderer.ts +23 -1
  41. package/src/web/templates/MarketRowRenderer.ts +2 -0
  42. package/src/web/templates/MediaTileRowRenderer.ts +1 -0
  43. package/src/web/templates/RowElements.ts +3 -2
  44. package/src/web/templates/RowText.ts +6 -0
  45. package/src/web/templates/RowVisual.ts +2 -1
@@ -255,10 +255,12 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
255
255
  v.ellipsize = null
256
256
  v.setLineSpacing(0f, 1f)
257
257
  v.letterSpacing = 0f
258
+ v.fontFeatureSettings = null
258
259
  }
259
260
  trailingIcons.forEach {
260
261
  it.visibility = GONE
261
262
  it.setOnClickListener(null)
263
+ it.setTag(R.id.onekey_native_list_reorder_handle, null)
262
264
  it.background = null
263
265
  it.useSourceScale = selectorUsesSourceScale
264
266
  it.glyphSizeDp = null
@@ -441,13 +443,20 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
441
443
  theme,
442
444
  )
443
445
  "menu" -> showTrailingMenu(textIndex++, accessory.optString("actionKey"))
444
- "drag" ->
446
+ "drag" -> {
447
+ val handleIndex = textIndex++
445
448
  showTrailingIcon(
446
- textIndex++,
449
+ handleIndex,
447
450
  item,
448
- JSONObject(accessory.toString()).apply { put("name", "DragOutline") },
451
+ // ListItem draws the handle as a medium tertiary IconButton.
452
+ JSONObject(accessory.toString()).apply {
453
+ put("name", "DragOutline")
454
+ put("buttonStyle", "tertiary")
455
+ },
449
456
  theme,
450
457
  )
458
+ trailingIcons.getOrNull(handleIndex)?.setTag(R.id.onekey_native_list_reorder_handle, true)
459
+ }
451
460
  "icon" -> showTrailingIcon(textIndex++, item, accessory, theme)
452
461
  "spinner" -> spinner.visibility = VISIBLE
453
462
  "progress" ->
@@ -719,9 +728,13 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
719
728
  icon.contentDescription = data.optString("accessibilityLabel").takeIf { it.isNotEmpty() }
720
729
  if (data.optString("buttonStyle") == "tertiary") {
721
730
  icon.glyphSizeDp = 24
731
+ // A rename + drag pair sits in ListItem's <XStack gap="$6">: 24dp between
732
+ // the buttons' 24dp layout slots, after the second frame's m=-7.
733
+ val pairGap =
734
+ orientation == HORIZONTAL && index > 0 && data.optString("name") == "DragOutline"
722
735
  icon.layoutParams = LayoutParams(dp(38), dp(38)).apply {
723
736
  gravity = Gravity.CENTER_VERTICAL
724
- marginStart = -dp(7)
737
+ marginStart = if (pairGap) dp(24) - dp(7) else -dp(7)
725
738
  marginEnd = -dp(7)
726
739
  }
727
740
  icon.background = StateListDrawable().apply {
@@ -895,6 +908,7 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
895
908
  if (style.has("offsetY"))
896
909
  (view as? NativeListTextView)?.opticalOffsetY =
897
910
  (style.optDouble("offsetY") * resources.displayMetrics.density).toFloat()
911
+ applyNativeListTextSpacing(view, style, view.fontFeatureSettings)
898
912
  style.optString("alignment").takeIf(String::isNotEmpty)?.let {
899
913
  view.gravity =
900
914
  (view.gravity and Gravity.VERTICAL_GRAVITY_MASK) or
@@ -366,11 +366,12 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
366
366
  return
367
367
  fun visit(view: View) {
368
368
  if (view is TextView) {
369
- view.fontFeatureSettings = "tnum"
370
369
  if (sourceScale) {
371
370
  paintDefaults.putIfAbsent(view, view.paintFlags)
372
371
  // Explicit style fontSize/lineHeight are kept as the caller set them.
373
372
  applyNativeListSourceTypography(view, explicitStyle(view))
373
+ } else {
374
+ applyNativeListTextSpacing(view, explicitStyle(view))
374
375
  }
375
376
  }
376
377
  if (view is ViewGroup) for (i in 0 until view.childCount) visit(view.getChildAt(i))
@@ -393,7 +394,13 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
393
394
  }
394
395
  leadingFrame.bitmapBorderWidth =
395
396
  if (descriptor.optString("borderColor").isNotEmpty() &&
396
- descriptor.optString("borderStyle") != "dashed") dp(1) else 0
397
+ descriptor.optString("borderStyle") != "dashed") {
398
+ // Optional borderWidth (logical units); a hairline still draws one physical pixel.
399
+ descriptor.optDouble("borderWidth", Double.NaN)
400
+ .takeIf { it.isFinite() && it > 0 && it <= 4 }
401
+ ?.let { (it * resources.displayMetrics.density).roundToInt().coerceAtLeast(1) }
402
+ ?: dp(1)
403
+ } else 0
397
404
  if (visual == null) leadingFrame.recycle()
398
405
  val item = currentItem!!
399
406
  val style = item.json.optJSONObject("style")?.optJSONObject("image") ?: JSONObject()
@@ -722,11 +729,11 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
722
729
  leadingActionIcon.setOnClickListener {
723
730
  emitAction(item, action.optString("actionKey"), null, leadingActionIcon, "leadingAction")
724
731
  }
725
- // ListItem.IconButton is 36dp with 6dp inner padding and m=-7. Keep the
726
- // full button frame but absorb its leading negative margin into the row
727
- // padding and its trailing margin into the following gap.
728
- setPadding(dp(5), paddingTop, paddingRight, paddingBottom)
729
- addView(leadingActionIcon, LayoutParams(dp(36), dp(36)).apply { marginEnd = dp(5) })
732
+ // ListItem.IconButton is 38dp (6dp padding plus a 1dp border) with m=-7,
733
+ // so its glyph sits on a 24dp slot at the 12dp padding. This 36dp frame
734
+ // centers the same glyph with a 6dp inset and a 6dp following gap.
735
+ setPadding(dp(6), paddingTop, paddingRight, paddingBottom)
736
+ addView(leadingActionIcon, LayoutParams(dp(36), dp(36)).apply { marginEnd = dp(6) })
730
737
  }
731
738
  addLeading(
732
739
  leading,
@@ -921,6 +928,12 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
921
928
  ),
922
929
  )
923
930
  trailingColumn.endInset?.let { setPadding(paddingLeft, paddingTop, it, paddingBottom) }
931
+ // ListItem keeps 12dp between the text and a tertiary button's 24dp slot; the
932
+ // button's m=-7 would otherwise pull its slot over the text column.
933
+ val first = accessories.optJSONObject(0)
934
+ if (first?.optString("kind") == "drag" || first?.optString("buttonStyle") == "tertiary") {
935
+ (mainColumn.layoutParams as LayoutParams).marginEnd = dp(12)
936
+ }
924
937
  }
925
938
 
926
939
  private fun applyValueSegments(
@@ -1021,6 +1034,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
1021
1034
  if (style.has("offsetY"))
1022
1035
  (view as? NativeListTextView)?.opticalOffsetY =
1023
1036
  (style.optDouble("offsetY") * resources.displayMetrics.density).toFloat()
1037
+ applyNativeListTextSpacing(view, style)
1024
1038
  style.optString("alignment").takeIf(String::isNotEmpty)?.let {
1025
1039
  view.gravity =
1026
1040
  (view.gravity and Gravity.VERTICAL_GRAVITY_MASK) or
@@ -401,10 +401,10 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
401
401
  defaultAlignment: String,
402
402
  ) {
403
403
  view.includeFontPadding = false
404
- view.fontFeatureSettings = "tnum"
405
404
  view.textSize =
406
405
  sp(style?.optDouble("fontSize", defaultSize.toDouble())?.toFloat() ?: defaultSize)
407
406
  view.typeface = marketTypeface(style?.optString("fontWeight").orEmpty(), defaultWeight)
407
+ applyNativeListTextSpacing(view, style)
408
408
  view.setTextColor(safeColor(style?.optString("color"), defaultColor))
409
409
  val alignment = style?.optString("alignment", defaultAlignment) ?: defaultAlignment
410
410
  view.gravity =
@@ -437,6 +437,7 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
437
437
  kotlin.math.ceil(sourceSize.toDouble()).toFloat(),
438
438
  )
439
439
  }
440
+ applyNativeListTextSpacing(view, style)
440
441
  // Legacy parity: keep marketText's subscript AbsoluteSizeSpan (ceil(0.6 x fontSize)).
441
442
  val text = SpannableStringBuilder(view.text)
442
443
  text.getSpans(0, text.length, NativeListLineHeightSpan::class.java).forEach(text::removeSpan)
@@ -703,8 +704,8 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
703
704
  }
704
705
  badgeLabel.text = text
705
706
  // OneKey patch: match SizableText's tabular numerals only for explicit Market metrics.
706
- badgeLabel.fontFeatureSettings = if (badgeStyle != null) "tnum" else null
707
707
  badgeLabel.textSize = sp(badgeStyle?.optDouble("fontSize", 11.0)?.toFloat() ?: 11f)
708
+ applyNativeListTextSpacing(badgeLabel, badgeStyle, if (badgeStyle != null) "tnum" else null)
708
709
  badgeLabel.typeface =
709
710
  marketTypeface(badgeStyle?.optString("fontWeight").orEmpty(), "medium")
710
711
  if (badgeStyle?.has("lineHeight") == true) {
@@ -197,7 +197,8 @@ internal fun nativeListIdentityTrailingIsHorizontal(
197
197
  first.actionKey.isEmpty()) ||
198
198
  (kinds == listOf("icon", "icon") &&
199
199
  first.name == "PencilOutline" &&
200
- second.name == "DragOutline")
200
+ second.name == "DragOutline") ||
201
+ (kinds == listOf("icon", "drag") && first.name == "PencilOutline")
201
202
  }
202
203
 
203
204
  internal fun resolveNativeListSelectorBackgroundColor(
@@ -330,6 +331,8 @@ internal data class NativeListConfig(
330
331
  val rowPressToggles: Boolean,
331
332
  val selectedKeys: LinkedHashSet<String>,
332
333
  val reorderable: Boolean,
334
+ /** `handle` starts a reorder only from a long press on a trailing `drag` accessory. */
335
+ val reorderFromHandleOnly: Boolean = false,
333
336
  val pullToRefresh: Boolean,
334
337
  val refreshTriggerDistance: Double? = null,
335
338
  val refreshing: Boolean,
@@ -377,6 +380,9 @@ internal data class NativeListConfig(
377
380
  val layout = root.getJSONObject("layout")
378
381
  val selection = root.optJSONObject("selection")
379
382
  val capabilities = root.optJSONObject("capabilities")
383
+ val reorderActivation = capabilities?.opt("reorderActivation")
384
+ require(reorderActivation == null || reorderActivation == "row" ||
385
+ reorderActivation == "handle") { "Invalid reorderActivation" }
380
386
  val sectionIndex = capabilities?.optJSONObject("sectionIndex")
381
387
  val rowArray = root.getJSONArray("rows")
382
388
  val items = ArrayList<NativeListItem>(rowArray.length())
@@ -410,6 +416,7 @@ internal data class NativeListConfig(
410
416
  rowPressToggles = selection?.optBoolean("rowPressToggles", false) ?: false,
411
417
  selectedKeys = selectedKeys,
412
418
  reorderable = capabilities?.optBoolean("reorderable", false) ?: false,
419
+ reorderFromHandleOnly = reorderActivation == "handle",
413
420
  pullToRefresh = capabilities?.optBoolean("pullToRefresh", false) ?: false,
414
421
  refreshTriggerDistance = capabilities?.optDouble("refreshTriggerDistance")?.takeIf { it.isFinite() && it > 0 },
415
422
  refreshing = capabilities?.optBoolean("refreshing", false) ?: false,
@@ -42,6 +42,7 @@ internal data class NativeListResolvedText(
42
42
  val clip: Boolean,
43
43
  val gravity: Int,
44
44
  val offset: Float,
45
+ private val style: JSONObject?,
45
46
  ) {
46
47
  /** Offset into [text] for a UTF-16 offset into the [source] it was resolved from. */
47
48
  fun displayOffset(sourceOffset: Long, source: String): Int =
@@ -49,11 +50,10 @@ internal data class NativeListResolvedText(
49
50
 
50
51
  fun bind(view: NativeListTextView) {
51
52
  view.includeFontPadding = false
52
- view.fontFeatureSettings = "tnum"
53
53
  view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
54
54
  view.typeface = typeface
55
55
  view.setTextColor(color)
56
- view.letterSpacing = 0f
56
+ applyNativeListTextSpacing(view, style)
57
57
  view.gravity = gravity
58
58
  view.opticalOffsetY = offset
59
59
  view.maxLines = if (lines == 0) Int.MAX_VALUE else lines
@@ -137,11 +137,32 @@ internal data class NativeListResolvedText(
137
137
  style?.optString("truncate") == "clip",
138
138
  horizontal or vertical,
139
139
  ((style?.optDouble("offsetY", 0.0) ?: 0.0) * density).toFloat(),
140
+ style,
140
141
  )
141
142
  }
142
143
  }
143
144
  }
144
145
 
146
+ /** Apply tracking after the final font size, then rebuild font features for this binding. */
147
+ internal fun applyNativeListTextSpacing(
148
+ view: TextView,
149
+ style: JSONObject?,
150
+ defaultFeatures: String? = "tnum",
151
+ defaultLetterSpacing: Float = 0f,
152
+ ) {
153
+ val tracking = style?.optDouble("letterSpacing")?.takeIf { it.isFinite() }
154
+ val digitFeatures = when {
155
+ style?.has("tabularNumbers") != true -> defaultFeatures
156
+ style.optBoolean("tabularNumbers") -> "tnum"
157
+ else -> "'tnum' 0, 'pnum' 1"
158
+ }
159
+ view.fontFeatureSettings = if (tracking == null) digitFeatures else
160
+ listOfNotNull(digitFeatures, "'kern' 0").joinToString(", ")
161
+ view.letterSpacing = if (tracking != null && view.textSize > 0f)
162
+ (tracking * view.resources.displayMetrics.density / view.textSize).toFloat()
163
+ else defaultLetterSpacing
164
+ }
165
+
145
166
  /**
146
167
  * Legacy selector source-scale typography (accountSelector / networkSelector /
147
168
  * walletSidebar with source scaling): whole-pixel unscaled font size, unhinted
@@ -158,7 +179,7 @@ internal fun applyNativeListSourceTypography(view: TextView, style: JSONObject?)
158
179
  TypedValue.COMPLEX_UNIT_PX,
159
180
  kotlin.math.ceil((view.textSize * metrics.density / metrics.scaledDensity).toDouble()).toFloat(),
160
181
  )
161
- view.letterSpacing = 0f
182
+ applyNativeListTextSpacing(view, style)
162
183
  if (style?.has("lineHeight") != true && view.text.isNotEmpty()) {
163
184
  val text = SpannableStringBuilder(view.text)
164
185
  text.getSpans(0, text.length, NativeListLineHeightSpan::class.java).forEach(text::removeSpan)
@@ -773,6 +773,7 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
773
773
  if (style.has("offsetY"))
774
774
  (view as? NativeListTextView)?.opticalOffsetY =
775
775
  (style.optDouble("offsetY") * resources.displayMetrics.density).toFloat()
776
+ applyNativeListTextSpacing(view, style, defaultLetterSpacing = view.letterSpacing)
776
777
  style.optString("alignment").takeIf(String::isNotEmpty)?.let {
777
778
  view.gravity =
778
779
  (view.gravity and Gravity.VERTICAL_GRAVITY_MASK) or
@@ -790,15 +791,21 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
790
791
  setOf("accountSelector", "networkSelector", "walletSidebar")
791
792
  )
792
793
  return
794
+ val rowStyle = item.json.optJSONObject("style")
793
795
  fun visit(view: View) {
794
796
  if (view is TextView) {
795
- view.fontFeatureSettings = "tnum"
797
+ val explicit = when (view) {
798
+ title -> rowStyle?.optJSONObject("title")
799
+ subtitle -> rowStyle?.optJSONObject("subtitle")
800
+ trailingViews[0] -> rowStyle?.optJSONObject("value")
801
+ else -> null
802
+ }
796
803
  if (sourceScale) {
797
804
  paintDefaults.putIfAbsent(view, view.paintFlags)
798
805
  view.paintFlags = view.paintFlags or Paint.SUBPIXEL_TEXT_FLAG or Paint.LINEAR_TEXT_FLAG
799
806
  val (fontSize, line) =
800
807
  selectorTextMetrics.getOrPut(view) { view.textSize to view.lineHeight }
801
- view.setTextSize(
808
+ if (explicit?.has("fontSize") != true) view.setTextSize(
802
809
  TypedValue.COMPLEX_UNIT_PX,
803
810
  kotlin.math
804
811
  .ceil(
@@ -808,8 +815,7 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
808
815
  )
809
816
  .toFloat(),
810
817
  )
811
- view.letterSpacing = 0f
812
- if (view.text.isNotEmpty()) {
818
+ if (explicit?.has("lineHeight") != true && view.text.isNotEmpty()) {
813
819
  val text = SpannableStringBuilder(view.text)
814
820
  text
815
821
  .getSpans(0, text.length, NativeListLineHeightSpan::class.java)
@@ -824,6 +830,7 @@ internal class NativeListSectionHeaderRowView(context: ThemedReactContext, fonts
824
830
  view.text = text
825
831
  }
826
832
  }
833
+ applyNativeListTextSpacing(view, explicit, defaultLetterSpacing = view.letterSpacing)
827
834
  }
828
835
  if (view is ViewGroup) for (i in 0 until view.childCount) visit(view.getChildAt(i))
829
836
  }
@@ -7,6 +7,7 @@ import android.animation.AnimatorListenerAdapter
7
7
  import android.content.Context
8
8
  import android.graphics.Canvas
9
9
  import android.graphics.Color
10
+ import android.graphics.Matrix
10
11
  import android.graphics.Paint
11
12
  import android.graphics.Path
12
13
  import android.graphics.Rect
@@ -2791,6 +2792,7 @@ class NativeListView(
2791
2792
  previous.selectionMode != next.selectionMode ||
2792
2793
  previous.rowPressToggles != next.rowPressToggles ||
2793
2794
  previous.reorderable != next.reorderable ||
2795
+ previous.reorderFromHandleOnly != next.reorderFromHandleOnly ||
2794
2796
  previous.pullToRefresh != next.pullToRefresh ||
2795
2797
  previous.refreshTriggerDistance != next.refreshTriggerDistance ||
2796
2798
  previous.refreshing != next.refreshing ||
@@ -4537,18 +4539,35 @@ class NativeListView(
4537
4539
  reorderTouchHandler = handler
4538
4540
  val movementLimit = dp(REORDER_ALLOWABLE_MOVEMENT_DP).toFloat()
4539
4541
  reorderTouchListener = object : RecyclerView.SimpleOnItemTouchListener() {
4540
- private var candidate: RecyclerView.ViewHolder? = null
4542
+ private var candidate: NativeListViewHolder? = null
4543
+ private var candidateItem: NativeListItem? = null
4544
+ private var candidateHandle: View? = null
4545
+ private var candidateBindingEpoch = 0L
4546
+ private var rawDownX = 0f
4547
+ private var rawDownY = 0f
4541
4548
  private var downX = 0f
4542
4549
  private var downY = 0f
4543
4550
  private var dragStarted = false
4544
4551
  private val startDrag = Runnable {
4545
4552
  val holder = candidate ?: return@Runnable
4546
- val position = holder.bindingAdapterPosition
4547
- val item = adapter.itemAt(position) ?: return@Runnable
4548
- if (!item.isReorderable) return@Runnable
4549
- if (item.type != "walletGroup" && recyclerView.isLayoutRequested) {
4553
+ val original = candidateItem ?: return@Runnable
4554
+ if (original.type != "walletGroup" && recyclerView.isLayoutRequested) {
4550
4555
  relayoutRecyclerViewImmediately()
4551
4556
  }
4557
+ val item = adapter.itemAt(holder.bindingAdapterPosition) ?: return@Runnable
4558
+ val acceptedIndex = acceptedKeyIndex?.get(original.key) ?: return@Runnable
4559
+ val current = config ?: return@Runnable
4560
+ val accepted = current.items.getOrNull(acceptedIndex) ?: return@Runnable
4561
+ if (item.key != original.key || accepted.key != original.key || !accepted.isReorderable)
4562
+ return@Runnable
4563
+ val handle = candidateHandle
4564
+ if (handle != null) {
4565
+ val controlled = current.selectionMode == "single" || current.selectionMode == "multiple"
4566
+ if (holder.rowView.bindingEpoch != candidateBindingEpoch ||
4567
+ (accepted.content != original.content && !isStableSelectionUpdate(original, accepted, controlled)) ||
4568
+ findReorderHandle(holder.itemView, rawDownX, rawDownY) !== handle
4569
+ ) return@Runnable
4570
+ }
4552
4571
  dragStarted = true
4553
4572
  beginDrag(holder)
4554
4573
  }
@@ -4562,6 +4581,8 @@ class NativeListView(
4562
4581
  private fun cancelPending() {
4563
4582
  handler.removeCallbacks(startDrag)
4564
4583
  candidate = null
4584
+ candidateItem = null
4585
+ candidateHandle = null
4565
4586
  }
4566
4587
 
4567
4588
  override fun onInterceptTouchEvent(recyclerView: RecyclerView, event: MotionEvent): Boolean {
@@ -4572,11 +4593,14 @@ class NativeListView(
4572
4593
  dragStarted = false
4573
4594
  downX = event.x
4574
4595
  downY = event.y
4596
+ rawDownX = event.rawX
4597
+ rawDownY = event.rawY
4575
4598
  val child = recyclerView.findChildViewUnder(event.x, event.y)
4576
4599
  candidate = child
4577
4600
  ?.let(recyclerView::getChildViewHolder)
4578
4601
  // Container-slot holders report binding position 0 in their own adapter.
4579
- ?.takeIf { holder -> holder is NativeListViewHolder && holder.bindingAdapter === adapter }
4602
+ ?.let { it as? NativeListViewHolder }
4603
+ ?.takeIf { holder -> holder.bindingAdapter === adapter }
4580
4604
  ?.takeIf { holder ->
4581
4605
  adapter.itemAt(holder.bindingAdapterPosition)?.let { item ->
4582
4606
  // OneKey patch: any wallet group member can initiate the group drag.
@@ -4586,10 +4610,14 @@ class NativeListView(
4586
4610
  // item.type != "walletGroup" ||
4587
4611
  // event.rawY in holderLocation[1].toFloat()..(holderLocation[1] + dp(68)).toFloat()
4588
4612
  // )
4613
+ candidateItem = item
4614
+ if (config?.reorderFromHandleOnly == true) {
4615
+ candidateHandle = findReorderHandle(holder.itemView, rawDownX, rawDownY)
4616
+ if (candidateHandle == null) return@let false
4617
+ candidateBindingEpoch = holder.rowView.bindingEpoch
4618
+ }
4589
4619
  item.isReorderable &&
4590
- (holder as? NativeListViewHolder)?.rowView?.canStartWalletGroupReorder(
4591
- event.y - holder.itemView.top,
4592
- ) != false
4620
+ holder.rowView.canStartWalletGroupReorder(event.y - holder.itemView.top)
4593
4621
  } == true
4594
4622
  }
4595
4623
  if (candidate != null) handler.postDelayed(startDrag, REORDER_LONG_PRESS_MS)
@@ -4607,6 +4635,53 @@ class NativeListView(
4607
4635
  }.also(recyclerView::addOnItemTouchListener)
4608
4636
  }
4609
4637
 
4638
+ /** Find the visible trailing handle whose button frame contains the initial press. */
4639
+ private fun findReorderHandle(root: View, rawX: Float, rawY: Float): View? {
4640
+ if (root.visibility != View.VISIBLE) return null
4641
+ if (root.getTag(R.id.onekey_native_list_reorder_handle) == true) {
4642
+ return root.takeIf { reorderHandleContainsScreenPoint(it, rawX, rawY) }
4643
+ }
4644
+ if (root is ViewGroup) {
4645
+ for (index in 0 until root.childCount) {
4646
+ findReorderHandle(root.getChildAt(index), rawX, rawY)?.let { return it }
4647
+ }
4648
+ }
4649
+ return null
4650
+ }
4651
+
4652
+ private fun reorderHandleContainsScreenPoint(handle: View, rawX: Float, rawY: Float): Boolean {
4653
+ val localToScreen = Matrix()
4654
+ var view = handle
4655
+ while (true) {
4656
+ val parent = view.parent as? View ?: break
4657
+ localToScreen.postConcat(view.matrix)
4658
+ localToScreen.postTranslate(
4659
+ (view.left - parent.scrollX).toFloat(),
4660
+ (view.top - parent.scrollY).toFloat(),
4661
+ )
4662
+ view = parent
4663
+ }
4664
+
4665
+ // The top-level View's screen origin already includes its transform and
4666
+ // the window offset. Subtract its mapped origin to apply the matrix once.
4667
+ val screenOrigin = IntArray(2)
4668
+ view.getLocationOnScreen(screenOrigin)
4669
+ val mappedOrigin = floatArrayOf(0f, 0f)
4670
+ view.matrix.mapPoints(mappedOrigin)
4671
+ localToScreen.postConcat(view.matrix)
4672
+ localToScreen.postTranslate(
4673
+ screenOrigin[0] - mappedOrigin[0],
4674
+ screenOrigin[1] - mappedOrigin[1],
4675
+ )
4676
+
4677
+ val screenToLocal = Matrix()
4678
+ if (!localToScreen.invert(screenToLocal)) return false
4679
+ val point = floatArrayOf(rawX, rawY)
4680
+ screenToLocal.mapPoints(point)
4681
+ return point[0] >= 0f && point[0] < handle.width &&
4682
+ point[1] >= 0f && point[1] < handle.height
4683
+ }
4684
+
4610
4685
  private fun prepareDisplacedReorderAnimation(view: View, helper: ItemTouchHelper) {
4611
4686
  val previousX = view.x
4612
4687
  val previousY = view.y
@@ -4,4 +4,5 @@
4
4
  <item name="onekey_native_scroll_coordinator_refresh_inset" type="id" />
5
5
  <item name="onekey_native_scroll_coordinator_command_listener" type="id" />
6
6
  <item name="onekey_native_scroll_coordinator_command_cancel_listener" type="id" />
7
+ <item name="onekey_native_list_reorder_handle" type="id" />
7
8
  </resources>
@@ -24,6 +24,8 @@ class NativeListIdentityTrailingAxisTest {
24
24
  listOf(d("icon", "RefreshCcwOutline"), d("chevron")) to true,
25
25
  listOf(d("icon", "RefreshCcwOutline", "refresh"), d("chevron")) to false,
26
26
  listOf(d("icon", "PencilOutline", "edit"), d("icon", "DragOutline")) to true,
27
+ listOf(d("icon", "PencilOutline", "edit"), d("drag")) to true,
28
+ listOf(d("icon", "InfoCircleOutline", "edit"), d("drag")) to false,
27
29
  listOf(d("value"), d("checkbox")) to true,
28
30
  listOf(d("valuePair"), d("icon", "DotVerSolid", "menu"), d("chevron")) to false,
29
31
  )
package/docs/SPEC.md CHANGED
@@ -116,6 +116,17 @@ Status: implemented in local source for the Select Address and Swap selectors;
116
116
  native device and broader Web runtime verification remain pending. These fields travel in snapshot/patch JSON
117
117
  and do not change the Nitro ABI.
118
118
 
119
+ Snapshot and patch validation requires a boolean for `collapseEmptyTrailing`;
120
+ a patch with `null` restores the default. Automatic height uses the same
121
+ trailing geometry, font features and tracking as the rendered text.
122
+
123
+ An `identity` row may set `collapseEmptyTrailing: true`: when it has no trailing
124
+ accessories, iOS drops the (empty) trailing column and its 12-point gap so the
125
+ text column reaches the row's trailing padding, as a React Native `ListItem`
126
+ without children does. Omission keeps the legacy iOS reservation. Android and
127
+ Web already give an empty trailing column no width or gap, so the flag does not
128
+ change them.
129
+
119
130
  An `identity` row may opt into `subtitleLines: 0`, meaning the complete subtitle
120
131
  wraps at its measured text-column width without a line cap. Existing omitted,
121
132
  one-line and two-line behavior stays unchanged. An identity row with
@@ -193,6 +204,15 @@ names through the same DOM helper; their previous coverage does not expand.
193
204
  Image preserves raw path order, fill rules, fixed colors, opacity and viewBoxes.
194
205
  NativeList retains its layout, button bounds, actions and snapshot interfaces.
195
206
 
207
+ The registries are aliases and native geometry, not a whitelist. iOS and Android
208
+ already resolve any other name through image's `OneKeyNamedSVG` catalog. Web now
209
+ does the same: a name missing from the Web registry is passed to
210
+ `createNamedIcon` unchanged, so every host-catalog icon (for example
211
+ `DeleteOutline`, `MinusCircleSolid`) renders as artwork on all three platforms.
212
+ Only a name the host catalog also lacks keeps the legacy text glyph. The
213
+ trailing `drag` accessory renders the `DragOutline` artwork on Web instead of
214
+ `≡` when the host provides it.
215
+
196
216
  Focused SDK fixture acceptance covers native attached lifecycle/rebinding,
197
217
  legacy iOS asset comparisons, shared alpha semantics and real Web/Electron
198
218
  source/lib consumers. This is not full App, balance, transaction or signed
@@ -202,7 +222,8 @@ Identity trailing accessories stack vertically, except for the pairs every
202
222
  platform lays out side by side: `value` + `checkbox`, `valuePair` + `menu`,
203
223
  `valuePair` + an `icon` named `DotVerSolid` whose `actionKey` is `menu`,
204
224
  `valuePair` + `chevron`, a `RefreshCcwOutline` icon without an action key +
205
- `chevron`, and `PencilOutline` + `DragOutline` icons. iOS decides this in
225
+ `chevron`, and a `PencilOutline` icon followed by a `DragOutline` icon or a
226
+ `drag` accessory. iOS decides this in
206
227
  `configureTrailingStack`; Android in `nativeListIdentityTrailingIsHorizontal`
207
228
  (JVM test `NativeListIdentityTrailingAxisTest`). The `valuePair` + menu-icon
208
229
  pair is the Swap token selector's balance column and row menu; stacking it
@@ -444,7 +465,13 @@ existing appearance.
444
465
 
445
466
  Identity leading visuals consume the existing `borderColor` as a one-point/dp
446
467
  solid bitmap border when supplied without `borderStyle: 'dashed'`; omission or
447
- a dashed style clears the solid border on every bind.
468
+ a dashed style clears the solid border on every bind. An optional `borderWidth`
469
+ (`0 < width <= 4` logical units, default 1) sets that solid border's width; a
470
+ host hairline (`StyleSheet.hairlineWidth`) draws one physical pixel on iOS and
471
+ Android (rounded up to at least one pixel) and a fractional CSS border on Web.
472
+ Web insets the main image into the bordered frame's content box, as iOS and
473
+ Android do, and a sized `fallbackIcon` keeps its requested size there instead
474
+ of shrinking to the content box.
448
475
  The image is inset by that border width. An overlay may optionally set
449
476
  `fontWeight` to one of the existing text weight names
450
477
  (`regular | medium | semibold | bold`). This changes only overlay text;
@@ -625,6 +652,90 @@ and one native end, a tap produces touch-end, and cancellation/removal followed
625
652
  by reuse leaves the next tap functional. This proves native touch delivery, not
626
653
  execution of a JavaScript press handler or physical-device gesture feel.
627
654
 
655
+ ### Handle-only reorder activation
656
+
657
+ `capabilities.reorderActivation` selects where a reorder may start. `row`
658
+ (default, also when omitted) keeps the existing behavior: a long press anywhere
659
+ on a reorderable row. `handle` restricts the start to the row's trailing `drag`
660
+ accessory; a long press elsewhere on the row is an ordinary press or long press
661
+ and never begins a reorder. Development and production reject any other value
662
+ and retain the currently accepted snapshot.
663
+
664
+ - **Gesture:** iOS and Android keep their reorder long-press duration (200 ms)
665
+ and movement tolerance. Web keeps its touch long press and mouse drag
666
+ threshold; only the pointer-down target is narrowed.
667
+ - **Hit area:** the visible `drag` accessory. Android accepts its 24dp glyph
668
+ slot plus 7dp on each side (its actual 38dp button frame). Android maps
669
+ the screen press into the handle's local coordinates at press and at
670
+ recognition, accounting for transforms and scrolling between ancestors.
671
+ iOS also uses the button frame. Recognition remains tied to the row and handle that
672
+ received the initial touch, even if the finger moves across a row boundary.
673
+ A removed handle or a recycled binding cancels a pending start and keeps
674
+ accepted data updates. An iOS or Android selection echo that retains the row
675
+ binding and its handle preserves the pending press.
676
+ - **Eligibility:** row reorder eligibility (`draggable`, a `drag` accessory,
677
+ `disabled`) is unchanged. A row without a `drag` accessory cannot start a
678
+ reorder in `handle` mode.
679
+ - **Accessory:** a `drag` without an action swallows a short tap on iOS and
680
+ passes it to the row on Android and Web. In Web handle mode a `drag` with
681
+ an `actionKey` can start a reorder and still emits its action on a short
682
+ tap. A recognized reorder suppresses the click generated by that press,
683
+ including release after cancellation. Overlapping pointer sequences retain
684
+ their own suppression until a matching click or new press with that pointer
685
+ ID, native cancellation, or 500 ms after release. A click without a pointer ID
686
+ matches the most recent release at the same action or row and client position
687
+ (within one CSS pixel), using the input type when the browser supplies it.
688
+ For a press and release on different elements, the match uses their nearest
689
+ shared ancestor as the click target. Releases outside the list cannot replace
690
+ that match. A new short tap or
691
+ keyboard activation can still emit the action. Icons beside the handle keep
692
+ their own actions.
693
+ Callers can use `pressDisabled` to disable row opening.
694
+ - **Web cursor:** in `handle` mode the row keeps the default cursor and the
695
+ handle shows `grab`.
696
+ - **Handle appearance:** every platform tints the `DragOutline` glyph
697
+ `iconSubdued`, matching `ListItem.IconButton`; Web centers it in a 24-point
698
+ box so it lines up with neighbouring icon buttons instead of the text line.
699
+ iOS and Android draw the handle as a medium tertiary button (38-point frame,
700
+ glyph inset 7), like the source `IconButton`, so a `PencilOutline` + `drag`
701
+ pair keeps 24 points between glyph slots (Android gives the second frame a
702
+ 17dp start margin after its m=-7); Web applies the same 24-point gap.
703
+ - **Tertiary text gap:** when the first trailing accessory is a tertiary icon,
704
+ the text column ends 12 points before its glyph slot, as `ListItem` lays it
705
+ out. iOS absorbs the button's m=-7 on the text side (it clipped 9 points
706
+ early), Android adds the 12dp end margin the -7 had eaten (text ran into the
707
+ button), and Web already does this through CSS margins.
708
+ - **Leading action geometry:** an identity `leadingAction` reproduces
709
+ `ListItem.IconButton` (medium tertiary: 6-point padding plus a 1-point
710
+ border, m=-7) on all three platforms, so its glyph sits on a 24-point slot at
711
+ the 12-point row padding and the leading visual starts at 48. iOS and Android
712
+ use a 36-point frame with a 6-point inset and 6-point following gap; Web
713
+ applies the tertiary icon frame and reports the inner glyph slot's window
714
+ rect, including any ancestor transform. Web icon buttons use an explicit
715
+ accessibility label where supplied and otherwise retain their fallback
716
+ glyph as a name even when host SVG artwork is present.
717
+
718
+ - **Enclosing pans (iOS):** once a reorder has started, the list disables the
719
+ enabled `UIPanGestureRecognizer`s of its ancestors (for example a sheet's
720
+ dismiss pan or a pager) and restores them when the reorder finishes, is
721
+ cancelled by a structural update, or the list is torn down. Before the long
722
+ press is recognized those pans behave as before, so a quick pull still drags
723
+ the sheet. This applies to both activation modes. The NativeOverlay page
724
+ sheet combines temporary suppression with the current `dismissOnPanDown`
725
+ setting, including prop changes during the drag.
726
+
727
+ Toggling `reorderActivation` or `reorderable` cancels pending and active
728
+ pointer reorder without emitting a reorder event. An accepted full Web
729
+ snapshot supersedes a provisional reorder; accepted row patches retain their
730
+ content even if a gesture is cancelled. Web keyboard sorting remains available
731
+ from the focused row if it has a rendered handle in `handle` mode. The
732
+ capability travels in snapshot JSON; the Nitro ABI is unchanged.
733
+
734
+ Leading visual `borderWidth` supports values in (0, 4]. Development rejects
735
+ out-of-range widths; production discards the invalid width in full snapshots
736
+ and patches so the border uses its existing default of 1. Production also
737
+ discards invalid tracking and digit-spacing overrides so template defaults apply.
738
+
628
739
  ### Android reorder cancellation
629
740
 
630
741
  Status: implemented; three real Android View/callback regressions verified on
@@ -234,7 +234,7 @@ meaning is defined in the [catalog](ROW_TEMPLATES.md).
234
234
 
235
235
  Every text role listed below accepts the same `NativeListTextStyle`:
236
236
  `token`, `fontSize`, `fontWeight`, `color`, `lineHeight`, `lines`, `truncate`,
237
- `alignment`, `verticalAlignment`, `offsetY`.
237
+ `alignment`, `verticalAlignment`, `offsetY`, `letterSpacing`, `tabularNumbers`.
238
238
  Weights are `regular | medium | semibold | bold`; line counts are `1 | 2 | 3`;
239
239
  `start | center | end` alignment follows layout direction on all three
240
240
  platforms (`end` is the left edge in RTL). Colors must be
@@ -363,6 +363,8 @@ style: {
363
363
  | `alignment` | Horizontal `start / center / end` inside the text region, respecting direction |
364
364
  | `verticalAlignment` | `top / center / bottom` for the complete text block inside its allocated text region; no effect without spare height |
365
365
  | `offsetY` | `-8…8` logical units of optical translation; does not change measurement, sibling spacing or hit areas |
366
+ | `letterSpacing` | `-4…10` logical units between glyphs. iOS sets `.kern`, so an explicit `0` also turns off pair kerning, matching React Native `letterSpacing: 0`; Android converts to em of the current text size and adds `'kern' 0`, matching React Native text there too; Web sets CSS `letter-spacing`. Omission keeps each platform's existing tracking |
367
+ | `tabularNumbers` | `true` draws equal-width digits, as the App's `SizableText` does by default: iOS swaps each run to the monospaced-number font feature, Android sets `tnum`, Web sets `font-variant-numeric: tabular-nums`. `false` explicitly selects proportional digits. Omission keeps each template's current digits, including selector defaults |
366
368
 
367
369
  Single-line text does not wrap; explicit CR/LF line breaks become spaces (CRLF is
368
370
  one break). Multi-line text wraps naturally, preserves explicit breaks, and
@@ -570,6 +572,10 @@ model fields, whatever the renderer's internal view names are.
570
572
  | table layout | `$bodyXs` | 11 regular / 14 | sp(11) regular / dp(14) | — |
571
573
  | `value` | `$bodyLg` | 16 / 24 | sp(16) medium / dp(24) | 14px / 20px / 500 **≠** |
572
574
 
575
+ Android history titles keep their default tracking when `style.title` omits
576
+ `letterSpacing`. Web network selector success badges inherit tabular numerals
577
+ from the section, independently of explicit digit styles on the title or value.
578
+
573
579
  ### action
574
580
 
575
581
  | Key | Default | iOS | Android | Web |