130 lines
5.9 KiB
Diff
130 lines
5.9 KiB
Diff
diff --git a/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/appearance/TabsAppearanceApplicator.kt b/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/appearance/TabsAppearanceApplicator.kt
|
|
index cbe9b978ced6972a51bc5235b47a58dd55836351..b7063502332a7d1da5cb58ea8738670a9d3f5e87 100644
|
|
--- a/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/appearance/TabsAppearanceApplicator.kt
|
|
+++ b/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/appearance/TabsAppearanceApplicator.kt
|
|
@@ -186,16 +186,24 @@ internal class TabsAppearanceApplicator(
|
|
val rippleColor =
|
|
tabBarAppearance?.tabBarItemRippleColor
|
|
?: resolveColorAttr(context, R.attr.itemRippleColor)
|
|
- bottomNavigationView.itemRippleColor = ColorStateList.valueOf(rippleColor)
|
|
+ // Material recreates the ripple drawable on these setters, even when
|
|
+ // values are unchanged. Preserve an in-flight press across tab updates.
|
|
+ if (bottomNavigationView.itemRippleColor?.defaultColor != rippleColor) {
|
|
+ bottomNavigationView.itemRippleColor = ColorStateList.valueOf(rippleColor)
|
|
+ }
|
|
|
|
// Active Indicator
|
|
val activeIndicatorColor =
|
|
tabBarAppearance?.tabBarItemActiveIndicatorColor
|
|
?: resolveColorAttr(context, R.attr.colorSecondaryContainer)
|
|
|
|
- bottomNavigationView.isItemActiveIndicatorEnabled =
|
|
- tabBarAppearance?.tabBarItemActiveIndicatorEnabled ?: true
|
|
- bottomNavigationView.itemActiveIndicatorColor = ColorStateList.valueOf(activeIndicatorColor)
|
|
+ val activeIndicatorEnabled = tabBarAppearance?.tabBarItemActiveIndicatorEnabled ?: true
|
|
+ if (bottomNavigationView.isItemActiveIndicatorEnabled != activeIndicatorEnabled) {
|
|
+ bottomNavigationView.isItemActiveIndicatorEnabled = activeIndicatorEnabled
|
|
+ }
|
|
+ if (bottomNavigationView.itemActiveIndicatorColor?.defaultColor != activeIndicatorColor) {
|
|
+ bottomNavigationView.itemActiveIndicatorColor = ColorStateList.valueOf(activeIndicatorColor)
|
|
+ }
|
|
}
|
|
|
|
fun updateFontStyles(
|
|
diff --git a/ios/tabs/host/RNSTabBarController.mm b/ios/tabs/host/RNSTabBarController.mm
|
|
--- a/ios/tabs/host/RNSTabBarController.mm
|
|
+++ b/ios/tabs/host/RNSTabBarController.mm
|
|
@@ -354,6 +354,8 @@
|
|
[self updateTabBarA11yIfNeeded];
|
|
[self updateProminentIdentifierIfNeeded];
|
|
[self updateOrientationIfNeeded];
|
|
+ // Allow app-owned sidebar groups to be restored after router tab reconciliation.
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"oTunesTabsDidUpdate" object:self];
|
|
}
|
|
|
|
/**
|
|
@@ -415,8 +417,9 @@
|
|
- (void)userDidSelectViewController:(nonnull UIViewController *)viewController
|
|
{
|
|
// At this moment the `UITabBarController` model is already updated.
|
|
- RCTAssert(self.selectedViewController == viewController,
|
|
- @"[RNScreens] Expected UIKit to update selectedViewController");
|
|
+ // A tab group exposes its root controller here, while selectedTab is the selected leaf.
|
|
+ RCTAssert([self effectiveSelectedViewController] == viewController,
|
|
+ @"[RNScreens] Expected UIKit to update the effective selection");
|
|
|
|
if (![self usesUITabAPI] && [self isSelectedViewControllerTheMoreNavigationController]) {
|
|
[self disableNavigationBarInMoreNavigationController];
|
|
@@ -465,7 +468,7 @@
|
|
BOOL repeatedSelection = viewController == self.selectedViewController;
|
|
#if RNS_UITAB_API_SDK_AVAILABLE
|
|
if (RNS_UITAB_API_ENABLED) {
|
|
- repeatedSelection = viewController.tab == self.selectedTab && ![self isMoreNavigationControllerTabBarItemSelected];
|
|
+ repeatedSelection = viewController.tab == [self leafTab:self.selectedTab] && ![self isMoreNavigationControllerTabBarItemSelected];
|
|
}
|
|
#endif // RNS_UITAB_API_SDK_AVAILABLE
|
|
|
|
@@ -546,9 +549,34 @@
|
|
|
|
#pragma mark UITabBarControllerDelegate (UITab API)
|
|
|
|
+// Sidebar groups are containers. Navigation state and React events use their leaf screens.
|
|
+- (UITab *)leafTab:(UITab *)tab API_AVAILABLE(ios(18.0))
|
|
+{
|
|
+ while ([tab isKindOfClass:UITabGroup.class]) {
|
|
+ UITabGroup *group = (UITabGroup *)tab;
|
|
+ UITab *child = group.selectedChild ?: group.children.firstObject;
|
|
+ if (child == nil) {
|
|
+ break;
|
|
+ }
|
|
+ tab = child;
|
|
+ }
|
|
+ return tab;
|
|
+}
|
|
+
|
|
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectTab:(UITab *)tab API_AVAILABLE(ios(18.0))
|
|
{
|
|
- return [self tabBarController:tabBarController shouldSelectViewController:tab.viewController];
|
|
+ UITab *leaf = [self leafTab:tab];
|
|
+ if (![self tabBarController:tabBarController shouldSelectViewController:leaf.viewController]) {
|
|
+ return NO;
|
|
+ }
|
|
+ if (leaf != tab) {
|
|
+ // A group button in a compact bar must open its screen, not its placeholder.
|
|
+ [self applySelectedScreenController:(RNSTabsScreenViewController *)leaf.viewController];
|
|
+ [self userDidSelectViewController:leaf.viewController];
|
|
+ _isHandlingExplicitSelectionUpdate = NO;
|
|
+ return NO;
|
|
+ }
|
|
+ return YES;
|
|
}
|
|
|
|
- (void)tabBarController:(UITabBarController *)tabBarController
|
|
@@ -560,7 +588,7 @@
|
|
}
|
|
|
|
RCTAssert(self.selectedTab == selectedTab, @"[RNScreens] Expected UIKit to update selectedTab");
|
|
- [self tabBarController:tabBarController didSelectViewController:selectedTab.viewController];
|
|
+ [self tabBarController:tabBarController didSelectViewController:[self leafTab:selectedTab].viewController];
|
|
}
|
|
|
|
#endif // RNS_UITAB_API_SDK_AVAILABLE
|
|
@@ -675,7 +703,7 @@
|
|
|
|
#if RNS_UITAB_API_SDK_AVAILABLE
|
|
if (RNS_UITAB_API_ENABLED) {
|
|
- return screenController == self.selectedTab.viewController;
|
|
+ return screenController == [self leafTab:self.selectedTab].viewController;
|
|
}
|
|
#endif // RNS_UITAB_API_SDK_AVAILABLE
|
|
return screenController == self.selectedViewController;
|
|
@@ -696,7 +724,7 @@
|
|
|
|
#if RNS_UITAB_API_SDK_AVAILABLE
|
|
if (RNS_UITAB_API_ENABLED) {
|
|
- return self.selectedTab.viewController;
|
|
+ return [self leafTab:self.selectedTab].viewController;
|
|
}
|
|
#endif // RNS_UITAB_API_SDK_AVAILABLE
|
|
return self.selectedViewController;
|