@onekeyfe/react-native-native-list 3.0.179-alpha.304 → 3.0.179

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 (111) hide show
  1. package/README.md +3 -32
  2. package/android/build.gradle +1 -0
  3. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +1 -22
  4. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +8 -8
  5. package/android/src/main/java/com/onekey/nativelist/NativeListActionRenderer.kt +5 -5
  6. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +4 -4
  7. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +6 -6
  8. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +1 -6
  9. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +11 -11
  10. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +20 -20
  11. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +4 -5
  12. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +7 -7
  13. package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +5 -5
  14. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +7 -8
  15. package/android/src/main/java/com/onekey/nativelist/NativeListMetricCardRenderer.kt +14 -14
  16. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +15 -28
  17. package/android/src/main/java/com/onekey/nativelist/NativeListRailRenderer.kt +4 -4
  18. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +3 -3
  19. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -3
  20. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +4 -5
  21. package/android/src/main/java/com/onekey/nativelist/NativeListRowHost.kt +1 -1
  22. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +20 -20
  23. package/android/src/main/java/com/onekey/nativelist/NativeListSystemRenderer.kt +3 -3
  24. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +18 -104
  25. package/android/src/main/java/com/onekey/nativelist/NativeListWalletGroupRenderer.kt +5 -6
  26. package/common/fonts/Roobert-Bold.ttf +0 -0
  27. package/common/fonts/Roobert-Medium.ttf +0 -0
  28. package/common/fonts/Roobert-Regular.ttf +0 -0
  29. package/common/fonts/Roobert-SemiBold.ttf +0 -0
  30. package/docs/SPEC.md +0 -69
  31. package/docs/STYLE_SPEC.md +2 -12
  32. package/ios/HybridNativeList.swift +6 -18
  33. package/ios/NativeListAccessoryStack.swift +10 -14
  34. package/ios/NativeListActionRenderer.swift +4 -7
  35. package/ios/NativeListActivityDetailsView.swift +24 -63
  36. package/ios/NativeListActivityRenderer.swift +10 -19
  37. package/ios/NativeListDataRowRenderer.swift +19 -23
  38. package/ios/NativeListDesignAssets.swift +34 -43
  39. package/ios/NativeListIdentityRenderer.swift +19 -23
  40. package/ios/NativeListLeadingVisual.swift +4 -9
  41. package/ios/NativeListMarketRenderer.swift +11 -19
  42. package/ios/NativeListMediaTileRenderer.swift +7 -11
  43. package/ios/NativeListMessageRenderer.swift +10 -20
  44. package/ios/NativeListMetricCardRenderer.swift +12 -16
  45. package/ios/NativeListRailRenderer.swift +7 -9
  46. package/ios/NativeListRendererCell.swift +4 -6
  47. package/ios/NativeListRendererRegistry.swift +3 -8
  48. package/ios/NativeListResolvedText.swift +3 -3
  49. package/ios/NativeListRowHost.swift +2 -7
  50. package/ios/NativeListSectionHeaderRenderer.swift +19 -22
  51. package/ios/NativeListSystemRenderer.swift +16 -18
  52. package/ios/NativeListTextStyles.swift +12 -18
  53. package/ios/NativeListWalletGroupRenderer.swift +4 -6
  54. package/ios/RNCNativeListView.swift +5 -38
  55. package/ios/tests/NativeListActivityPresentationTests.swift +3 -5
  56. package/ios/tests/NativeListLifecycleTests.swift +2 -77
  57. package/lib/module/NativeList.js +0 -3
  58. package/lib/module/NativeList.web.js +1 -8
  59. package/lib/module/index.js +0 -1
  60. package/lib/module/web/NativeListWebEngine.js +24 -48
  61. package/lib/module/web/templates/ActionRowRenderer.js +1 -2
  62. package/lib/module/web/templates/IdentityRowRenderer.js +3 -4
  63. package/lib/module/web/templates/MarketRowRenderer.js +1 -2
  64. package/lib/module/web/templates/RowText.js +3 -13
  65. package/lib/module/web/templates/SectionHeaderRowRenderer.js +2 -3
  66. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +0 -9
  67. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +0 -2
  68. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +0 -5
  69. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +0 -6
  70. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +0 -7
  71. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +0 -6
  72. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +0 -1
  73. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +0 -11
  74. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +0 -2
  75. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +0 -2
  76. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +0 -2
  77. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +0 -3
  78. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +0 -1
  79. package/lib/typescript/src/NativeList.nitro.d.ts +0 -1
  80. package/lib/typescript/src/index.d.ts +0 -2
  81. package/lib/typescript/src/web/NativeListWebEngine.d.ts +1 -4
  82. package/lib/typescript/src/web/templates/RowText.d.ts +0 -1
  83. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +0 -9
  84. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +0 -2
  85. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +0 -5
  86. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +0 -6
  87. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +0 -7
  88. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +0 -6
  89. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +0 -1
  90. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +0 -11
  91. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +0 -2
  92. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +0 -2
  93. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +0 -2
  94. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +0 -3
  95. package/nitrogen/generated/shared/json/NativeListConfig.json +0 -1
  96. package/package.json +5 -4
  97. package/react-native-native-list.podspec +1 -0
  98. package/src/NativeList.nitro.ts +0 -1
  99. package/src/NativeList.tsx +0 -3
  100. package/src/NativeList.web.tsx +1 -10
  101. package/src/index.ts +0 -3
  102. package/src/web/NativeListWebEngine.ts +24 -53
  103. package/src/web/templates/ActionRowRenderer.ts +1 -2
  104. package/src/web/templates/IdentityRowRenderer.ts +3 -4
  105. package/src/web/templates/MarketRowRenderer.ts +2 -4
  106. package/src/web/templates/RowText.ts +3 -15
  107. package/src/web/templates/SectionHeaderRowRenderer.ts +3 -6
  108. package/LICENSE +0 -36
  109. package/lib/module/fonts.js +0 -44
  110. package/lib/typescript/src/fonts.d.ts +0 -10
  111. package/src/fonts.ts +0 -64
