@onekeyfe/react-native-native-list 3.0.179-alpha.303 → 3.0.179-alpha.306
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/LICENSE +36 -0
- package/README.md +32 -3
- package/android/build.gradle +0 -1
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +22 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +8 -8
- package/android/src/main/java/com/onekey/nativelist/NativeListActionRenderer.kt +5 -5
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +4 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +6 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +6 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +11 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +20 -20
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +5 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +7 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +5 -5
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +8 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListMetricCardRenderer.kt +14 -14
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +28 -15
- package/android/src/main/java/com/onekey/nativelist/NativeListRailRenderer.kt +4 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +3 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +5 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListRowHost.kt +1 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +20 -20
- package/android/src/main/java/com/onekey/nativelist/NativeListSystemRenderer.kt +3 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +104 -18
- package/android/src/main/java/com/onekey/nativelist/NativeListWalletGroupRenderer.kt +6 -5
- package/docs/SPEC.md +69 -0
- package/docs/STYLE_SPEC.md +12 -2
- package/ios/HybridNativeList.swift +18 -6
- package/ios/NativeListAccessoryStack.swift +14 -10
- package/ios/NativeListActionRenderer.swift +7 -4
- package/ios/NativeListActivityDetailsView.swift +63 -24
- package/ios/NativeListActivityRenderer.swift +19 -10
- package/ios/NativeListDataRowRenderer.swift +23 -19
- package/ios/NativeListDesignAssets.swift +43 -34
- package/ios/NativeListIdentityRenderer.swift +23 -19
- package/ios/NativeListLeadingVisual.swift +9 -4
- package/ios/NativeListMarketRenderer.swift +19 -11
- package/ios/NativeListMediaTileRenderer.swift +11 -7
- package/ios/NativeListMessageRenderer.swift +20 -10
- package/ios/NativeListMetricCardRenderer.swift +16 -12
- package/ios/NativeListRailRenderer.swift +9 -7
- package/ios/NativeListRendererCell.swift +6 -4
- package/ios/NativeListRendererRegistry.swift +8 -3
- package/ios/NativeListResolvedText.swift +3 -3
- package/ios/NativeListRowHost.swift +7 -2
- package/ios/NativeListSectionHeaderRenderer.swift +22 -19
- package/ios/NativeListSystemRenderer.swift +18 -16
- package/ios/NativeListTextStyles.swift +18 -12
- package/ios/NativeListWalletGroupRenderer.swift +6 -4
- package/ios/RNCNativeListView.swift +38 -5
- package/ios/tests/NativeListActivityPresentationTests.swift +5 -3
- package/ios/tests/NativeListLifecycleTests.swift +77 -2
- package/lib/module/NativeList.js +3 -0
- package/lib/module/NativeList.web.js +8 -1
- package/lib/module/fonts.js +44 -0
- package/lib/module/index.js +1 -0
- package/lib/module/web/NativeListWebEngine.js +48 -24
- package/lib/module/web/templates/ActionRowRenderer.js +2 -1
- package/lib/module/web/templates/IdentityRowRenderer.js +4 -3
- package/lib/module/web/templates/MarketRowRenderer.js +2 -1
- package/lib/module/web/templates/RowText.js +13 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +3 -2
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +9 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +5 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +6 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +7 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +6 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +11 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +2 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +3 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +1 -0
- package/lib/typescript/src/NativeList.nitro.d.ts +1 -0
- package/lib/typescript/src/fonts.d.ts +10 -0
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +4 -1
- package/lib/typescript/src/web/templates/RowText.d.ts +1 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +9 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +5 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +6 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +7 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +6 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +11 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +2 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +3 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +1 -0
- package/package.json +4 -5
- package/react-native-native-list.podspec +0 -1
- package/src/NativeList.nitro.ts +1 -0
- package/src/NativeList.tsx +3 -0
- package/src/NativeList.web.tsx +10 -1
- package/src/fonts.ts +64 -0
- package/src/index.ts +3 -0
- package/src/web/NativeListWebEngine.ts +53 -24
- package/src/web/templates/ActionRowRenderer.ts +2 -1
- package/src/web/templates/IdentityRowRenderer.ts +4 -3
- package/src/web/templates/MarketRowRenderer.ts +4 -2
- package/src/web/templates/RowText.ts +15 -3
- package/src/web/templates/SectionHeaderRowRenderer.ts +6 -3
- package/common/fonts/Roobert-Bold.ttf +0 -0
- package/common/fonts/Roobert-Medium.ttf +0 -0
- package/common/fonts/Roobert-Regular.ttf +0 -0
- package/common/fonts/Roobert-SemiBold.ttf +0 -0
|
@@ -101,6 +101,25 @@ 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
|
+
|
|
104
123
|
private data class VisibleMarketAnchor(
|
|
105
124
|
val key: String,
|
|
106
125
|
val offset: Int,
|
|
@@ -193,7 +212,7 @@ class NativeListView(
|
|
|
193
212
|
private val defaultRefreshTriggerDistancePx = (64 * resources.displayMetrics.density).roundToInt()
|
|
194
213
|
private var refreshIndicatorOffsetPx = 0
|
|
195
214
|
private val contentContainer = FrameLayout(context)
|
|
196
|
-
private val adapter = NativeListAdapter(reactContext)
|
|
215
|
+
private val adapter = NativeListAdapter(reactContext, fonts)
|
|
197
216
|
private val containerSlots = mutableListOf<View>()
|
|
198
217
|
private val slotHeights = IntArray(3)
|
|
199
218
|
private var containerSlotRelayoutPending = false
|
|
@@ -451,13 +470,13 @@ class NativeListView(
|
|
|
451
470
|
mass = REORDER_SPRING_MASS,
|
|
452
471
|
durationSeconds = REORDER_SPRING_DURATION_MS / 1_000.0,
|
|
453
472
|
)
|
|
454
|
-
private var footerView: NativeListRowHost = NativeListRendererRegistry.create(reactContext, NativeListRendererKey.ACTION.ordinal)
|
|
473
|
+
private var footerView: NativeListRowHost = NativeListRendererRegistry.create(reactContext, NativeListRendererKey.ACTION.ordinal, fonts)
|
|
455
474
|
private var footerRendererKey = NativeListRendererKey.ACTION
|
|
456
|
-
private val sectionIndexView = NativeListSectionIndexView(context)
|
|
475
|
+
private val sectionIndexView = NativeListSectionIndexView(context, fonts)
|
|
457
476
|
private val sectionIndexPreview = TextView(context)
|
|
458
477
|
private var config: NativeListConfig? = null
|
|
459
478
|
private var usesSelectorSourceScale = false
|
|
460
|
-
private val stickyHeaderView = NativeListRendererRegistry.create(reactContext, NativeListRendererKey.SECTION_HEADER.ordinal)
|
|
479
|
+
private val stickyHeaderView = NativeListRendererRegistry.create(reactContext, NativeListRendererKey.SECTION_HEADER.ordinal, fonts)
|
|
461
480
|
private var stickyHeaderSignature: String? = null
|
|
462
481
|
private var stickyHeaderConfig: NativeListConfig? = null
|
|
463
482
|
private val stickyHeaderHost = object : FrameLayout(reactContext) {
|
|
@@ -517,6 +536,7 @@ class NativeListView(
|
|
|
517
536
|
private var stickyObservedTree: ViewTreeObserver? = null
|
|
518
537
|
private var spacingDecoration: ItemSpacingDecoration? = null
|
|
519
538
|
private var itemTouchHelper: ItemTouchHelper? = null
|
|
539
|
+
private var activeReorderHolder: NativeListViewHolder? = null
|
|
520
540
|
private var reorderTouchListener: RecyclerView.OnItemTouchListener? = null
|
|
521
541
|
private var reorderTouchHandler: Handler? = null
|
|
522
542
|
private var endReachedGeneration: Int? = null
|
|
@@ -630,7 +650,7 @@ class NativeListView(
|
|
|
630
650
|
sectionIndexPreview.apply {
|
|
631
651
|
gravity = Gravity.CENTER
|
|
632
652
|
textSize = 30f
|
|
633
|
-
typeface =
|
|
653
|
+
typeface = fonts.regular(context)
|
|
634
654
|
setPadding(0, 0, sectionIndexDp(10), 0)
|
|
635
655
|
visibility = INVISIBLE
|
|
636
656
|
alpha = 0f
|
|
@@ -1663,8 +1683,19 @@ class NativeListView(
|
|
|
1663
1683
|
reorderTouchListener = null
|
|
1664
1684
|
recyclerView.removeOnItemTouchListener(keyboardTapTouchListener)
|
|
1665
1685
|
recyclerView.removeOnItemTouchListener(pagerGestureTouchListener)
|
|
1666
|
-
itemTouchHelper
|
|
1686
|
+
val previousHelper = itemTouchHelper
|
|
1667
1687
|
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
|
|
1668
1699
|
footerView.recycle()
|
|
1669
1700
|
footerView.dispose()
|
|
1670
1701
|
stopStickyHeaderTracking()
|
|
@@ -2005,7 +2036,7 @@ class NativeListView(
|
|
|
2005
2036
|
val position = indexOfChild(previous)
|
|
2006
2037
|
previous.recycle()
|
|
2007
2038
|
previous.dispose()
|
|
2008
|
-
footerView = NativeListRendererRegistry.create(reactContext, footer.rendererKey.ordinal)
|
|
2039
|
+
footerView = NativeListRendererRegistry.create(reactContext, footer.rendererKey.ordinal, fonts)
|
|
2009
2040
|
footerView.onRowPress = ::handleRowPress
|
|
2010
2041
|
footerView.onAction = ::handleAction
|
|
2011
2042
|
footerView.onBindingInvalidated = ::handleBindingInvalidated
|
|
@@ -2248,15 +2279,44 @@ class NativeListView(
|
|
|
2248
2279
|
}
|
|
2249
2280
|
|
|
2250
2281
|
private fun updateReordering(next: NativeListConfig) {
|
|
2282
|
+
dragFrom = RecyclerView.NO_POSITION
|
|
2283
|
+
dragTo = RecyclerView.NO_POSITION
|
|
2284
|
+
pendingReorder = null
|
|
2285
|
+
reorderPlaceholderDecoration.position = RecyclerView.NO_POSITION
|
|
2251
2286
|
stopReorderRelayoutLoop()
|
|
2252
2287
|
reorderTouchHandler?.removeCallbacksAndMessages(null)
|
|
2253
2288
|
reorderTouchHandler = null
|
|
2254
2289
|
reorderTouchListener?.let(recyclerView::removeOnItemTouchListener)
|
|
2255
2290
|
reorderTouchListener = null
|
|
2256
|
-
itemTouchHelper
|
|
2291
|
+
val previousHelper = itemTouchHelper
|
|
2257
2292
|
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()
|
|
2258
2317
|
adapter.cancelReorder()
|
|
2259
2318
|
if (!next.reorderable) return
|
|
2319
|
+
lateinit var helper: ItemTouchHelper
|
|
2260
2320
|
val callback = object : ItemTouchHelper.SimpleCallback(
|
|
2261
2321
|
ItemTouchHelper.UP or ItemTouchHelper.DOWN or ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT,
|
|
2262
2322
|
0,
|
|
@@ -2309,8 +2369,10 @@ class NativeListView(
|
|
|
2309
2369
|
override fun isLongPressDragEnabled(): Boolean = false
|
|
2310
2370
|
|
|
2311
2371
|
override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
|
|
2372
|
+
if (itemTouchHelper !== helper) return
|
|
2312
2373
|
super.onSelectedChanged(viewHolder, actionState)
|
|
2313
2374
|
if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
|
|
2375
|
+
activeReorderHolder = viewHolder as? NativeListViewHolder
|
|
2314
2376
|
val position = viewHolder?.bindingAdapterPosition ?: RecyclerView.NO_POSITION
|
|
2315
2377
|
val item = adapter.itemAt(position)
|
|
2316
2378
|
reorderPlaceholderDecoration.position = position
|
|
@@ -2337,7 +2399,7 @@ class NativeListView(
|
|
|
2337
2399
|
(viewHolder as? NativeListViewHolder)?.rowView?.setReorderActive(true)
|
|
2338
2400
|
if (compactWalletGroupDrag && viewHolder != null) {
|
|
2339
2401
|
recyclerView.postOnAnimation {
|
|
2340
|
-
if (viewHolder.itemView.isAttachedToWindow) {
|
|
2402
|
+
if (itemTouchHelper === helper && viewHolder.itemView.isAttachedToWindow) {
|
|
2341
2403
|
relayoutRecyclerViewImmediately()
|
|
2342
2404
|
}
|
|
2343
2405
|
}
|
|
@@ -2346,6 +2408,7 @@ class NativeListView(
|
|
|
2346
2408
|
}
|
|
2347
2409
|
|
|
2348
2410
|
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
|
|
2411
|
+
if (itemTouchHelper !== helper) return makeMovementFlags(0, 0)
|
|
2349
2412
|
if (viewHolder !is NativeListViewHolder) return makeMovementFlags(0, 0)
|
|
2350
2413
|
val item = adapter.itemAt(viewHolder.bindingAdapterPosition)
|
|
2351
2414
|
if (item == null || !item.isReorderable) return makeMovementFlags(0, 0)
|
|
@@ -2358,6 +2421,7 @@ class NativeListView(
|
|
|
2358
2421
|
source: RecyclerView.ViewHolder,
|
|
2359
2422
|
target: RecyclerView.ViewHolder,
|
|
2360
2423
|
): Boolean {
|
|
2424
|
+
if (itemTouchHelper !== helper) return false
|
|
2361
2425
|
if (source !is NativeListViewHolder || target !is NativeListViewHolder) return false
|
|
2362
2426
|
val from = source.bindingAdapterPosition
|
|
2363
2427
|
val to = target.bindingAdapterPosition
|
|
@@ -2399,7 +2463,7 @@ class NativeListView(
|
|
|
2399
2463
|
)
|
|
2400
2464
|
}
|
|
2401
2465
|
val displacedView = target.itemView
|
|
2402
|
-
prepareDisplacedReorderAnimation(displacedView)
|
|
2466
|
+
prepareDisplacedReorderAnimation(displacedView, helper)
|
|
2403
2467
|
val reordered = adapter.moveReordered(from, to)
|
|
2404
2468
|
if (reordered == null) {
|
|
2405
2469
|
logMoveAttempt(
|
|
@@ -2433,6 +2497,7 @@ class NativeListView(
|
|
|
2433
2497
|
actionState: Int,
|
|
2434
2498
|
isCurrentlyActive: Boolean,
|
|
2435
2499
|
) {
|
|
2500
|
+
if (itemTouchHelper !== helper) return
|
|
2436
2501
|
if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
|
|
2437
2502
|
latestDragDx = dX
|
|
2438
2503
|
latestDragDy = dY
|
|
@@ -2477,6 +2542,7 @@ class NativeListView(
|
|
|
2477
2542
|
totalSize: Int,
|
|
2478
2543
|
msSinceStartScroll: Long,
|
|
2479
2544
|
): Int {
|
|
2545
|
+
if (itemTouchHelper !== helper) return 0
|
|
2480
2546
|
val effectiveViewSize: Int
|
|
2481
2547
|
val effectiveOutOfBounds: Int
|
|
2482
2548
|
if (compactWalletGroupDrag) {
|
|
@@ -2530,6 +2596,9 @@ class NativeListView(
|
|
|
2530
2596
|
}
|
|
2531
2597
|
|
|
2532
2598
|
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
|
|
2533
2602
|
stopReorderRelayoutLoop()
|
|
2534
2603
|
val rowView = (viewHolder as? NativeListViewHolder)?.rowView
|
|
2535
2604
|
val draggedGroupKey = (rowView?.tag as? NativeListItem)?.key
|
|
@@ -2564,6 +2633,7 @@ class NativeListView(
|
|
|
2564
2633
|
val finishCompactWalletGroup = {
|
|
2565
2634
|
if (wasCompactWalletGroupDrag) {
|
|
2566
2635
|
recyclerView.postOnAnimation {
|
|
2636
|
+
if (itemTouchHelper !== helper) return@postOnAnimation
|
|
2567
2637
|
relayoutRecyclerViewImmediately()
|
|
2568
2638
|
val resolvedPosition = draggedGroupKey
|
|
2569
2639
|
?.let(adapter::positionOfKey)
|
|
@@ -2580,7 +2650,9 @@ class NativeListView(
|
|
|
2580
2650
|
REORDER_SPRING_DURATION_MS,
|
|
2581
2651
|
reorderSpringInterpolator,
|
|
2582
2652
|
) {
|
|
2583
|
-
recyclerView.postOnAnimation
|
|
2653
|
+
recyclerView.postOnAnimation {
|
|
2654
|
+
if (itemTouchHelper === helper) relayoutRecyclerViewImmediately()
|
|
2655
|
+
}
|
|
2584
2656
|
}
|
|
2585
2657
|
}
|
|
2586
2658
|
}
|
|
@@ -2597,9 +2669,12 @@ class NativeListView(
|
|
|
2597
2669
|
reordered.getOrNull(to + 1)?.let { payload.put("afterKey", it.key) }
|
|
2598
2670
|
reorderPayload = payload
|
|
2599
2671
|
adapter.commitReordered(reordered) {
|
|
2672
|
+
if (itemTouchHelper !== helper) return@commitReordered
|
|
2600
2673
|
finishCompactWalletGroup()
|
|
2601
2674
|
if (!wasCompactWalletGroupDrag) {
|
|
2602
|
-
recyclerView.postOnAnimation
|
|
2675
|
+
recyclerView.postOnAnimation {
|
|
2676
|
+
if (itemTouchHelper === helper) relayoutRecyclerViewImmediately()
|
|
2677
|
+
}
|
|
2603
2678
|
}
|
|
2604
2679
|
}
|
|
2605
2680
|
}
|
|
@@ -2615,7 +2690,9 @@ class NativeListView(
|
|
|
2615
2690
|
reorderPayload?.let { emit(REORDER, it) }
|
|
2616
2691
|
}
|
|
2617
2692
|
}
|
|
2618
|
-
|
|
2693
|
+
helper = ItemTouchHelper(callback)
|
|
2694
|
+
itemTouchHelper = helper
|
|
2695
|
+
helper.attachToRecyclerView(recyclerView)
|
|
2619
2696
|
val handler = Handler(Looper.getMainLooper())
|
|
2620
2697
|
reorderTouchHandler = handler
|
|
2621
2698
|
val movementLimit = dp(REORDER_ALLOWABLE_MOVEMENT_DP).toFloat()
|
|
@@ -2637,8 +2714,8 @@ class NativeListView(
|
|
|
2637
2714
|
}
|
|
2638
2715
|
|
|
2639
2716
|
private fun beginDrag(holder: RecyclerView.ViewHolder) {
|
|
2640
|
-
if (candidate !== holder || !holder.itemView.isAttachedToWindow) return
|
|
2641
|
-
|
|
2717
|
+
if (itemTouchHelper !== helper || candidate !== holder || !holder.itemView.isAttachedToWindow) return
|
|
2718
|
+
helper.startDrag(holder)
|
|
2642
2719
|
holder.itemView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
|
2643
2720
|
}
|
|
2644
2721
|
|
|
@@ -2648,6 +2725,7 @@ class NativeListView(
|
|
|
2648
2725
|
}
|
|
2649
2726
|
|
|
2650
2727
|
override fun onInterceptTouchEvent(recyclerView: RecyclerView, event: MotionEvent): Boolean {
|
|
2728
|
+
if (itemTouchHelper !== helper) return false
|
|
2651
2729
|
when (event.actionMasked) {
|
|
2652
2730
|
MotionEvent.ACTION_DOWN -> {
|
|
2653
2731
|
cancelPending()
|
|
@@ -2689,7 +2767,7 @@ class NativeListView(
|
|
|
2689
2767
|
}.also(recyclerView::addOnItemTouchListener)
|
|
2690
2768
|
}
|
|
2691
2769
|
|
|
2692
|
-
private fun prepareDisplacedReorderAnimation(view: View) {
|
|
2770
|
+
private fun prepareDisplacedReorderAnimation(view: View, helper: ItemTouchHelper) {
|
|
2693
2771
|
val previousX = view.x
|
|
2694
2772
|
val previousY = view.y
|
|
2695
2773
|
view.addOnLayoutChangeListener(object : View.OnLayoutChangeListener {
|
|
@@ -2705,6 +2783,7 @@ class NativeListView(
|
|
|
2705
2783
|
oldBottom: Int,
|
|
2706
2784
|
) {
|
|
2707
2785
|
changedView.removeOnLayoutChangeListener(this)
|
|
2786
|
+
if (itemTouchHelper !== helper) return
|
|
2708
2787
|
val deltaX = previousX - changedView.x
|
|
2709
2788
|
val deltaY = previousY - changedView.y
|
|
2710
2789
|
if (deltaX == 0f && deltaY == 0f) return
|
|
@@ -3016,6 +3095,7 @@ private data class NativeListSectionIndexEntry(
|
|
|
3016
3095
|
|
|
3017
3096
|
private class NativeListSectionIndexView(
|
|
3018
3097
|
context: android.content.Context,
|
|
3098
|
+
private val fonts: NativeListFonts,
|
|
3019
3099
|
) : View(context) {
|
|
3020
3100
|
var onSelect: ((Int, Boolean) -> Unit)? = null
|
|
3021
3101
|
var onInteractionEnded: (() -> Unit)? = null
|
|
@@ -3026,14 +3106,20 @@ private class NativeListSectionIndexView(
|
|
|
3026
3106
|
private var activeColor = Color.BLACK
|
|
3027
3107
|
private var activeTextColor = Color.WHITE
|
|
3028
3108
|
private var lastTouchIndex: Int? = null
|
|
3109
|
+
fun refreshFonts() {
|
|
3110
|
+
normalPaint.typeface = fonts.regular(context)
|
|
3111
|
+
activePaint.typeface = fonts.medium(context)
|
|
3112
|
+
invalidate()
|
|
3113
|
+
}
|
|
3114
|
+
|
|
3029
3115
|
private val activeBackgroundPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
|
3030
3116
|
private val normalPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
|
3031
3117
|
textAlign = Paint.Align.CENTER
|
|
3032
|
-
typeface =
|
|
3118
|
+
typeface = fonts.regular(context)
|
|
3033
3119
|
}
|
|
3034
3120
|
private val activePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
|
3035
3121
|
textAlign = Paint.Align.CENTER
|
|
3036
|
-
typeface =
|
|
3122
|
+
typeface = fonts.medium(context)
|
|
3037
3123
|
}
|
|
3038
3124
|
|
|
3039
3125
|
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) :
|
|
18
|
-
NativeListRendererRowView(context) {
|
|
17
|
+
internal class NativeListWalletGroupRowView(context: ThemedReactContext, fonts: NativeListFonts) :
|
|
18
|
+
NativeListRendererRowView(context, fonts) {
|
|
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) :
|
|
|
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 =
|
|
77
|
+
dragBadge.typeface = fonts.semibold(context)
|
|
78
78
|
compactContainer.addView(dragBadge)
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -84,6 +84,7 @@ internal class NativeListWalletGroupRowView(context: ThemedReactContext) :
|
|
|
84
84
|
layout: String,
|
|
85
85
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
|
|
86
86
|
) {
|
|
87
|
+
dragBadge.typeface = fonts.semibold(context)
|
|
87
88
|
currentTheme = theme
|
|
88
89
|
currentLayout = layout
|
|
89
90
|
members = memberItems(item)
|
|
@@ -135,7 +136,7 @@ internal class NativeListWalletGroupRowView(context: ThemedReactContext) :
|
|
|
135
136
|
members.forEachIndexed { index, member ->
|
|
136
137
|
val view =
|
|
137
138
|
memberViews.getOrPut(member.key) {
|
|
138
|
-
NativeListIdentityRowView(reactContext).also { view ->
|
|
139
|
+
NativeListIdentityRowView(reactContext, fonts).also { view ->
|
|
139
140
|
// Legacy: members own their disabled state; the group never gates them.
|
|
140
141
|
view.onRowPress = { source, origin -> onRowPress?.invoke(source, origin) }
|
|
141
142
|
view.onAction = { source, key, target, origin ->
|
|
@@ -168,7 +169,7 @@ internal class NativeListWalletGroupRowView(context: ThemedReactContext) :
|
|
|
168
169
|
}
|
|
169
170
|
if (compactParent == null) {
|
|
170
171
|
compactParent =
|
|
171
|
-
NativeListIdentityRowView(reactContext).also {
|
|
172
|
+
NativeListIdentityRowView(reactContext, fonts).also {
|
|
172
173
|
compactContainer.addView(
|
|
173
174
|
it,
|
|
174
175
|
0,
|
package/docs/SPEC.md
CHANGED
|
@@ -72,6 +72,30 @@ 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
|
+
|
|
75
99
|
### Native section title loading indicator
|
|
76
100
|
|
|
77
101
|
Status: implemented source; simulator rendering acceptance pending.
|
|
@@ -152,6 +176,51 @@ Existing geometry/typography differences are recorded in
|
|
|
152
176
|
them. iOS uses UICollectionView, Android RecyclerView, and Web a windowed DOM
|
|
153
177
|
engine. See [DESIGN.md](DESIGN.md) for their current ownership boundaries.
|
|
154
178
|
|
|
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
|
+
|
|
155
224
|
## Failures, fallback and limits
|
|
156
225
|
|
|
157
226
|
Snapshot validation rejects malformed/duplicate-key input without partial
|
package/docs/STYLE_SPEC.md
CHANGED
|
@@ -180,8 +180,18 @@ 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
|
|
184
|
-
|
|
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.
|
|
185
195
|
|
|
186
196
|
### 3.3 Spacing, radius, bounds
|
|
187
197
|
|
|
@@ -36,6 +36,13 @@ 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
|
+
|
|
39
46
|
var topScrollEdgeHard = false {
|
|
40
47
|
didSet {
|
|
41
48
|
runOnMain { [weak self] in
|
|
@@ -55,12 +62,17 @@ final class HybridNativeList: HybridNativeListSpec {
|
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
var snapshotJson: String = "" {
|
|
58
|
-
didSet {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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) }
|
|
64
76
|
}
|
|
65
77
|
}
|
|
66
78
|
|
|
@@ -118,6 +118,7 @@ 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()
|
|
121
122
|
private let accessoryButtons = (0..<2).map { _ in NativeListAccessoryButton(type: .system) }
|
|
122
123
|
private let checkboxButton = UIButton(type: .system)
|
|
123
124
|
private let spinner = UIActivityIndicatorView(style: .medium)
|
|
@@ -167,8 +168,10 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
167
168
|
func bind(
|
|
168
169
|
_ item: NativeListItem, descriptors: [[String: Any]], theme: [String: Any]?,
|
|
169
170
|
style: [String: Any], defaultSpacing: CGFloat = 2,
|
|
170
|
-
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
171
|
+
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
|
|
172
|
+
fonts: NativeListFontFamilies
|
|
171
173
|
) {
|
|
174
|
+
self.fonts = fonts
|
|
172
175
|
reset()
|
|
173
176
|
currentItem = item
|
|
174
177
|
currentTheme = theme
|
|
@@ -227,7 +230,7 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
227
230
|
button.setImage(nil, for: .normal)
|
|
228
231
|
button.setImage(nil, for: .disabled)
|
|
229
232
|
button.titleLabel?.font = nativeListFont(
|
|
230
|
-
ofSize: index == 0 ? 16 : 14, weight: index == 0 ? .medium : .regular)
|
|
233
|
+
ofSize: index == 0 ? 16 : 14, weight: index == 0 ? .medium : .regular, fonts: fonts)
|
|
231
234
|
button.titleLabel?.numberOfLines = 1
|
|
232
235
|
button.titleLabel?.lineBreakMode = .byTruncatingTail
|
|
233
236
|
button.contentHorizontalAlignment = .center
|
|
@@ -415,7 +418,7 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
415
418
|
NSAttributedString(
|
|
416
419
|
string: primary,
|
|
417
420
|
attributes: [
|
|
418
|
-
.font: nativeListFont(ofSize: 16, weight: .medium),
|
|
421
|
+
.font: nativeListFont(ofSize: 16, weight: .medium, fonts: fonts),
|
|
419
422
|
.foregroundColor: accessoryTextColor(
|
|
420
423
|
accessory.string("primaryTone"),
|
|
421
424
|
defaultTone: "primary",
|
|
@@ -433,7 +436,7 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
433
436
|
NSAttributedString(
|
|
434
437
|
string: secondary,
|
|
435
438
|
attributes: [
|
|
436
|
-
.font: nativeListFont(ofSize: 14),
|
|
439
|
+
.font: nativeListFont(ofSize: 14, fonts: fonts),
|
|
437
440
|
.foregroundColor: accessoryTextColor(
|
|
438
441
|
accessory.string("secondaryTone"),
|
|
439
442
|
defaultTone: "secondary",
|
|
@@ -459,7 +462,7 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
459
462
|
showAccessory(index, "⋮", action: action)
|
|
460
463
|
guard accessoryButtons.indices.contains(index) else { return }
|
|
461
464
|
let button = accessoryButtons[index]
|
|
462
|
-
button.titleLabel?.font = nativeListFont(ofSize: 20, weight: .medium)
|
|
465
|
+
button.titleLabel?.font = nativeListFont(ofSize: 20, weight: .medium, fonts: fonts)
|
|
463
466
|
accessorySizeConstraints.append(contentsOf: [
|
|
464
467
|
button.widthAnchor.constraint(equalToConstant: 24),
|
|
465
468
|
button.heightAnchor.constraint(equalToConstant: 24),
|
|
@@ -564,7 +567,7 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
564
567
|
}
|
|
565
568
|
for segment in segments {
|
|
566
569
|
attributes[.font] = nativeListTabularFont(
|
|
567
|
-
ofSize: segment.string("style") == "subscript" ? 10 : 16, weight: .medium)
|
|
570
|
+
ofSize: segment.string("style") == "subscript" ? 10 : 16, weight: .medium, fonts: fonts)
|
|
568
571
|
value.append(NSAttributedString(string: segment.string("text"), attributes: attributes))
|
|
569
572
|
}
|
|
570
573
|
button.setAttributedTitle(value, for: .normal)
|
|
@@ -580,14 +583,14 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
580
583
|
let accessory = button as? NativeListAccessoryButton
|
|
581
584
|
let baseFont =
|
|
582
585
|
(originalText?.attribute(.font, at: 0, effectiveRange: nil) as? UIFont) ?? button.titleLabel?
|
|
583
|
-
.font ?? nativeListFont(ofSize: 14)
|
|
586
|
+
.font ?? nativeListFont(ofSize: 14, fonts: fonts)
|
|
584
587
|
let size = CGFloat(style.double("fontSize", default: Double(baseFont.pointSize)))
|
|
585
588
|
let font: UIFont
|
|
586
589
|
if let weightName = style["fontWeight"] as? String {
|
|
587
590
|
font = nativeListFont(
|
|
588
591
|
ofSize: size,
|
|
589
|
-
weight: marketFontWeight(weightName, fallback: .regular)
|
|
590
|
-
|
|
592
|
+
weight: marketFontWeight(weightName, fallback: .regular),
|
|
593
|
+
fonts: fonts)
|
|
591
594
|
} else {
|
|
592
595
|
font = baseFont.withSize(size)
|
|
593
596
|
}
|
|
@@ -659,7 +662,8 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
659
662
|
style["fontWeight"] == nil
|
|
660
663
|
? original.withSize(size)
|
|
661
664
|
: nativeListFont(
|
|
662
|
-
ofSize: size, weight: marketFontWeight(style.string("fontWeight"), fallback: .regular)
|
|
665
|
+
ofSize: size, weight: marketFontWeight(style.string("fontWeight"), fallback: .regular),
|
|
666
|
+
fonts: fonts)
|
|
663
667
|
text.addAttribute(.font, value: font, range: range)
|
|
664
668
|
}
|
|
665
669
|
}
|
|
@@ -2,7 +2,8 @@ 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
|
|
5
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String,
|
|
6
|
+
fonts: NativeListFontFamilies
|
|
6
7
|
) -> CGFloat? {
|
|
7
8
|
return item.data.string("presentation") == "accountSelector"
|
|
8
9
|
? 48 : item.data.dictionary("icon") == nil ? 44 : 60
|
|
@@ -53,7 +54,8 @@ final class NativeListActionCell: NativeListRendererCell {
|
|
|
53
54
|
return [checkbox]
|
|
54
55
|
} ?? item.data.dictionaries("trailing")
|
|
55
56
|
accessories.bind(
|
|
56
|
-
item, descriptors: descriptors, theme: theme, style: style, checkboxState: checkboxState
|
|
57
|
+
item, descriptors: descriptors, theme: theme, style: style, checkboxState: checkboxState,
|
|
58
|
+
fonts: fonts)
|
|
57
59
|
let hp = CGFloat(style.double("horizontalPadding", default: layout == "table" ? 16 : 12))
|
|
58
60
|
let vp = CGFloat(style.double("verticalPadding", default: 8))
|
|
59
61
|
let end =
|
|
@@ -75,7 +77,8 @@ final class NativeListActionCell: NativeListRendererCell {
|
|
|
75
77
|
tone == "danger" ? "#CE2C31" : "#202020")
|
|
76
78
|
NativeListResolvedText(
|
|
77
79
|
item.data.string("title"), style: style.dictionary("title"), size: 16,
|
|
78
|
-
weight: selector && icon == nil ? .regular : .medium, color: color, lineHeight: 24, lines: 1
|
|
80
|
+
weight: selector && icon == nil ? .regular : .medium, color: color, lineHeight: 24, lines: 1,
|
|
81
|
+
fonts: fonts
|
|
79
82
|
).bind(title)
|
|
80
83
|
visual.isHidden = icon == nil
|
|
81
84
|
if var icon {
|
|
@@ -89,7 +92,7 @@ final class NativeListActionCell: NativeListRendererCell {
|
|
|
89
92
|
}
|
|
90
93
|
visualWidth.constant = CGFloat(image.double("width", default: selector ? 32 : 40))
|
|
91
94
|
visualHeight.constant = CGFloat(image.double("height", default: selector ? 32 : 40))
|
|
92
|
-
visual.bind(icon, style: image, key: item.key, theme: theme, isUnread: false)
|
|
95
|
+
visual.bind(icon, style: image, key: item.key, theme: theme, isUnread: false, fonts: fonts)
|
|
93
96
|
if !keepsBorder { visual.layer.borderWidth = 0 }
|
|
94
97
|
} else {
|
|
95
98
|
visual.recycle()
|