@onekeyfe/react-native-bottom-tabs 6.7.0-40 → 6.7.0-41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsView.kt +209 -37
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsViewManager.kt +4 -3
- package/android/src/main/java/com/onekey/bottomtabs/FloatingTabBarStyle.kt +22 -6
- package/docs/SPEC.md +18 -6
- package/lib/module/BottomTabs.js +55 -54
- package/package.json +1 -1
- package/src/BottomTabs.tsx +37 -37
|
@@ -201,8 +201,10 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
201
201
|
}
|
|
202
202
|
var items: MutableList<TabInfo> = mutableListOf()
|
|
203
203
|
private val iconSources: MutableMap<Int, ImageSource> = mutableMapOf()
|
|
204
|
+
private val selectedIconSources: MutableMap<Int, ImageSource> = mutableMapOf()
|
|
204
205
|
private val drawableCache: MutableMap<ImageSource, Drawable> = mutableMapOf()
|
|
205
206
|
private val iconRequestTokens: MutableMap<Int, Any> = mutableMapOf()
|
|
207
|
+
private val selectedIconRequestTokens: MutableMap<Int, Any> = mutableMapOf()
|
|
206
208
|
|
|
207
209
|
private var isLayoutEnqueued = false
|
|
208
210
|
private var selectedItem: String? = null
|
|
@@ -233,6 +235,7 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
233
235
|
private var floatingStretch = 0f
|
|
234
236
|
private var floatingLiftAnimator: ValueAnimator? = null
|
|
235
237
|
private var floatingSlideAnimator: ValueAnimator? = null
|
|
238
|
+
private var floatingSlideTargetX = Float.NaN
|
|
236
239
|
private var floatingVisibilityCallback: Choreographer.FrameCallback? = null
|
|
237
240
|
private var floatingTouchView: View? = null
|
|
238
241
|
private var floatingTouchItemId = View.NO_ID
|
|
@@ -653,7 +656,20 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
653
656
|
1f + (FloatingTabBarMetrics.LENS_SCALE_Y - 1f) * floatingLift - floatingStretch * 0.4f
|
|
654
657
|
}
|
|
655
658
|
|
|
659
|
+
private val floatingLiftSettle = Runnable {
|
|
660
|
+
if (floatingTouchItemId == View.NO_ID) {
|
|
661
|
+
animateFloatingLift(0f)
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
private fun cancelFloatingSlideAnimator() {
|
|
666
|
+
floatingSlideAnimator?.cancel()
|
|
667
|
+
floatingSlideAnimator = null
|
|
668
|
+
floatingSlideTargetX = Float.NaN
|
|
669
|
+
}
|
|
670
|
+
|
|
656
671
|
private fun animateFloatingLift(target: Float) {
|
|
672
|
+
floatingBar.removeCallbacks(floatingLiftSettle)
|
|
657
673
|
floatingLiftAnimator?.cancel()
|
|
658
674
|
val start = floatingLift
|
|
659
675
|
if (start == target) {
|
|
@@ -662,8 +678,15 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
662
678
|
}
|
|
663
679
|
val lifting = target > start
|
|
664
680
|
floatingLiftAnimator = ValueAnimator.ofFloat(start, target).apply {
|
|
665
|
-
duration = if (lifting)
|
|
666
|
-
|
|
681
|
+
duration = if (lifting) {
|
|
682
|
+
FloatingTabBarMetrics.LIFT_UP_DURATION_MS
|
|
683
|
+
} else {
|
|
684
|
+
FloatingTabBarMetrics.LIFT_SETTLE_DURATION_MS
|
|
685
|
+
}
|
|
686
|
+
interpolator = SpringInterpolator(
|
|
687
|
+
dampingRatio = if (lifting) 0.72f else 0.8f,
|
|
688
|
+
angularFrequency = if (lifting) 9f else 7.8f,
|
|
689
|
+
)
|
|
667
690
|
addUpdateListener {
|
|
668
691
|
floatingLift = it.animatedValue as Float
|
|
669
692
|
applyFloatingIndicatorState()
|
|
@@ -672,8 +695,40 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
672
695
|
}
|
|
673
696
|
}
|
|
674
697
|
|
|
675
|
-
private fun
|
|
676
|
-
|
|
698
|
+
private fun scheduleFloatingLiftSettle(cancelled: Boolean) {
|
|
699
|
+
floatingBar.removeCallbacks(floatingLiftSettle)
|
|
700
|
+
if (cancelled) {
|
|
701
|
+
animateFloatingLift(0f)
|
|
702
|
+
return
|
|
703
|
+
}
|
|
704
|
+
val slideAnimator = floatingSlideAnimator
|
|
705
|
+
if (slideAnimator != null && slideAnimator.isRunning) {
|
|
706
|
+
val remainingFraction = (1f - slideAnimator.animatedFraction).coerceIn(0f, 1f)
|
|
707
|
+
val delayMs = (FloatingTabBarMetrics.LIFT_HOLD_DURING_SLIDE_MS * remainingFraction)
|
|
708
|
+
.roundToInt()
|
|
709
|
+
.toLong()
|
|
710
|
+
if (delayMs > 16L) {
|
|
711
|
+
floatingBar.postDelayed(floatingLiftSettle, delayMs)
|
|
712
|
+
return
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
animateFloatingLift(0f)
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
private fun animateFloatingIndicatorTo(
|
|
719
|
+
targetX: Float,
|
|
720
|
+
durationMs: Long = FloatingTabBarMetrics.SLIDE_DURATION_MS,
|
|
721
|
+
) {
|
|
722
|
+
val activeAnimator = floatingSlideAnimator
|
|
723
|
+
if (
|
|
724
|
+
activeAnimator != null &&
|
|
725
|
+
activeAnimator.isRunning &&
|
|
726
|
+
!floatingSlideTargetX.isNaN() &&
|
|
727
|
+
abs(floatingSlideTargetX - targetX) < 0.5f
|
|
728
|
+
) {
|
|
729
|
+
return
|
|
730
|
+
}
|
|
731
|
+
cancelFloatingSlideAnimator()
|
|
677
732
|
val startX = floatingIndicator.x
|
|
678
733
|
if (abs(targetX - startX) < 0.5f) {
|
|
679
734
|
floatingIndicator.x = targetX
|
|
@@ -682,23 +737,39 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
682
737
|
return
|
|
683
738
|
}
|
|
684
739
|
var previousX = startX
|
|
685
|
-
|
|
740
|
+
var previousTimeMs = SystemClock.uptimeMillis()
|
|
741
|
+
floatingSlideTargetX = targetX
|
|
742
|
+
val animator = ValueAnimator.ofFloat(startX, targetX)
|
|
743
|
+
floatingSlideAnimator = animator
|
|
744
|
+
animator.apply {
|
|
686
745
|
duration = durationMs
|
|
687
|
-
interpolator = SpringInterpolator(
|
|
746
|
+
interpolator = SpringInterpolator(
|
|
747
|
+
dampingRatio = FloatingTabBarMetrics.SLIDE_SPRING_DAMPING,
|
|
748
|
+
angularFrequency = FloatingTabBarMetrics.SLIDE_SPRING_FREQUENCY,
|
|
749
|
+
)
|
|
688
750
|
addUpdateListener {
|
|
751
|
+
val nowMs = SystemClock.uptimeMillis()
|
|
752
|
+
val elapsedMs = (nowMs - previousTimeMs).coerceIn(4L, 32L).toFloat()
|
|
753
|
+
previousTimeMs = nowMs
|
|
689
754
|
val x = it.animatedValue as Float
|
|
690
755
|
val frameDelta = abs(x - previousX)
|
|
691
756
|
previousX = x
|
|
692
757
|
floatingIndicator.x = x
|
|
693
|
-
//
|
|
694
|
-
|
|
758
|
+
// Normalize velocity to a 16ms reference step so 60Hz and 120Hz displays
|
|
759
|
+
// produce identical liquid stretch during the spring slide.
|
|
760
|
+
val normalizedStepDelta = frameDelta * (16f / elapsedMs)
|
|
761
|
+
val rawStretch = (normalizedStepDelta / floatingIndicator.width.coerceAtLeast(1) * 1.4f)
|
|
695
762
|
.coerceAtMost(FloatingTabBarMetrics.LENS_MAX_STRETCH)
|
|
696
|
-
floatingStretch = floatingStretch * 0.
|
|
763
|
+
floatingStretch = floatingStretch * 0.62f + rawStretch * 0.38f
|
|
697
764
|
applyFloatingIndicatorState()
|
|
698
765
|
}
|
|
699
766
|
doOnEnd {
|
|
700
|
-
|
|
701
|
-
|
|
767
|
+
if (floatingSlideAnimator === animator) {
|
|
768
|
+
floatingSlideAnimator = null
|
|
769
|
+
floatingSlideTargetX = Float.NaN
|
|
770
|
+
floatingStretch = 0f
|
|
771
|
+
applyFloatingIndicatorState()
|
|
772
|
+
}
|
|
702
773
|
}
|
|
703
774
|
start()
|
|
704
775
|
}
|
|
@@ -727,14 +798,32 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
727
798
|
val targetX = getFloatingItemX(selectedIndex) ?: return
|
|
728
799
|
floatingIndicator.visibility = VISIBLE
|
|
729
800
|
|
|
730
|
-
if (!
|
|
731
|
-
|
|
801
|
+
if (!floatingIndicatorPositioned) {
|
|
802
|
+
cancelFloatingSlideAnimator()
|
|
732
803
|
floatingIndicator.x = targetX
|
|
733
804
|
floatingStretch = 0f
|
|
734
805
|
floatingIndicatorPositioned = true
|
|
735
806
|
applyFloatingIndicatorState()
|
|
736
807
|
return
|
|
737
808
|
}
|
|
809
|
+
val activeAnimator = floatingSlideAnimator
|
|
810
|
+
if (
|
|
811
|
+
activeAnimator != null &&
|
|
812
|
+
activeAnimator.isRunning &&
|
|
813
|
+
!floatingSlideTargetX.isNaN() &&
|
|
814
|
+
abs(floatingSlideTargetX - targetX) < 0.5f
|
|
815
|
+
) {
|
|
816
|
+
// Keep an in-flight slide to the same target running smoothly even when
|
|
817
|
+
// a late layout/item sync arrives with animate = false.
|
|
818
|
+
return
|
|
819
|
+
}
|
|
820
|
+
if (!animate) {
|
|
821
|
+
cancelFloatingSlideAnimator()
|
|
822
|
+
floatingIndicator.x = targetX
|
|
823
|
+
floatingStretch = 0f
|
|
824
|
+
applyFloatingIndicatorState()
|
|
825
|
+
return
|
|
826
|
+
}
|
|
738
827
|
animateFloatingIndicatorTo(targetX)
|
|
739
828
|
}
|
|
740
829
|
|
|
@@ -865,7 +954,7 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
865
954
|
updateFloatingIndicatorWidth(itemView.width)
|
|
866
955
|
floatingIndicator.visibility = VISIBLE
|
|
867
956
|
if (floatingIndicatorPositioned) {
|
|
868
|
-
animateFloatingIndicatorTo(targetX, durationMs =
|
|
957
|
+
animateFloatingIndicatorTo(targetX, durationMs = FloatingTabBarMetrics.SLIDE_DURATION_MS)
|
|
869
958
|
} else {
|
|
870
959
|
floatingIndicator.x = targetX
|
|
871
960
|
floatingIndicatorPositioned = true
|
|
@@ -901,7 +990,7 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
901
990
|
val targetStretch = (velocityDpPerMs * 0.06f).coerceAtMost(FloatingTabBarMetrics.LENS_MAX_STRETCH)
|
|
902
991
|
floatingStretch = floatingStretch * 0.6f + targetStretch * 0.4f
|
|
903
992
|
|
|
904
|
-
|
|
993
|
+
cancelFloatingSlideAnimator()
|
|
905
994
|
floatingIndicator.x = centerX - halfWidth
|
|
906
995
|
applyFloatingIndicatorState()
|
|
907
996
|
floatingBar.removeCallbacks(floatingStretchDecay)
|
|
@@ -938,7 +1027,6 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
938
1027
|
val wasDragging = floatingDragging
|
|
939
1028
|
clearFloatingTouchTracking()
|
|
940
1029
|
setFloatingItemMagnified(View.NO_ID)
|
|
941
|
-
animateFloatingLift(0f)
|
|
942
1030
|
|
|
943
1031
|
if (!cancelled && requestedItemId != View.NO_ID) {
|
|
944
1032
|
if (!wasDragging) {
|
|
@@ -952,6 +1040,7 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
952
1040
|
// Settles on the selected tab, which is the old one for cancelled or
|
|
953
1041
|
// preventsDefault presses.
|
|
954
1042
|
updateFloatingIndicator(animate = true)
|
|
1043
|
+
scheduleFloatingLiftSettle(cancelled = cancelled || wasDragging)
|
|
955
1044
|
}
|
|
956
1045
|
|
|
957
1046
|
private fun clearFloatingTouchTracking() {
|
|
@@ -966,8 +1055,9 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
966
1055
|
|
|
967
1056
|
private fun resetFloatingGesture() {
|
|
968
1057
|
clearFloatingTouchTracking()
|
|
1058
|
+
floatingBar.removeCallbacks(floatingLiftSettle)
|
|
969
1059
|
floatingLiftAnimator?.cancel()
|
|
970
|
-
|
|
1060
|
+
cancelFloatingSlideAnimator()
|
|
971
1061
|
floatingLift = 0f
|
|
972
1062
|
floatingStretch = 0f
|
|
973
1063
|
items.indices.forEach { itemId ->
|
|
@@ -1188,7 +1278,13 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1188
1278
|
private fun setSelectedIndex(itemId: Int) {
|
|
1189
1279
|
val selectionChanged = bottomNavigation.selectedItemId != itemId
|
|
1190
1280
|
bottomNavigation.selectedItemId = itemId
|
|
1191
|
-
if (
|
|
1281
|
+
if (selectionChanged) {
|
|
1282
|
+
updateMenuItemIconsForSelection()
|
|
1283
|
+
}
|
|
1284
|
+
if (
|
|
1285
|
+
androidTabBarStyle == AndroidTabBarStyle.FLOATING &&
|
|
1286
|
+
(selectionChanged || !floatingIndicatorPositioned)
|
|
1287
|
+
) {
|
|
1192
1288
|
post { updateFloatingIndicator(animate = selectionChanged) }
|
|
1193
1289
|
}
|
|
1194
1290
|
if (disablePageAnimations) {
|
|
@@ -1450,11 +1546,7 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1450
1546
|
}
|
|
1451
1547
|
|
|
1452
1548
|
menuItem.isVisible = !item.hidden
|
|
1453
|
-
|
|
1454
|
-
getDrawable(index, iconSources[index]!!) {
|
|
1455
|
-
menuItem.icon = it
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1549
|
+
applyMenuItemIcon(index, menuItem)
|
|
1458
1550
|
|
|
1459
1551
|
if (item.badge?.isNotEmpty() == true) {
|
|
1460
1552
|
val badge = bottomNavigation.getOrCreateBadge(index)
|
|
@@ -1506,6 +1598,49 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1506
1598
|
return bottomNavigation.menu.findItem(index) ?: bottomNavigation.menu.add(0, index, 0, title)
|
|
1507
1599
|
}
|
|
1508
1600
|
|
|
1601
|
+
private fun isItemSelected(index: Int): Boolean {
|
|
1602
|
+
val selectedKey = selectedItem
|
|
1603
|
+
return if (selectedKey != null) {
|
|
1604
|
+
items.getOrNull(index)?.key == selectedKey
|
|
1605
|
+
} else {
|
|
1606
|
+
bottomNavigation.selectedItemId == index
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
private fun activeIconSourceForIndex(index: Int): Pair<ImageSource, Boolean>? {
|
|
1611
|
+
val selected = isItemSelected(index)
|
|
1612
|
+
if (selected) {
|
|
1613
|
+
selectedIconSources[index]?.let { return it to true }
|
|
1614
|
+
}
|
|
1615
|
+
iconSources[index]?.let { return it to false }
|
|
1616
|
+
selectedIconSources[index]?.let { return it to true }
|
|
1617
|
+
return null
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
private fun applyMenuItemIcon(index: Int, menuItem: MenuItem) {
|
|
1621
|
+
val (source, isSelectedSource) = activeIconSourceForIndex(index) ?: return
|
|
1622
|
+
drawableCache[source]?.let { cached ->
|
|
1623
|
+
if (menuItem.icon !== cached) {
|
|
1624
|
+
menuItem.icon = cached
|
|
1625
|
+
}
|
|
1626
|
+
return
|
|
1627
|
+
}
|
|
1628
|
+
loadDrawable(index, source, isSelectedSource) { drawable ->
|
|
1629
|
+
val currentSource = activeIconSourceForIndex(index)?.first
|
|
1630
|
+
if (currentSource == source && drawable != null) {
|
|
1631
|
+
menuItem.icon = drawable
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
private fun updateMenuItemIconsForSelection() {
|
|
1637
|
+
items.indices.forEach { index ->
|
|
1638
|
+
bottomNavigation.menu.findItem(index)?.let { menuItem ->
|
|
1639
|
+
applyMenuItemIcon(index, menuItem)
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1509
1644
|
fun setIcons(icons: ReadableArray?) {
|
|
1510
1645
|
if (icons == null || icons.size() == 0) {
|
|
1511
1646
|
return
|
|
@@ -1521,10 +1656,38 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1521
1656
|
val imageSource = ImageSource(context, uri)
|
|
1522
1657
|
this.iconSources[idx] = imageSource
|
|
1523
1658
|
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1659
|
+
loadDrawable(idx, imageSource, isSelectedIcon = false) {
|
|
1660
|
+
bottomNavigation.menu.findItem(idx)?.let { menuItem ->
|
|
1661
|
+
applyMenuItemIcon(idx, menuItem)
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
fun setSelectedIcons(icons: ReadableArray?) {
|
|
1668
|
+
if (icons == null || icons.size() == 0) {
|
|
1669
|
+
selectedIconRequestTokens.values.forEach { OneKeyNamedSVG.cancel(it) }
|
|
1670
|
+
selectedIconRequestTokens.clear()
|
|
1671
|
+
selectedIconSources.clear()
|
|
1672
|
+
updateMenuItemIconsForSelection()
|
|
1673
|
+
return
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
for (idx in 0 until icons.size()) {
|
|
1677
|
+
val source = icons.getMap(idx)
|
|
1678
|
+
val uri = source?.getString("uri")
|
|
1679
|
+
if (uri.isNullOrEmpty()) {
|
|
1680
|
+
selectedIconSources.remove(idx)
|
|
1681
|
+
continue
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
val imageSource = ImageSource(context, uri)
|
|
1685
|
+
this.selectedIconSources[idx] = imageSource
|
|
1686
|
+
|
|
1687
|
+
// Pre-warm the selected icon into drawableCache so tab switches swap synchronously.
|
|
1688
|
+
loadDrawable(idx, imageSource, isSelectedIcon = true) {
|
|
1689
|
+
bottomNavigation.menu.findItem(idx)?.let { menuItem ->
|
|
1690
|
+
applyMenuItemIcon(idx, menuItem)
|
|
1528
1691
|
}
|
|
1529
1692
|
}
|
|
1530
1693
|
}
|
|
@@ -1555,8 +1718,15 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1555
1718
|
}
|
|
1556
1719
|
|
|
1557
1720
|
@SuppressLint("CheckResult")
|
|
1558
|
-
private fun
|
|
1559
|
-
|
|
1721
|
+
private fun loadDrawable(
|
|
1722
|
+
index: Int,
|
|
1723
|
+
imageSource: ImageSource,
|
|
1724
|
+
isSelectedIcon: Boolean,
|
|
1725
|
+
onDrawableReady: (Drawable?) -> Unit,
|
|
1726
|
+
) {
|
|
1727
|
+
val tokenMap = if (isSelectedIcon) selectedIconRequestTokens else iconRequestTokens
|
|
1728
|
+
val sourceMap = if (isSelectedIcon) selectedIconSources else iconSources
|
|
1729
|
+
tokenMap.remove(index)?.let { OneKeyNamedSVG.cancel(it) }
|
|
1560
1730
|
drawableCache[imageSource]?.let {
|
|
1561
1731
|
onDrawableReady(it)
|
|
1562
1732
|
return
|
|
@@ -1569,7 +1739,7 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1569
1739
|
return
|
|
1570
1740
|
}
|
|
1571
1741
|
val token = Any()
|
|
1572
|
-
|
|
1742
|
+
tokenMap[index] = token
|
|
1573
1743
|
val iconSizePx = bottomNavigation.itemIconSize.coerceAtLeast(1)
|
|
1574
1744
|
val density = resources.displayMetrics.density
|
|
1575
1745
|
OneKeyNamedSVG.request(
|
|
@@ -1581,24 +1751,24 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1581
1751
|
height = iconSizePx,
|
|
1582
1752
|
scale = density,
|
|
1583
1753
|
) { bitmap ->
|
|
1584
|
-
if (
|
|
1754
|
+
if (tokenMap[index] !== token) {
|
|
1585
1755
|
return@request
|
|
1586
1756
|
}
|
|
1587
|
-
|
|
1757
|
+
tokenMap.remove(index)
|
|
1588
1758
|
if (bitmap == null) {
|
|
1589
1759
|
onDrawableReady(null)
|
|
1590
1760
|
return@request
|
|
1591
1761
|
}
|
|
1592
1762
|
val stateDrawable = BitmapDrawable(context.resources, bitmap)
|
|
1593
1763
|
drawableCache[imageSource] = stateDrawable
|
|
1594
|
-
if (
|
|
1764
|
+
if (sourceMap[index] == imageSource) {
|
|
1595
1765
|
onDrawableReady(stateDrawable)
|
|
1596
1766
|
}
|
|
1597
1767
|
}
|
|
1598
1768
|
return
|
|
1599
1769
|
}
|
|
1600
1770
|
val token = Any()
|
|
1601
|
-
|
|
1771
|
+
tokenMap[index] = token
|
|
1602
1772
|
val iconSizePx = bottomNavigation.itemIconSize
|
|
1603
1773
|
val request = ImageRequest.Builder(context)
|
|
1604
1774
|
.data(imageSource.getUri(context))
|
|
@@ -1607,13 +1777,13 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1607
1777
|
.precision(Precision.EXACT)
|
|
1608
1778
|
.target { drawable ->
|
|
1609
1779
|
post {
|
|
1610
|
-
if (
|
|
1780
|
+
if (tokenMap[index] !== token) {
|
|
1611
1781
|
return@post
|
|
1612
1782
|
}
|
|
1613
|
-
|
|
1783
|
+
tokenMap.remove(index)
|
|
1614
1784
|
val stateDrawable = drawable.asDrawable(context.resources)
|
|
1615
1785
|
drawableCache[imageSource] = stateDrawable
|
|
1616
|
-
if (
|
|
1786
|
+
if (sourceMap[index] == imageSource) {
|
|
1617
1787
|
onDrawableReady(stateDrawable)
|
|
1618
1788
|
}
|
|
1619
1789
|
}
|
|
@@ -1687,6 +1857,8 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1687
1857
|
fun onDropViewInstance() {
|
|
1688
1858
|
iconRequestTokens.values.forEach { OneKeyNamedSVG.cancel(it) }
|
|
1689
1859
|
iconRequestTokens.clear()
|
|
1860
|
+
selectedIconRequestTokens.values.forEach { OneKeyNamedSVG.cancel(it) }
|
|
1861
|
+
selectedIconRequestTokens.clear()
|
|
1690
1862
|
androidBottomBlurEnabled = false
|
|
1691
1863
|
updateBlurAppearance()
|
|
1692
1864
|
releaseBottomBlur()
|
|
@@ -207,9 +207,10 @@ class BottomTabsViewManager(context: ReactApplicationContext) :
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
// iOS-only props (no-ops on Android)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
override fun setSelectedIcons(view: BottomTabsView?, value: ReadableArray?) {
|
|
211
|
+
if (view != null)
|
|
212
|
+
view.setSelectedIcons(value)
|
|
213
|
+
}
|
|
213
214
|
override fun setTranslucent(view: BottomTabsView?, value: Boolean) {}
|
|
214
215
|
override fun setSidebarAdaptable(view: BottomTabsView?, value: Boolean) {}
|
|
215
216
|
override fun setScrollEdgeAppearance(view: BottomTabsView?, value: String?) {}
|
|
@@ -24,6 +24,14 @@ internal object FloatingTabBarMetrics {
|
|
|
24
24
|
const val LENS_MAX_STRETCH = 0.16f
|
|
25
25
|
const val ITEM_PRESSED_SCALE = 1.1f
|
|
26
26
|
const val DRAG_EDGE_RESISTANCE = 0.22f
|
|
27
|
+
|
|
28
|
+
// Motion timings aligned with the iOS 26 Liquid Glass tab bar spring.
|
|
29
|
+
const val SLIDE_DURATION_MS = 520L
|
|
30
|
+
const val SLIDE_SPRING_DAMPING = 0.82f
|
|
31
|
+
const val SLIDE_SPRING_FREQUENCY = 7.5f
|
|
32
|
+
const val LIFT_UP_DURATION_MS = 220L
|
|
33
|
+
const val LIFT_SETTLE_DURATION_MS = 380L
|
|
34
|
+
const val LIFT_HOLD_DURING_SLIDE_MS = 200L
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
/**
|
|
@@ -31,20 +39,28 @@ internal object FloatingTabBarMetrics {
|
|
|
31
39
|
* below 1 overshoots slightly before settling, matching UIKit spring motion.
|
|
32
40
|
*/
|
|
33
41
|
internal class SpringInterpolator(
|
|
34
|
-
private val dampingRatio: Float =
|
|
35
|
-
private val angularFrequency: Float =
|
|
42
|
+
private val dampingRatio: Float = FloatingTabBarMetrics.SLIDE_SPRING_DAMPING,
|
|
43
|
+
private val angularFrequency: Float = FloatingTabBarMetrics.SLIDE_SPRING_FREQUENCY,
|
|
36
44
|
) : Interpolator {
|
|
37
45
|
private val dampedFrequency =
|
|
38
46
|
angularFrequency * sqrt(1f - dampingRatio * dampingRatio)
|
|
47
|
+
private val endValue = rawSpring(1f)
|
|
39
48
|
|
|
40
|
-
|
|
41
|
-
if (input >= 1f) {
|
|
42
|
-
return 1f
|
|
43
|
-
}
|
|
49
|
+
private fun rawSpring(input: Float): Float {
|
|
44
50
|
val decay = exp(-dampingRatio * angularFrequency * input)
|
|
45
51
|
val phase = dampedFrequency * input
|
|
46
52
|
return 1f - decay * (
|
|
47
53
|
cos(phase) + (dampingRatio * angularFrequency / dampedFrequency) * sin(phase)
|
|
48
54
|
)
|
|
49
55
|
}
|
|
56
|
+
|
|
57
|
+
override fun getInterpolation(input: Float): Float {
|
|
58
|
+
if (input <= 0f) {
|
|
59
|
+
return 0f
|
|
60
|
+
}
|
|
61
|
+
if (input >= 1f || endValue == 0f) {
|
|
62
|
+
return 1f
|
|
63
|
+
}
|
|
64
|
+
return rawSpring(input) / endValue
|
|
65
|
+
}
|
|
50
66
|
}
|
package/docs/SPEC.md
CHANGED
|
@@ -44,9 +44,13 @@ and SF Symbols retain their existing resolution. The shared resolver is used for
|
|
|
44
44
|
focused/unfocused icons and the iOS side-accessory icon.
|
|
45
45
|
|
|
46
46
|
The default `getIcon` resolver has a stable identity. With the same routes array
|
|
47
|
-
and resolver, iOS
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
and resolver, both iOS and Android retain normal (`icons`) and selected
|
|
48
|
+
(`selectedIcons`) icon-source arrays across tab selection and unrelated renders,
|
|
49
|
+
and `items` does not recompute solely because `selectedPage` changes. Replacing
|
|
50
|
+
the routes array or supplying a new resolver recomputes both arrays. On Android,
|
|
51
|
+
`BottomTabsView` pre-loads both `icons` and `selectedIcons` into `drawableCache`
|
|
52
|
+
and swaps each `MenuItem`'s icon synchronously on the UI thread when selection
|
|
53
|
+
changes.
|
|
50
54
|
|
|
51
55
|
## Native left drawer
|
|
52
56
|
|
|
@@ -311,9 +315,17 @@ Floating interaction (single finger; motion splitting is disabled):
|
|
|
311
315
|
Release after a drag selects the candidate once, only if it differs from the
|
|
312
316
|
current tab. Cancel selects nothing.
|
|
313
317
|
4. The lens then settles back into the pill on the selected tab, which stays on
|
|
314
|
-
the old tab for cancelled or `preventsDefault` presses.
|
|
315
|
-
|
|
316
|
-
|
|
318
|
+
the old tab for cancelled or `preventsDefault` presses. When a stationary tap
|
|
319
|
+
releases while the indicator slide is still in flight, the lifted lens holds
|
|
320
|
+
briefly (proportional to the remaining slide fraction) before settling into
|
|
321
|
+
the resting pill as it arrives at the target tab.
|
|
322
|
+
|
|
323
|
+
Both press-initiated and JS-driven selection changes slide the pill with a
|
|
324
|
+
520 ms underdamped spring (`dampingRatio = 0.82`, `angularFrequency = 7.5`) and
|
|
325
|
+
frame-rate-normalized velocity stretch (16 ms reference step). An in-flight
|
|
326
|
+
slide animator already targeting the selected tab's X position is preserved
|
|
327
|
+
across touch release and subsequent JS `selectedPage` or `items` syncs instead
|
|
328
|
+
of being restarted or snapped.
|
|
317
329
|
When `tabBarHidden` changes dynamically while attached and laid out in `floating`
|
|
318
330
|
style, `BottomTabsView` animates `floatingBar.translationY` across its visible
|
|
319
331
|
bottom clearance (`DecelerateInterpolator`), preserving in-flight translation on
|
package/lib/module/BottomTabs.js
CHANGED
|
@@ -76,6 +76,42 @@ export const resolveTabIconSource = icon => {
|
|
|
76
76
|
scale: resolved?.scale ?? 1
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
|
+
const defaultGetBadge = ({
|
|
80
|
+
route
|
|
81
|
+
}) => route.badge;
|
|
82
|
+
const defaultGetBadgeBackgroundColor = ({
|
|
83
|
+
route
|
|
84
|
+
}) => route.badgeBackgroundColor;
|
|
85
|
+
const defaultGetBadgeTextColor = ({
|
|
86
|
+
route
|
|
87
|
+
}) => route.badgeTextColor;
|
|
88
|
+
const defaultGetLazy = ({
|
|
89
|
+
route
|
|
90
|
+
}) => route.lazy;
|
|
91
|
+
const defaultGetLabelText = ({
|
|
92
|
+
route
|
|
93
|
+
}) => route.title;
|
|
94
|
+
const defaultGetHidden = ({
|
|
95
|
+
route
|
|
96
|
+
}) => route.hidden;
|
|
97
|
+
const defaultGetActiveTintColor = ({
|
|
98
|
+
route
|
|
99
|
+
}) => route.activeTintColor;
|
|
100
|
+
const defaultGetTestID = ({
|
|
101
|
+
route
|
|
102
|
+
}) => route.testID;
|
|
103
|
+
const defaultGetRole = ({
|
|
104
|
+
route
|
|
105
|
+
}) => route.role;
|
|
106
|
+
const defaultGetSceneStyle = ({
|
|
107
|
+
route
|
|
108
|
+
}) => route.style;
|
|
109
|
+
const defaultGetPreventsDefault = ({
|
|
110
|
+
route
|
|
111
|
+
}) => route.preventsDefault;
|
|
112
|
+
const defaultGetFreezeOnBlur = ({
|
|
113
|
+
route
|
|
114
|
+
}) => route.freezeOnBlur;
|
|
79
115
|
const defaultGetIcon = ({
|
|
80
116
|
route,
|
|
81
117
|
focused
|
|
@@ -94,45 +130,21 @@ const BottomTabs = ({
|
|
|
94
130
|
rippleColor,
|
|
95
131
|
tabBarActiveTintColor: activeTintColor,
|
|
96
132
|
tabBarInactiveTintColor: inactiveTintColor,
|
|
97
|
-
getBadge =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}) => route.badgeBackgroundColor,
|
|
103
|
-
getBadgeTextColor = ({
|
|
104
|
-
route
|
|
105
|
-
}) => route.badgeTextColor,
|
|
106
|
-
getLazy = ({
|
|
107
|
-
route
|
|
108
|
-
}) => route.lazy,
|
|
109
|
-
getLabelText = ({
|
|
110
|
-
route
|
|
111
|
-
}) => route.title,
|
|
133
|
+
getBadge = defaultGetBadge,
|
|
134
|
+
getBadgeBackgroundColor = defaultGetBadgeBackgroundColor,
|
|
135
|
+
getBadgeTextColor = defaultGetBadgeTextColor,
|
|
136
|
+
getLazy = defaultGetLazy,
|
|
137
|
+
getLabelText = defaultGetLabelText,
|
|
112
138
|
getIcon = defaultGetIcon,
|
|
113
|
-
getHidden =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
getTestID = ({
|
|
120
|
-
route
|
|
121
|
-
}) => route.testID,
|
|
122
|
-
getRole = ({
|
|
123
|
-
route
|
|
124
|
-
}) => route.role,
|
|
125
|
-
getSceneStyle = ({
|
|
126
|
-
route
|
|
127
|
-
}) => route.style,
|
|
128
|
-
getPreventsDefault = ({
|
|
129
|
-
route
|
|
130
|
-
}) => route.preventsDefault,
|
|
139
|
+
getHidden = defaultGetHidden,
|
|
140
|
+
getActiveTintColor = defaultGetActiveTintColor,
|
|
141
|
+
getTestID = defaultGetTestID,
|
|
142
|
+
getRole = defaultGetRole,
|
|
143
|
+
getSceneStyle = defaultGetSceneStyle,
|
|
144
|
+
getPreventsDefault = defaultGetPreventsDefault,
|
|
131
145
|
hapticFeedbackEnabled = false,
|
|
132
146
|
labeled = Platform.OS !== "android" ? true : undefined,
|
|
133
|
-
getFreezeOnBlur =
|
|
134
|
-
route
|
|
135
|
-
}) => route.freezeOnBlur,
|
|
147
|
+
getFreezeOnBlur = defaultGetFreezeOnBlur,
|
|
136
148
|
tabBar: renderCustomTabBar,
|
|
137
149
|
tabBarStyle,
|
|
138
150
|
tabLabelStyle,
|
|
@@ -178,24 +190,16 @@ const BottomTabs = ({
|
|
|
178
190
|
route,
|
|
179
191
|
focused: false
|
|
180
192
|
})), [getIcon, trimmedRoutes]);
|
|
181
|
-
// Focused (solid) icons — also stable; handed to
|
|
193
|
+
// Focused (solid) icons — also stable; handed to native as selectedIcons so
|
|
194
|
+
// both iOS and Android swap focused artwork synchronously on the UI thread
|
|
195
|
+
// without waiting for a JS round-trip.
|
|
182
196
|
const focusedIcons = React.useMemo(() => trimmedRoutes.map(route => getIcon({
|
|
183
197
|
route,
|
|
184
198
|
focused: true
|
|
185
199
|
})), [getIcon, trimmedRoutes]);
|
|
186
|
-
|
|
187
|
-
// JS (it has no selectedImage equivalent).
|
|
188
|
-
const focusKeyedIcons = React.useMemo(() => trimmedRoutes.map(route => getIcon({
|
|
189
|
-
route,
|
|
190
|
-
focused: route.key === focusedKey
|
|
191
|
-
})), [focusedKey, getIcon, trimmedRoutes]);
|
|
192
|
-
|
|
193
|
-
// iOS hands both states to UIKit (image + selectedImage) so the focused
|
|
194
|
-
// artwork swaps natively, in sync with the selection animation, instead of
|
|
195
|
-
// waiting for a JS round-trip. Android keeps the focusedKey-driven array.
|
|
196
|
-
const icons = isIOS ? unfocusedIcons : focusKeyedIcons;
|
|
200
|
+
const icons = unfocusedIcons;
|
|
197
201
|
const items = React.useMemo(() => trimmedRoutes.map((route, index) => {
|
|
198
|
-
const icon =
|
|
202
|
+
const icon = unfocusedIcons[index];
|
|
199
203
|
const isSfSymbol = isAppleSymbol(icon);
|
|
200
204
|
if (Platform.OS === "android" && isSfSymbol) {
|
|
201
205
|
console.warn("SF Symbols are not supported on Android. Use require() or pass uri to load an image instead.");
|
|
@@ -234,11 +238,8 @@ const BottomTabs = ({
|
|
|
234
238
|
route
|
|
235
239
|
})
|
|
236
240
|
};
|
|
237
|
-
}), [trimmedRoutes,
|
|
241
|
+
}), [trimmedRoutes, unfocusedIcons, getLabelText, getBadge, getBadgeBackgroundColor, getBadgeTextColor, getActiveTintColor, getHidden, getTestID, getRole, getPreventsDefault]);
|
|
238
242
|
const resolvedIconAssets = React.useMemo(() => icons.map(icon => resolveTabIconSource(icon)), [icons]);
|
|
239
|
-
|
|
240
|
-
// Focused (solid) assets passed to iOS as selectedImage. iOS only — Android
|
|
241
|
-
// ignores selectedIcons and keeps swapping via the focusedKey array above.
|
|
242
243
|
const resolvedSelectedIconAssets = React.useMemo(() => focusedIcons.map(icon => resolveTabIconSource(icon)), [focusedIcons]);
|
|
243
244
|
const jumpTo = useLatestCallback(key => {
|
|
244
245
|
const index = trimmedRoutes.findIndex(route => route.key === key);
|
|
@@ -327,7 +328,7 @@ const BottomTabs = ({
|
|
|
327
328
|
style: styles.fullWidth,
|
|
328
329
|
items: items,
|
|
329
330
|
icons: renderCustomTabBar ? undefined : resolvedIconAssets,
|
|
330
|
-
selectedIcons:
|
|
331
|
+
selectedIcons: !renderCustomTabBar ? resolvedSelectedIconAssets : undefined,
|
|
331
332
|
selectedPage: focusedKey,
|
|
332
333
|
tabBarHidden: props.tabBarHidden ?? !!renderCustomTabBar,
|
|
333
334
|
onTabDoublePress: handleTabDoublePress,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-bottom-tabs",
|
|
3
|
-
"version": "6.7.0-
|
|
3
|
+
"version": "6.7.0-41",
|
|
4
4
|
"description": "Native bottom tabs (tab bar + scene container) for React Native on iOS and Android",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/module/index.js",
|
package/src/BottomTabs.tsx
CHANGED
|
@@ -335,6 +335,24 @@ interface Props<Route extends BaseRoute> {
|
|
|
335
335
|
onSideAccessoryPress?: () => void;
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
+
const defaultGetBadge = ({ route }: { route: BaseRoute }) => route.badge;
|
|
339
|
+
const defaultGetBadgeBackgroundColor = ({ route }: { route: BaseRoute }) =>
|
|
340
|
+
route.badgeBackgroundColor;
|
|
341
|
+
const defaultGetBadgeTextColor = ({ route }: { route: BaseRoute }) =>
|
|
342
|
+
route.badgeTextColor;
|
|
343
|
+
const defaultGetLazy = ({ route }: { route: BaseRoute }) => route.lazy;
|
|
344
|
+
const defaultGetLabelText = ({ route }: { route: BaseRoute }) => route.title;
|
|
345
|
+
const defaultGetHidden = ({ route }: { route: BaseRoute }) => route.hidden;
|
|
346
|
+
const defaultGetActiveTintColor = ({ route }: { route: BaseRoute }) =>
|
|
347
|
+
route.activeTintColor;
|
|
348
|
+
const defaultGetTestID = ({ route }: { route: BaseRoute }) => route.testID;
|
|
349
|
+
const defaultGetRole = ({ route }: { route: BaseRoute }) => route.role;
|
|
350
|
+
const defaultGetSceneStyle = ({ route }: { route: BaseRoute }) => route.style;
|
|
351
|
+
const defaultGetPreventsDefault = ({ route }: { route: BaseRoute }) =>
|
|
352
|
+
route.preventsDefault;
|
|
353
|
+
const defaultGetFreezeOnBlur = ({ route }: { route: BaseRoute }) =>
|
|
354
|
+
route.freezeOnBlur;
|
|
355
|
+
|
|
338
356
|
const defaultGetIcon = ({
|
|
339
357
|
route,
|
|
340
358
|
focused,
|
|
@@ -363,22 +381,21 @@ const BottomTabs = <Route extends BaseRoute>({
|
|
|
363
381
|
rippleColor,
|
|
364
382
|
tabBarActiveTintColor: activeTintColor,
|
|
365
383
|
tabBarInactiveTintColor: inactiveTintColor,
|
|
366
|
-
getBadge =
|
|
367
|
-
getBadgeBackgroundColor =
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
getLabelText = ({ route }: { route: Route }) => route.title,
|
|
384
|
+
getBadge = defaultGetBadge,
|
|
385
|
+
getBadgeBackgroundColor = defaultGetBadgeBackgroundColor,
|
|
386
|
+
getBadgeTextColor = defaultGetBadgeTextColor,
|
|
387
|
+
getLazy = defaultGetLazy,
|
|
388
|
+
getLabelText = defaultGetLabelText,
|
|
372
389
|
getIcon = defaultGetIcon,
|
|
373
|
-
getHidden =
|
|
374
|
-
getActiveTintColor =
|
|
375
|
-
getTestID =
|
|
376
|
-
getRole =
|
|
377
|
-
getSceneStyle =
|
|
378
|
-
getPreventsDefault =
|
|
390
|
+
getHidden = defaultGetHidden,
|
|
391
|
+
getActiveTintColor = defaultGetActiveTintColor,
|
|
392
|
+
getTestID = defaultGetTestID,
|
|
393
|
+
getRole = defaultGetRole,
|
|
394
|
+
getSceneStyle = defaultGetSceneStyle,
|
|
395
|
+
getPreventsDefault = defaultGetPreventsDefault,
|
|
379
396
|
hapticFeedbackEnabled = false,
|
|
380
397
|
labeled = Platform.OS !== "android" ? true : undefined,
|
|
381
|
-
getFreezeOnBlur =
|
|
398
|
+
getFreezeOnBlur = defaultGetFreezeOnBlur,
|
|
382
399
|
tabBar: renderCustomTabBar,
|
|
383
400
|
tabBarStyle,
|
|
384
401
|
tabLabelStyle,
|
|
@@ -441,33 +458,20 @@ const BottomTabs = <Route extends BaseRoute>({
|
|
|
441
458
|
() => trimmedRoutes.map((route) => getIcon({ route, focused: false })),
|
|
442
459
|
[getIcon, trimmedRoutes]
|
|
443
460
|
);
|
|
444
|
-
// Focused (solid) icons — also stable; handed to
|
|
461
|
+
// Focused (solid) icons — also stable; handed to native as selectedIcons so
|
|
462
|
+
// both iOS and Android swap focused artwork synchronously on the UI thread
|
|
463
|
+
// without waiting for a JS round-trip.
|
|
445
464
|
const focusedIcons = React.useMemo(
|
|
446
465
|
() => trimmedRoutes.map((route) => getIcon({ route, focused: true })),
|
|
447
466
|
[getIcon, trimmedRoutes]
|
|
448
467
|
);
|
|
449
|
-
// Legacy single array driven by focusedKey. Android still swaps the icon in
|
|
450
|
-
// JS (it has no selectedImage equivalent).
|
|
451
|
-
const focusKeyedIcons = React.useMemo(
|
|
452
|
-
() =>
|
|
453
|
-
trimmedRoutes.map((route) =>
|
|
454
|
-
getIcon({
|
|
455
|
-
route,
|
|
456
|
-
focused: route.key === focusedKey,
|
|
457
|
-
})
|
|
458
|
-
),
|
|
459
|
-
[focusedKey, getIcon, trimmedRoutes]
|
|
460
|
-
);
|
|
461
468
|
|
|
462
|
-
|
|
463
|
-
// artwork swaps natively, in sync with the selection animation, instead of
|
|
464
|
-
// waiting for a JS round-trip. Android keeps the focusedKey-driven array.
|
|
465
|
-
const icons = isIOS ? unfocusedIcons : focusKeyedIcons;
|
|
469
|
+
const icons = unfocusedIcons;
|
|
466
470
|
|
|
467
471
|
const items: BottomTabsItems[number][] = React.useMemo(
|
|
468
472
|
() =>
|
|
469
473
|
trimmedRoutes.map((route, index) => {
|
|
470
|
-
const icon =
|
|
474
|
+
const icon = unfocusedIcons[index];
|
|
471
475
|
const isSfSymbol = isAppleSymbol(icon);
|
|
472
476
|
|
|
473
477
|
if (Platform.OS === "android" && isSfSymbol) {
|
|
@@ -498,7 +502,7 @@ const BottomTabs = <Route extends BaseRoute>({
|
|
|
498
502
|
}),
|
|
499
503
|
[
|
|
500
504
|
trimmedRoutes,
|
|
501
|
-
|
|
505
|
+
unfocusedIcons,
|
|
502
506
|
getLabelText,
|
|
503
507
|
getBadge,
|
|
504
508
|
getBadgeBackgroundColor,
|
|
@@ -516,8 +520,6 @@ const BottomTabs = <Route extends BaseRoute>({
|
|
|
516
520
|
[icons]
|
|
517
521
|
);
|
|
518
522
|
|
|
519
|
-
// Focused (solid) assets passed to iOS as selectedImage. iOS only — Android
|
|
520
|
-
// ignores selectedIcons and keeps swapping via the focusedKey array above.
|
|
521
523
|
const resolvedSelectedIconAssets = React.useMemo(
|
|
522
524
|
() => focusedIcons.map((icon) => resolveTabIconSource(icon)),
|
|
523
525
|
[focusedIcons]
|
|
@@ -628,9 +630,7 @@ const BottomTabs = <Route extends BaseRoute>({
|
|
|
628
630
|
items={items}
|
|
629
631
|
icons={renderCustomTabBar ? undefined : resolvedIconAssets}
|
|
630
632
|
selectedIcons={
|
|
631
|
-
|
|
632
|
-
? resolvedSelectedIconAssets
|
|
633
|
-
: undefined
|
|
633
|
+
!renderCustomTabBar ? resolvedSelectedIconAssets : undefined
|
|
634
634
|
}
|
|
635
635
|
selectedPage={focusedKey}
|
|
636
636
|
tabBarHidden={props.tabBarHidden ?? !!renderCustomTabBar}
|