@@ -101,25 +101,6 @@ private class NativeListGridLayoutManager(
101
101
  class NativeListView(
102
102
  private val reactContext: ThemedReactContext,
103
103
  ) : LinearLayout(reactContext) {
104
- private val fonts = NativeListFonts()
105
-
106
- fun setFontFamiliesJson(json: String) {
107
- if (!fonts.configure(json)) return
108
- invalidateActionAnchor("layout")
109
- measuredRowExtentsPx.clear()
110
- measuredRowExtentSumPx = 0L
111
- config?.let { updateReordering(it) }
112
- adapter.rebindFonts()
113
- config?.let { bindFooter(it) }
114
- sectionIndexView.refreshFonts()
115
- sectionIndexPreview.typeface = fonts.regular(context)
116
- stickyHeaderSignature = null
117
- stickyHeaderConfig = null
118
- updateStickyHeader()
119
- recyclerView.requestLayout()
120
- requestLayout()
121
- }
122
-
123
104
  private data class VisibleMarketAnchor(
124
105
  val key: String,
125
106
  val offset: Int,
@@ -212,7 +193,7 @@ class NativeListView(
212
193
  private val defaultRefreshTriggerDistancePx = (64 * resources.displayMetrics.density).roundToInt()
213
194
  private var refreshIndicatorOffsetPx = 0
214
195
  private val contentContainer = FrameLayout(context)
215
- private val adapter = NativeListAdapter(reactContext, fonts)
196
+ private val adapter = NativeListAdapter(reactContext)
216
197
  private val containerSlots = mutableListOf<View>()
217
198
  private val slotHeights = IntArray(3)
218
199
  private var containerSlotRelayoutPending = false
@@ -470,13 +451,13 @@ class NativeListView(
470
451
  mass = REORDER_SPRING_MASS,
471
452
  durationSeconds = REORDER_SPRING_DURATION_MS / 1_000.0,
472
453
  )
473
- private var footerView: NativeListRowHost = NativeListRendererRegistry.create(reactContext, NativeListRendererKey.ACTION.ordinal, fonts)
454
+ private var footerView: NativeListRowHost = NativeListRendererRegistry.create(reactContext, NativeListRendererKey.ACTION.ordinal)
474
455
  private var footerRendererKey = NativeListRendererKey.ACTION
475
- private val sectionIndexView = NativeListSectionIndexView(context, fonts)
456
+ private val sectionIndexView = NativeListSectionIndexView(context)
476
457
  private val sectionIndexPreview = TextView(context)
477
458
  private var config: NativeListConfig? = null
478
459
  private var usesSelectorSourceScale = false
479
- private val stickyHeaderView = NativeListRendererRegistry.create(reactContext, NativeListRendererKey.SECTION_HEADER.ordinal, fonts)
460
+ private val stickyHeaderView = NativeListRendererRegistry.create(reactContext, NativeListRendererKey.SECTION_HEADER.ordinal)
480
461
  private var stickyHeaderSignature: String? = null
481
462
  private var stickyHeaderConfig: NativeListConfig? = null
482
463
  private val stickyHeaderHost = object : FrameLayout(reactContext) {
@@ -536,7 +517,6 @@ class NativeListView(
536
517
  private var stickyObservedTree: ViewTreeObserver? = null
537
518
  private var spacingDecoration: ItemSpacingDecoration? = null
538
519
  private var itemTouchHelper: ItemTouchHelper? = null
539
- private var activeReorderHolder: NativeListViewHolder? = null
540
520
  private var reorderTouchListener: RecyclerView.OnItemTouchListener? = null
541
521
  private var reorderTouchHandler: Handler? = null
542
522
  private var endReachedGeneration: Int? = null
@@ -650,7 +630,7 @@ class NativeListView(
650
630
  sectionIndexPreview.apply {
651
631
  gravity = Gravity.CENTER
652
632
  textSize = 30f
653
- typeface = fonts.regular(context)
633
+ typeface = NativeListFonts.regular(context)
654
634
  setPadding(0, 0, sectionIndexDp(10), 0)
655
635
  visibility = INVISIBLE
656
636
  alpha = 0f
@@ -1683,19 +1663,8 @@ class NativeListView(
1683
1663
  reorderTouchListener = null
1684
1664
  recyclerView.removeOnItemTouchListener(keyboardTapTouchListener)
1685
1665
  recyclerView.removeOnItemTouchListener(pagerGestureTouchListener)
1686
- val previousHelper = itemTouchHelper
1666
+ itemTouchHelper?.attachToRecyclerView(null)
1687
1667
  itemTouchHelper = null
1688
- if (previousHelper != null && activeReorderHolder != null) {
1689
- val now = SystemClock.uptimeMillis()
1690
- val cancel = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0f, 0f, 0)
1691
- try {
1692
- recyclerView.onInterceptTouchEvent(cancel)
1693
- } finally {
1694
- cancel.recycle()
1695
- }
1696
- }
1697
- previousHelper?.attachToRecyclerView(null)
1698
- activeReorderHolder = null
1699
1668
  footerView.recycle()
1700
1669
  footerView.dispose()
1701
1670
  stopStickyHeaderTracking()
@@ -2036,7 +2005,7 @@ class NativeListView(
2036
2005
  val position = indexOfChild(previous)
2037
2006
  previous.recycle()
2038
2007
  previous.dispose()
2039
- footerView = NativeListRendererRegistry.create(reactContext, footer.rendererKey.ordinal, fonts)
2008
+ footerView = NativeListRendererRegistry.create(reactContext, footer.rendererKey.ordinal)
2040
2009
  footerView.onRowPress = ::handleRowPress
2041
2010
  footerView.onAction = ::handleAction
2042
2011
  footerView.onBindingInvalidated = ::handleBindingInvalidated
@@ -2279,44 +2248,15 @@ class NativeListView(
2279
2248
  }
2280
2249
 
2281
2250
  private fun updateReordering(next: NativeListConfig) {
2282
- dragFrom = RecyclerView.NO_POSITION
2283
- dragTo = RecyclerView.NO_POSITION
2284
- pendingReorder = null
2285
- reorderPlaceholderDecoration.position = RecyclerView.NO_POSITION
2286
2251
  stopReorderRelayoutLoop()
2287
2252
  reorderTouchHandler?.removeCallbacksAndMessages(null)
2288
2253
  reorderTouchHandler = null
2289
2254
  reorderTouchListener?.let(recyclerView::removeOnItemTouchListener)
2290
2255
  reorderTouchListener = null
2291
- val previousHelper = itemTouchHelper
2256
+ itemTouchHelper?.attachToRecyclerView(null)
2292
2257
  itemTouchHelper = null
2293
- if (previousHelper != null && activeReorderHolder != null) {
2294
- // Detach alone leaves ItemTouchHelper's selection/auto-scroll runnable alive.
2295
- val now = SystemClock.uptimeMillis()
2296
- val cancel = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0f, 0f, 0)
2297
- try {
2298
- recyclerView.onInterceptTouchEvent(cancel)
2299
- } finally {
2300
- cancel.recycle()
2301
- }
2302
- }
2303
- previousHelper?.attachToRecyclerView(null)
2304
- val rows = mutableSetOf<NativeListViewHolder>()
2305
- activeReorderHolder?.let(rows::add)
2306
- activeReorderHolder = null
2307
- for (index in 0 until recyclerView.childCount) {
2308
- (recyclerView.getChildViewHolder(recyclerView.getChildAt(index)) as? NativeListViewHolder)
2309
- ?.let(rows::add)
2310
- }
2311
- rows.forEach { holder ->
2312
- holder.itemView.animate().cancel()
2313
- ItemTouchHelper.Callback.getDefaultUIUtil().clearView(holder.itemView)
2314
- holder.rowView.setReorderActive(false)
2315
- }
2316
- recyclerView.invalidate()
2317
2258
  adapter.cancelReorder()
2318
2259
  if (!next.reorderable) return
2319
- lateinit var helper: ItemTouchHelper
2320
2260
  val callback = object : ItemTouchHelper.SimpleCallback(
2321
2261
  ItemTouchHelper.UP or ItemTouchHelper.DOWN or ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT,
2322
2262
  0,
@@ -2369,10 +2309,8 @@ class NativeListView(
2369
2309
  override fun isLongPressDragEnabled(): Boolean = false
2370
2310
 
2371
2311
  override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
2372
- if (itemTouchHelper !== helper) return
2373
2312
  super.onSelectedChanged(viewHolder, actionState)
2374
2313
  if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
2375
- activeReorderHolder = viewHolder as? NativeListViewHolder
2376
2314
  val position = viewHolder?.bindingAdapterPosition ?: RecyclerView.NO_POSITION
2377
2315
  val item = adapter.itemAt(position)
2378
2316
  reorderPlaceholderDecoration.position = position
@@ -2399,7 +2337,7 @@ class NativeListView(
2399
2337
  (viewHolder as? NativeListViewHolder)?.rowView?.setReorderActive(true)
2400
2338
  if (compactWalletGroupDrag && viewHolder != null) {
2401
2339
  recyclerView.postOnAnimation {
2402
- if (itemTouchHelper === helper && viewHolder.itemView.isAttachedToWindow) {
2340
+ if (viewHolder.itemView.isAttachedToWindow) {
2403
2341
  relayoutRecyclerViewImmediately()
2404
2342
  }
2405
2343
  }
@@ -2408,7 +2346,6 @@ class NativeListView(
2408
2346
  }
2409
2347
 
2410
2348
  override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
2411
- if (itemTouchHelper !== helper) return makeMovementFlags(0, 0)
2412
2349
  if (viewHolder !is NativeListViewHolder) return makeMovementFlags(0, 0)
2413
2350
  val item = adapter.itemAt(viewHolder.bindingAdapterPosition)
2414
2351
  if (item == null || !item.isReorderable) return makeMovementFlags(0, 0)
@@ -2421,7 +2358,6 @@ class NativeListView(
2421
2358
  source: RecyclerView.ViewHolder,
2422
2359
  target: RecyclerView.ViewHolder,
2423
2360
  ): Boolean {
2424
- if (itemTouchHelper !== helper) return false
2425
2361
  if (source !is NativeListViewHolder || target !is NativeListViewHolder) return false
2426
2362
  val from = source.bindingAdapterPosition
2427
2363
  val to = target.bindingAdapterPosition
@@ -2463,7 +2399,7 @@ class NativeListView(
2463
2399
  )
2464
2400
  }
2465
2401
  val displacedView = target.itemView
2466
- prepareDisplacedReorderAnimation(displacedView, helper)
2402
+ prepareDisplacedReorderAnimation(displacedView)
2467
2403
  val reordered = adapter.moveReordered(from, to)
2468
2404
  if (reordered == null) {
2469
2405
  logMoveAttempt(
@@ -2497,7 +2433,6 @@ class NativeListView(
2497
2433
  actionState: Int,
2498
2434
  isCurrentlyActive: Boolean,
2499
2435
  ) {
2500
- if (itemTouchHelper !== helper) return
2501
2436
  if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
2502
2437
  latestDragDx = dX
2503
2438
  latestDragDy = dY
@@ -2542,7 +2477,6 @@ class NativeListView(
2542
2477
  totalSize: Int,
2543
2478
  msSinceStartScroll: Long,
2544
2479
  ): Int {
2545
- if (itemTouchHelper !== helper) return 0
2546
2480
  val effectiveViewSize: Int
2547
2481
  val effectiveOutOfBounds: Int
2548
2482
  if (compactWalletGroupDrag) {
@@ -2596,9 +2530,6 @@ class NativeListView(
2596
2530
  }
2597
2531
 
2598
2532
  override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {
2599
- // Cancellation already restored rows before a replacement helper takes ownership.
2600
- if (itemTouchHelper !== helper) return
2601
- if (activeReorderHolder === viewHolder) activeReorderHolder = null
2602
2533
  stopReorderRelayoutLoop()
2603
2534
  val rowView = (viewHolder as? NativeListViewHolder)?.rowView
2604
2535
  val draggedGroupKey = (rowView?.tag as? NativeListItem)?.key
@@ -2633,7 +2564,6 @@ class NativeListView(
2633
2564
  val finishCompactWalletGroup = {
2634
2565
  if (wasCompactWalletGroupDrag) {
2635
2566
  recyclerView.postOnAnimation {
2636
- if (itemTouchHelper !== helper) return@postOnAnimation
2637
2567
  relayoutRecyclerViewImmediately()
2638
2568
  val resolvedPosition = draggedGroupKey
2639
2569
  ?.let(adapter::positionOfKey)
@@ -2650,9 +2580,7 @@ class NativeListView(
2650
2580
  REORDER_SPRING_DURATION_MS,
2651
2581
  reorderSpringInterpolator,
2652
2582
  ) {
2653
- recyclerView.postOnAnimation {
2654
- if (itemTouchHelper === helper) relayoutRecyclerViewImmediately()
2655
- }
2583
+ recyclerView.postOnAnimation(::relayoutRecyclerViewImmediately)
2656
2584
  }
2657
2585
  }
2658
2586
  }
@@ -2669,12 +2597,9 @@ class NativeListView(
2669
2597
  reordered.getOrNull(to + 1)?.let { payload.put("afterKey", it.key) }
2670
2598
  reorderPayload = payload
2671
2599
  adapter.commitReordered(reordered) {
2672
- if (itemTouchHelper !== helper) return@commitReordered
2673
2600
  finishCompactWalletGroup()
2674
2601
  if (!wasCompactWalletGroupDrag) {
2675
- recyclerView.postOnAnimation {
2676
- if (itemTouchHelper === helper) relayoutRecyclerViewImmediately()
2677
- }
2602
+ recyclerView.postOnAnimation(::relayoutRecyclerViewImmediately)
2678
2603
  }
2679
2604
  }
2680
2605
  }
@@ -2690,9 +2615,7 @@ class NativeListView(
2690
2615
  reorderPayload?.let { emit(REORDER, it) }
2691
2616
  }
2692
2617
  }
2693
- helper = ItemTouchHelper(callback)
2694
- itemTouchHelper = helper
2695
- helper.attachToRecyclerView(recyclerView)
2618
+ itemTouchHelper = ItemTouchHelper(callback).also { it.attachToRecyclerView(recyclerView) }
2696
2619
  val handler = Handler(Looper.getMainLooper())
2697
2620
  reorderTouchHandler = handler
2698
2621
  val movementLimit = dp(REORDER_ALLOWABLE_MOVEMENT_DP).toFloat()
@@ -2714,8 +2637,8 @@ class NativeListView(
2714
2637
  }
2715
2638
 
2716
2639
  private fun beginDrag(holder: RecyclerView.ViewHolder) {
2717
- if (itemTouchHelper !== helper || candidate !== holder || !holder.itemView.isAttachedToWindow) return
2718
- helper.startDrag(holder)
2640
+ if (candidate !== holder || !holder.itemView.isAttachedToWindow) return
2641
+ itemTouchHelper?.startDrag(holder)
2719
2642
  holder.itemView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
2720
2643
  }
2721
2644
 
@@ -2725,7 +2648,6 @@ class NativeListView(
2725
2648
  }
2726
2649
 
2727
2650
  override fun onInterceptTouchEvent(recyclerView: RecyclerView, event: MotionEvent): Boolean {
2728
- if (itemTouchHelper !== helper) return false
2729
2651
  when (event.actionMasked) {
2730
2652
  MotionEvent.ACTION_DOWN -> {
2731
2653
  cancelPending()
@@ -2767,7 +2689,7 @@ class NativeListView(
2767
2689
  }.also(recyclerView::addOnItemTouchListener)
2768
2690
  }
2769
2691
 
2770
- private fun prepareDisplacedReorderAnimation(view: View, helper: ItemTouchHelper) {
2692
+ private fun prepareDisplacedReorderAnimation(view: View) {
2771
2693
  val previousX = view.x
2772
2694
  val previousY = view.y
2773
2695
  view.addOnLayoutChangeListener(object : View.OnLayoutChangeListener {
@@ -2783,7 +2705,6 @@ class NativeListView(
2783
2705
  oldBottom: Int,
2784
2706
  ) {
2785
2707
  changedView.removeOnLayoutChangeListener(this)
2786
- if (itemTouchHelper !== helper) return
2787
2708
  val deltaX = previousX - changedView.x
2788
2709
  val deltaY = previousY - changedView.y
2789
2710
  if (deltaX == 0f && deltaY == 0f) return
@@ -3095,7 +3016,6 @@ private data class NativeListSectionIndexEntry(
3095
3016
 
3096
3017
  private class NativeListSectionIndexView(
3097
3018
  context: android.content.Context,
3098
- private val fonts: NativeListFonts,
3099
3019
  ) : View(context) {
3100
3020
  var onSelect: ((Int, Boolean) -> Unit)? = null
3101
3021
  var onInteractionEnded: (() -> Unit)? = null
@@ -3106,20 +3026,14 @@ private class NativeListSectionIndexView(
3106
3026
  private var activeColor = Color.BLACK
3107
3027
  private var activeTextColor = Color.WHITE
3108
3028
  private var lastTouchIndex: Int? = null
3109
- fun refreshFonts() {
3110
- normalPaint.typeface = fonts.regular(context)
3111
- activePaint.typeface = fonts.medium(context)
3112
- invalidate()
3113
- }
3114
-
3115
3029
  private val activeBackgroundPaint = Paint(Paint.ANTI_ALIAS_FLAG)
3116
3030
  private val normalPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
3117
3031
  textAlign = Paint.Align.CENTER
3118
- typeface = fonts.regular(context)
3032
+ typeface = NativeListFonts.regular(context)
3119
3033
  }
3120
3034
  private val activePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
3121
3035
  textAlign = Paint.Align.CENTER
3122
- typeface = fonts.medium(context)
3036
+ typeface = NativeListFonts.medium(context)
3123
3037
  }
3124
3038
 
3125
3039
  init {
@@ -14,8 +14,8 @@ import com.facebook.react.uimanager.ThemedReactContext
14
14
  import org.json.JSONObject
15
15
 
16
16
  /** Composite only; each keyed member owns an independent Identity binding. */
17
- internal class NativeListWalletGroupRowView(context: ThemedReactContext, fonts: NativeListFonts) :
18
- NativeListRendererRowView(context, fonts) {
17
+ internal class NativeListWalletGroupRowView(context: ThemedReactContext) :
18
+ NativeListRendererRowView(context) {
19
19
  private val membersColumn = LinearLayout(context).apply { orientation = VERTICAL }
20
20
  private val memberViews = linkedMapOf<String, NativeListIdentityRowView>()
21
21
  private var members = emptyList<NativeListItem>()
@@ -74,7 +74,7 @@ internal class NativeListWalletGroupRowView(context: ThemedReactContext, fonts:
74
74
  addView(membersColumn, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT))
75
75
  addView(compactContainer, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT))
76
76
  dragBadge.gravity = Gravity.CENTER
77
- dragBadge.typeface = fonts.semibold(context)
77
+ dragBadge.typeface = NativeListFonts.semibold(context)
78
78
  compactContainer.addView(dragBadge)
79
79
  }
80
80
 
@@ -84,7 +84,6 @@ internal class NativeListWalletGroupRowView(context: ThemedReactContext, fonts:
84
84
  layout: String,
85
85
  checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
86
86
  ) {
87
- dragBadge.typeface = fonts.semibold(context)
88
87
  currentTheme = theme
89
88
  currentLayout = layout
90
89
  members = memberItems(item)
@@ -136,7 +135,7 @@ internal class NativeListWalletGroupRowView(context: ThemedReactContext, fonts:
136
135
  members.forEachIndexed { index, member ->
137
136
  val view =
138
137
  memberViews.getOrPut(member.key) {
139
- NativeListIdentityRowView(reactContext, fonts).also { view ->
138
+ NativeListIdentityRowView(reactContext).also { view ->
140
139
  // Legacy: members own their disabled state; the group never gates them.
141
140
  view.onRowPress = { source, origin -> onRowPress?.invoke(source, origin) }
142
141
  view.onAction = { source, key, target, origin ->
@@ -169,7 +168,7 @@ internal class NativeListWalletGroupRowView(context: ThemedReactContext, fonts:
169
168
  }
170
169
  if (compactParent == null) {
171
170
  compactParent =
172
- NativeListIdentityRowView(reactContext, fonts).also {
171
+ NativeListIdentityRowView(reactContext).also {
173
172
  compactContainer.addView(
174
173
  it,
175
174
  0,
Binary file
Binary file
Binary file
package/docs/SPEC.md CHANGED
@@ -72,30 +72,6 @@ image that already loaded. Common container styling clears what it wrote on the
72
72
  next bind, including properties it set on template children. UI mutation remains on the platform
73
73
  UI thread; [DESIGN.md](DESIGN.md) describes update and event ownership.
74
74
 
75
- ### Android reorder cancellation
76
-
77
- Status: implemented; three real Android View/callback regressions verified on
78
- the task's API 34 emulator. Full MotionEvent long-press/edge-scroll gestures and
79
- physical-device acceptance remain pending.
80
- Replacing the reorder helper for a structural snapshot or changed font mapping
81
- MUST invalidate pending drag indices and transaction state before detaching the old
82
- helper, and restore the adapter's latest committed/submitted snapshot order
83
- during cancellation. An active helper's selection and auto-scroll ownership must
84
- end before detach, including disposal; ordinary non-reorder touch input is not
85
- force-cancelled.
86
- Cancellation emits no reorder event. It restores the active row's normal
87
- appearance, including wallet-group expansion and its declared opacity, removes
88
- the placeholder, and clears drag/displacement translation and temporary elevation.
89
- Callbacks and deferred displacement/drop animations owned by the detached helper
90
- MUST NOT change rows or commit a later gesture. A subsequent unmoved gesture
91
- emits no reorder event; a subsequent valid move retains the normal single commit
92
- with its own source/destination indices. This does not change the font API or
93
- ordinary successful-drop animation contract.
94
- In a repository source checkout, the opt-in platform-runner test and exact
95
- build/run commands are in `native-tests/android/README.md`; these tests
96
- drive the shipping NativeListView and ItemTouchHelper callbacks, not a copy of
97
- the cancellation implementation.
98
-
99
75
  ### Native section title loading indicator
100
76
 
101
77
  Status: implemented source; simulator rendering acceptance pending.
@@ -176,51 +152,6 @@ Existing geometry/typography differences are recorded in
176
152
  them. iOS uses UICollectionView, Android RecyclerView, and Web a windowed DOM
177
153
  engine. See [DESIGN.md](DESIGN.md) for their current ownership boundaries.
178
154
 
179
- ### Font resource ownership and runtime configuration
180
-
181
- Status: implemented; JavaScript regression tests, Android compilation/JVM tests
182
- and iOS test-target compilation verified. Device rendering acceptance pending.
183
- NativeList distributes no font files and registers no fonts. Hosts own font
184
- licensing, provisioning and registration. `configureNativeListFonts(families)`
185
- sets four optional face names (`regular`, `medium`, `semibold`, `bold`) for the
186
- current JavaScript runtime. The initial mapping is empty; `{}` resets every face
187
- to system fallback. Each call replaces the entire mapping. Names are trimmed,
188
- nonempty strings of at most 128 UTF-16 code units without control characters; unknown
189
- keys or invalid values throw before changing any state. Omitted/undefined faces
190
- use system fallback. Identical normalized mappings are idempotent.
191
-
192
- Hosts configure once during UI-runtime startup, after provisioning fonts and
193
- before rendering lists. Independent UI/background JavaScript runtimes have
194
- independent stores; configuring one MUST NOT change another. There is no public
195
- instance override and no mutable native-global font mapping. An internal Nitro
196
- `fontFamiliesJson` prop delivers each list's current mapping to its own resolver.
197
- Mounted lists subscribe to their runtime store. A changed mapping rebinds text,
198
- invalidates measured geometry and requests layout without replacing row keys,
199
- selection or snapshots. An active reorder is cancelled through the existing
200
- structural-update cleanup before changed font geometry is applied. The same mapping MUST NOT invalidate layout. Changing
201
- which font bytes an already configured name resolves to is outside this API;
202
- hosts load/register fonts before configuration, and no late-font-loading event or
203
- automatic font-file registration is added.
204
-
205
- iOS resolves each configured PostScript face with `UIFont(name:size:)`, then
206
- falls back to the requested system weight. Tabular-number features remain enabled
207
- where requested. Android delegates configured family names to ReactFontManager
208
- with `Typeface.NORMAL` and host assets, including Expo's `setTypeface` path;
209
- missing configured families use React Native's system fallback, whose weight
210
- need not match the requested semantic weight. An omitted face
211
- uses the requested system weight on Android API 28+, with the nearest
212
- regular/medium/bold system face on API 24–27. Web treats each configured name as a literal
213
- CSS font-family name with the existing semantic weight and platform font stack;
214
- the same resolver covers row text, sticky headers, fixed footers, section indexes
215
- and reorder previews. Native measurement and binding MUST use the same instance
216
- mapping. `fontFamily` remains absent from the public row-style surface.
217
-
218
- System/custom fallback changes text metrics. Consumers must check fixed-height
219
- rows, truncation and numeric alignment on each platform; source/unit checks do
220
- not establish visual acceptance. Acceptance includes two independent runtimes,
221
- two list instances, changed/reset mappings, invalid configuration without partial
222
- state, all templates and container text, and retained selection/scroll behavior.
223
-
224
155
  ## Failures, fallback and limits
225
156
 
226
157
  Snapshot validation rejects malformed/duplicate-key input without partial
@@ -180,18 +180,8 @@ slots already sit on that step; slots that do not are listed in §4.
180
180
  | `$bodySm` | 12 / 16 | regular | `rail.title`, `market.subtitle`, `identity.badge` |
181
181
  | `$bodyXs` | 11 / 16 | regular | `metricCard` labels, `market` badges |
182
182
 
183
- Weight names are `regular`, `medium`, `semibold`, and `bold`. NativeList bundles
184
- and registers no fonts. `configureNativeListFonts` sets optional face names once
185
- per JavaScript runtime; omitted faces and `{}` use system fonts. iOS names are
186
- host-registered PostScript names; Android names are host React Native family keys
187
- or matching asset names. Web names are literal host-defined CSS font families,
188
- with the existing semantic weight. Every list owns the native resolver delivered
189
- from its runtime store; there is no mutable native-global font mapping or public
190
- row/instance override. Configuration changes rebind text and invalidate measured
191
- layout; identical normalized mappings do not. Hosts provision fonts before this
192
- configuration and remain responsible for licensing. `fontFamily` is not part of
193
- the style surface. See SPEC.md for validation, lifecycle and fallback boundaries.
194
- Rendering acceptance remains required when font metrics change.
183
+ Weight names map to the bundled Roobert faces: `regular`, `medium`, `semibold`,
184
+ `bold`. No other family is available; `fontFamily` is not part of the style surface.
195
185
 
196
186
  ### 3.3 Spacing, radius, bounds
197
187
 
@@ -36,13 +36,6 @@ final class HybridNativeList: HybridNativeListSpec {
36
36
  }
37
37
  }
38
38
 
39
- private var fontsChanged = false
40
- private var snapshotChanged = false
41
-
42
- var fontFamiliesJson: String = "{}" {
43
- didSet { if fontFamiliesJson != oldValue { fontsChanged = true } }
44
- }
45
-
46
39
  var topScrollEdgeHard = false {
47
40
  didSet {
48
41
  runOnMain { [weak self] in
@@ -62,17 +55,12 @@ final class HybridNativeList: HybridNativeListSpec {
62
55
  }
63
56
 
64
57
  var snapshotJson: String = "" {
65
- didSet { if snapshotJson != oldValue { snapshotChanged = true } }
66
- }
67
-
68
- func afterUpdate() {
69
- let fonts = fontsChanged ? fontFamiliesJson : nil
70
- let snapshot = snapshotChanged ? snapshotJson : nil
71
- fontsChanged = false
72
- snapshotChanged = false
73
- runOnMain { [weak self] in
74
- if let fonts { self?.hostView?.setFontFamiliesJson(fonts) }
75
- if let snapshot { self?.hostView?.applySnapshotJson(snapshot) }
58
+ didSet {
59
+ guard snapshotJson != oldValue else { return }
60
+ runOnMain { [weak self] in
61
+ guard let self else { return }
62
+ self.hostView?.applySnapshotJson(self.snapshotJson)
63
+ }
76
64
  }
77
65
  }
78
66
 
@@ -118,7 +118,6 @@ final class NativeListAccessoryButton: UIButton {
118
118
  // Bounded trailing controls shared by migrated templates. The owning host supplies
119
119
  // action epochs; selection-only updates touch only the existing checkbox.
120
120
  final class NativeListAccessoryStack: UIStackView {
121
- var fonts = NativeListFontFamilies()
122
121
  private let accessoryButtons = (0..<2).map { _ in NativeListAccessoryButton(type: .system) }
123
122
  private let checkboxButton = UIButton(type: .system)
124
123
  private let spinner = UIActivityIndicatorView(style: .medium)
@@ -168,10 +167,8 @@ final class NativeListAccessoryStack: UIStackView {
168
167
  func bind(
169
168
  _ item: NativeListItem, descriptors: [[String: Any]], theme: [String: Any]?,
170
169
  style: [String: Any], defaultSpacing: CGFloat = 2,
171
- checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
172
- fonts: NativeListFontFamilies
170
+ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
173
171
  ) {
174
- self.fonts = fonts
175
172
  reset()
176
173
  currentItem = item
177
174
  currentTheme = theme
@@ -230,7 +227,7 @@ final class NativeListAccessoryStack: UIStackView {
230
227
  button.setImage(nil, for: .normal)
231
228
  button.setImage(nil, for: .disabled)
232
229
  button.titleLabel?.font = nativeListFont(
233
- ofSize: index == 0 ? 16 : 14, weight: index == 0 ? .medium : .regular, fonts: fonts)
230
+ ofSize: index == 0 ? 16 : 14, weight: index == 0 ? .medium : .regular)
234
231
  button.titleLabel?.numberOfLines = 1
235
232
  button.titleLabel?.lineBreakMode = .byTruncatingTail
236
233
  button.contentHorizontalAlignment = .center
@@ -418,7 +415,7 @@ final class NativeListAccessoryStack: UIStackView {
418
415
  NSAttributedString(
419
416
  string: primary,
420
417
  attributes: [
421
- .font: nativeListFont(ofSize: 16, weight: .medium, fonts: fonts),
418
+ .font: nativeListFont(ofSize: 16, weight: .medium),
422
419
  .foregroundColor: accessoryTextColor(
423
420
  accessory.string("primaryTone"),
424
421
  defaultTone: "primary",
@@ -436,7 +433,7 @@ final class NativeListAccessoryStack: UIStackView {
436
433
  NSAttributedString(
437
434
  string: secondary,
438
435
  attributes: [
439
- .font: nativeListFont(ofSize: 14, fonts: fonts),
436
+ .font: nativeListFont(ofSize: 14),
440
437
  .foregroundColor: accessoryTextColor(
441
438
  accessory.string("secondaryTone"),
442
439
  defaultTone: "secondary",
@@ -462,7 +459,7 @@ final class NativeListAccessoryStack: UIStackView {
462
459
  showAccessory(index, "⋮", action: action)
463
460
  guard accessoryButtons.indices.contains(index) else { return }
464
461
  let button = accessoryButtons[index]
465
- button.titleLabel?.font = nativeListFont(ofSize: 20, weight: .medium, fonts: fonts)
462
+ button.titleLabel?.font = nativeListFont(ofSize: 20, weight: .medium)
466
463
  accessorySizeConstraints.append(contentsOf: [
467
464
  button.widthAnchor.constraint(equalToConstant: 24),
468
465
  button.heightAnchor.constraint(equalToConstant: 24),
@@ -567,7 +564,7 @@ final class NativeListAccessoryStack: UIStackView {
567
564
  }
568
565
  for segment in segments {
569
566
  attributes[.font] = nativeListTabularFont(
570
- ofSize: segment.string("style") == "subscript" ? 10 : 16, weight: .medium, fonts: fonts)
567
+ ofSize: segment.string("style") == "subscript" ? 10 : 16, weight: .medium)
571
568
  value.append(NSAttributedString(string: segment.string("text"), attributes: attributes))
572
569
  }
573
570
  button.setAttributedTitle(value, for: .normal)
@@ -583,14 +580,14 @@ final class NativeListAccessoryStack: UIStackView {
583
580
  let accessory = button as? NativeListAccessoryButton
584
581
  let baseFont =
585
582
  (originalText?.attribute(.font, at: 0, effectiveRange: nil) as? UIFont) ?? button.titleLabel?
586
- .font ?? nativeListFont(ofSize: 14, fonts: fonts)
583
+ .font ?? nativeListFont(ofSize: 14)
587
584
  let size = CGFloat(style.double("fontSize", default: Double(baseFont.pointSize)))
588
585
  let font: UIFont
589
586
  if let weightName = style["fontWeight"] as? String {
590
587
  font = nativeListFont(
591
588
  ofSize: size,
592
- weight: marketFontWeight(weightName, fallback: .regular),
593
- fonts: fonts)
589
+ weight: marketFontWeight(weightName, fallback: .regular)
590
+ )
594
591
  } else {
595
592
  font = baseFont.withSize(size)
596
593
  }
@@ -662,8 +659,7 @@ final class NativeListAccessoryStack: UIStackView {
662
659
  style["fontWeight"] == nil
663
660
  ? original.withSize(size)
664
661
  : nativeListFont(
665
- ofSize: size, weight: marketFontWeight(style.string("fontWeight"), fallback: .regular),
666
- fonts: fonts)
662
+ ofSize: size, weight: marketFontWeight(style.string("fontWeight"), fallback: .regular))
667
663
  text.addAttribute(.font, value: font, range: range)
668
664
  }
669
665
  }
@@ -2,8 +2,7 @@ import UIKit
2
2
 
3
3
  final class NativeListActionCell: NativeListRendererCell {
4
4
  override class func measure(
5
- _ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String,
6
- fonts: NativeListFontFamilies
5
+ _ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String
7
6
  ) -> CGFloat? {
8
7
  return item.data.string("presentation") == "accountSelector"
9
8
  ? 48 : item.data.dictionary("icon") == nil ? 44 : 60
@@ -54,8 +53,7 @@ final class NativeListActionCell: NativeListRendererCell {
54
53
  return [checkbox]
55
54
  } ?? item.data.dictionaries("trailing")
56
55
  accessories.bind(
57
- item, descriptors: descriptors, theme: theme, style: style, checkboxState: checkboxState,
58
- fonts: fonts)
56
+ item, descriptors: descriptors, theme: theme, style: style, checkboxState: checkboxState)
59
57
  let hp = CGFloat(style.double("horizontalPadding", default: layout == "table" ? 16 : 12))
60
58
  let vp = CGFloat(style.double("verticalPadding", default: 8))
61
59
  let end =
@@ -77,8 +75,7 @@ final class NativeListActionCell: NativeListRendererCell {
77
75
  tone == "danger" ? "#CE2C31" : "#202020")
78
76
  NativeListResolvedText(
79
77
  item.data.string("title"), style: style.dictionary("title"), size: 16,
80
- weight: selector && icon == nil ? .regular : .medium, color: color, lineHeight: 24, lines: 1,
81
- fonts: fonts
78
+ weight: selector && icon == nil ? .regular : .medium, color: color, lineHeight: 24, lines: 1
82
79
  ).bind(title)
83
80
  visual.isHidden = icon == nil
84
81
  if var icon {
@@ -92,7 +89,7 @@ final class NativeListActionCell: NativeListRendererCell {
92
89
  }
93
90
  visualWidth.constant = CGFloat(image.double("width", default: selector ? 32 : 40))
94
91
  visualHeight.constant = CGFloat(image.double("height", default: selector ? 32 : 40))
95
- visual.bind(icon, style: image, key: item.key, theme: theme, isUnread: false, fonts: fonts)
92
+ visual.bind(icon, style: image, key: item.key, theme: theme, isUnread: false)
96
93
  if !keepsBorder { visual.layer.borderWidth = 0 }
97
94
  } else {
98
95
  visual.recycle()