fix(mobile): handle Duo tab groups and sidebar placement
This commit is contained in:
5 files changed
+119
-24
No files matched your search
@@ -54,10 +54,11 @@ and player spacing updates as the window folds or resizes.
|
||||
`native/TabletSidebar.swift` adds UIKit Library and Playlists groups and the pinned
|
||||
account footer, which the current Expo Router API does not expose. The bridge
|
||||
reuses the router's tab instances so each destination retains its navigation stack.
|
||||
On Duo, hiding the sidebar restores the native tab rail.
|
||||
|
||||
The `react-native-screens` patch checks the selected leaf controller rather than
|
||||
the group's root controller. It also notifies the sidebar bridge after each native
|
||||
tab reconciliation, so startup updates cannot replace the Library and Playlists
|
||||
sections with a flat tab list. Keep both behaviors when updating the dependency.
|
||||
The `react-native-screens` patch resolves groups to their selected leaf controller
|
||||
for tab selection and routes compact group buttons directly to that screen. It
|
||||
also notifies the sidebar bridge after each native tab reconciliation, so startup updates cannot replace the Library and Playlists
|
||||
sections with a flat tab list. Keep these behaviors when updating the dependency.
|
||||
After changing native modules or dependency patches, run `pod install` in `ios`
|
||||
and rebuild the development app.
|
||||
@@ -34,16 +34,14 @@ export function TabletMiniPlayer() {
|
||||
const { width } = useWindowDimensions()
|
||||
const left = useSharedValue(insets.left)
|
||||
const right = useSharedValue(insets.right)
|
||||
const bottom = useSharedValue(insets.bottom)
|
||||
useEffect(() => {
|
||||
left.value = withTiming(insets.left, tabletMotion)
|
||||
right.value = withTiming(insets.right, tabletMotion)
|
||||
bottom.value = withTiming(insets.bottom, tabletMotion)
|
||||
}, [insets.left, insets.right, insets.bottom, left, right, bottom])
|
||||
}, [insets.left, insets.right, left, right])
|
||||
const positionStyle = useAnimatedStyle(() => ({
|
||||
left: left.value + 16,
|
||||
right: right.value + 16,
|
||||
bottom: bottom.value + 8,
|
||||
bottom: 16,
|
||||
}))
|
||||
const { config } = useServerConfig()
|
||||
const {
|
||||
|
||||
@@ -86,6 +86,7 @@ final class TabletSidebarView: ExpoView {
|
||||
|
||||
@available(iOS 18.0, *)
|
||||
private func configure(_ controller: UITabBarController) {
|
||||
controller.sidebar.delegate = self
|
||||
configureGroups(controller)
|
||||
|
||||
let footer: SidebarAccountButton
|
||||
@@ -95,6 +96,13 @@ final class TabletSidebarView: ExpoView {
|
||||
footer = SidebarAccountButton()
|
||||
controller.sidebar.bottomBarView = footer
|
||||
}
|
||||
if #available(iOS 27.0, *), UIDevice.current.userInterfaceIdiom != .pad,
|
||||
!footer.didConfigurePlacement, controller.view.bounds.width >= 600,
|
||||
controller.view.bounds.height >= 600 {
|
||||
footer.didConfigurePlacement = true
|
||||
controller.sidebar.preferredPlacement = .sidebar
|
||||
controller.sidebar.isHidden = false
|
||||
}
|
||||
configureTabBar(controller, footer: footer)
|
||||
footer.update(name: accountName, initials: initials, imageURL: imageURL)
|
||||
footer.onPress = { [weak self] in self?.onProfilePress() }
|
||||
@@ -129,10 +137,10 @@ final class TabletSidebarView: ExpoView {
|
||||
guard library.count == 5, playlists.count == 2,
|
||||
let home = tab("home"), let search = tab("search") else { return }
|
||||
let libraryGroup = UITabGroup(
|
||||
title: "Library", image: nil, identifier: "otunes.library", children: library,
|
||||
title: "Library", image: UIImage(systemName: "music.note.square.stack"), identifier: "otunes.library", children: library,
|
||||
viewControllerProvider: { _ in UIViewController() })
|
||||
let playlistGroup = UITabGroup(
|
||||
title: "Playlists", image: nil, identifier: "otunes.playlists", children: playlists,
|
||||
title: "Playlists", image: UIImage(systemName: "music.note.list"), identifier: "otunes.playlists", children: playlists,
|
||||
viewControllerProvider: { _ in UIViewController() })
|
||||
// UIKit requires a managing controller to display the selected child of a group.
|
||||
let libraryNavigation = UINavigationController()
|
||||
@@ -164,6 +172,7 @@ final class TabletSidebarView: ExpoView {
|
||||
private final class SidebarAccountButton: UIView {
|
||||
var onPress: (() -> Void)?
|
||||
var contextualTab: UITab?
|
||||
var didConfigurePlacement = false
|
||||
private let button = UIButton(type: .system)
|
||||
private let avatar = UILabel()
|
||||
private let imageView = UIImageView()
|
||||
@@ -244,3 +253,19 @@ private final class SidebarAccountButton: UIView {
|
||||
|
||||
deinit { imageTask?.cancel() }
|
||||
}
|
||||
|
||||
@available(iOS 18.0, *)
|
||||
extension TabletSidebarView: UITabBarController.Sidebar.Delegate {
|
||||
func tabBarController(
|
||||
_ tabBarController: UITabBarController,
|
||||
sidebarVisibilityWillChange sidebar: UITabBarController.Sidebar,
|
||||
animator: any UITabBarController.Sidebar.Animating
|
||||
) {
|
||||
// Duo can display only one placement. Hiding its sidebar must restore the rail tabs.
|
||||
if #available(iOS 27.0, *), UIDevice.current.userInterfaceIdiom != .pad {
|
||||
DispatchQueue.main.async {
|
||||
sidebar.preferredPlacement = sidebar.isHidden ? .tabBar : .sidebar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,10 +32,9 @@ index cbe9b978ced6972a51bc5235b47a58dd55836351..b7063502332a7d1da5cb58ea8738670a
|
||||
|
||||
fun updateFontStyles(
|
||||
diff --git a/ios/tabs/host/RNSTabBarController.mm b/ios/tabs/host/RNSTabBarController.mm
|
||||
index bc9c64436da76959ecdc22539b94ce459e1e4ed2..8fb814a2a8f9b669419d59620e8082c2e01943fa 100644
|
||||
--- a/ios/tabs/host/RNSTabBarController.mm
|
||||
+++ b/ios/tabs/host/RNSTabBarController.mm
|
||||
@@ -354,6 +354,8 @@ static void rns_pushViewController(__unsafe_unretained id self,
|
||||
@@ -354,6 +354,8 @@
|
||||
[self updateTabBarA11yIfNeeded];
|
||||
[self updateProminentIdentifierIfNeeded];
|
||||
[self updateOrientationIfNeeded];
|
||||
@@ -44,7 +43,7 @@ index bc9c64436da76959ecdc22539b94ce459e1e4ed2..8fb814a2a8f9b669419d59620e8082c2
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -415,8 +417,9 @@ static void rns_pushViewController(__unsafe_unretained id self,
|
||||
@@ -415,8 +417,9 @@
|
||||
- (void)userDidSelectViewController:(nonnull UIViewController *)viewController
|
||||
{
|
||||
// At this moment the `UITabBarController` model is already updated.
|
||||
@@ -56,3 +55,75 @@ index bc9c64436da76959ecdc22539b94ce459e1e4ed2..8fb814a2a8f9b669419d59620e8082c2
|
||||
|
||||
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;
|
||||
Generated
+11
-11
@@ -9,7 +9,7 @@ patchedDependencies:
|
||||
hash: f7f102c0f17b28e763d828acd4f138d62809f5be576e316a13008c27e84968c5
|
||||
path: patches/expo-audio@58.0.10.patch
|
||||
react-native-screens@4.30.1:
|
||||
hash: f79520899c22be4c5109cdeacfecb373c9116181b7be338d898899bfcf0b262d
|
||||
hash: 9e31d150b1e6df3ab6835b7fa40fc5f3bde953cd32a018dab87f67a7ef3971d2
|
||||
path: patches/react-native-screens@4.30.1.patch
|
||||
|
||||
importers:
|
||||
@@ -102,7 +102,7 @@ importers:
|
||||
version: 58.0.4(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
expo-router:
|
||||
specifier: ~58.0.30
|
||||
version: 58.0.30(f3ddf1c95c8fa7fe835ab499afea9491)
|
||||
version: 58.0.30(4ef2ae6de61a15fdec068e31bb3c9eca)
|
||||
expo-secure-store:
|
||||
specifier: ~58.0.2
|
||||
version: 58.0.2(expo@58.0.17)
|
||||
@@ -144,7 +144,7 @@ importers:
|
||||
version: 5.10.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-screens:
|
||||
specifier: 4.30.1
|
||||
version: 4.30.1(patch_hash=f79520899c22be4c5109cdeacfecb373c9116181b7be338d898899bfcf0b262d)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
version: 4.30.1(patch_hash=9e31d150b1e6df3ab6835b7fa40fc5f3bde953cd32a018dab87f67a7ef3971d2)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-svg:
|
||||
specifier: 15.16.0
|
||||
version: 15.16.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
@@ -153,7 +153,7 @@ importers:
|
||||
version: 0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
sonner-native:
|
||||
specifier: ^0.26.2
|
||||
version: 0.26.4(841efd1f6d09cbc17c64b5b7dc139c3b)
|
||||
version: 0.26.4(1b3adc93fa0cee9285f393fbd14491f4)
|
||||
devDependencies:
|
||||
'@types/node':
|
||||
specifier: ^20
|
||||
@@ -7563,7 +7563,7 @@ snapshots:
|
||||
ws: 8.21.0
|
||||
zod: 3.25.76
|
||||
optionalDependencies:
|
||||
expo-router: 58.0.30(f3ddf1c95c8fa7fe835ab499afea9491)
|
||||
expo-router: 58.0.30(4ef2ae6de61a15fdec068e31bb3c9eca)
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
transitivePeerDependencies:
|
||||
- '@expo/dom-webview'
|
||||
@@ -7882,7 +7882,7 @@ snapshots:
|
||||
react: 19.3.0
|
||||
optionalDependencies:
|
||||
'@expo/metro-runtime': 58.0.17(@expo/log-box@58.0.15)(expo@58.0.17)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
expo-router: 58.0.30(f3ddf1c95c8fa7fe835ab499afea9491)
|
||||
expo-router: 58.0.30(4ef2ae6de61a15fdec068e31bb3c9eca)
|
||||
react-dom: 19.3.0(react@19.3.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -11287,7 +11287,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
expo-router@58.0.30(f3ddf1c95c8fa7fe835ab499afea9491):
|
||||
expo-router@58.0.30(4ef2ae6de61a15fdec068e31bb3c9eca):
|
||||
dependencies:
|
||||
'@expo/log-box': 58.0.15(@expo/dom-webview@58.0.2)(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
'@expo/metro-runtime': 58.0.17(@expo/log-box@58.0.15)(expo@58.0.17)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
@@ -11310,7 +11310,7 @@ snapshots:
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
react-native-drawer-layout: 4.2.12(react-native-gesture-handler@3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native-reanimated@4.7.1(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-safe-area-context: 5.10.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-screens: 4.30.1(patch_hash=f79520899c22be4c5109cdeacfecb373c9116181b7be338d898899bfcf0b262d)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-screens: 4.30.1(patch_hash=9e31d150b1e6df3ab6835b7fa40fc5f3bde953cd32a018dab87f67a7ef3971d2)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
server-only: 0.0.1
|
||||
sf-symbols-typescript: 2.2.0
|
||||
standard-navigation: 0.0.5
|
||||
@@ -13014,7 +13014,7 @@ snapshots:
|
||||
react: 19.3.0
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
|
||||
react-native-screens@4.30.1(patch_hash=f79520899c22be4c5109cdeacfecb373c9116181b7be338d898899bfcf0b262d)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
|
||||
react-native-screens@4.30.1(patch_hash=9e31d150b1e6df3ab6835b7fa40fc5f3bde953cd32a018dab87f67a7ef3971d2)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
|
||||
dependencies:
|
||||
react: 19.3.0
|
||||
react-freeze: 1.0.4(react@19.3.0)
|
||||
@@ -13563,14 +13563,14 @@ snapshots:
|
||||
|
||||
slugify@1.6.9: {}
|
||||
|
||||
sonner-native@0.26.4(841efd1f6d09cbc17c64b5b7dc139c3b):
|
||||
sonner-native@0.26.4(1b3adc93fa0cee9285f393fbd14491f4):
|
||||
dependencies:
|
||||
react: 19.3.0
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
react-native-gesture-handler: 3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-reanimated: 4.7.1(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-safe-area-context: 5.10.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-screens: 4.30.1(patch_hash=f79520899c22be4c5109cdeacfecb373c9116181b7be338d898899bfcf0b262d)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-screens: 4.30.1(patch_hash=9e31d150b1e6df3ab6835b7fa40fc5f3bde953cd32a018dab87f67a7ef3971d2)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-svg: 15.16.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-worklets: 0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
|
||||
|
||||
Reference in new issue
Block a user