-
Notifications
You must be signed in to change notification settings - Fork 83
feat: add Tab api support on newer OS #364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
okwasniewski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
I've found some issues with current implementation that we need to sort out.
packages/react-native-bottom-tabs/ios/TabView/LegacyTabView.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make TabRole work in the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces support for Apple’s new SwiftUI Tab API on iOS/iPadOS/tvOS 18+, macOS 15+, and visionOS 2+, while maintaining the existing implementation for earlier OS versions.
- Extracted
NewTabViewandLegacyTabViewand toggled between them inTabViewImplbased on platform availability. - Moved tab appearance logic into
TabAppearModifierand unified view signatures under a newAnyTabViewprotocol. - Simplified
TabViewImplby replacing inlinerenderTabItemlogic with atabContentcomputed property.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-bottom-tabs/ios/TabViewImpl.swift | Replaced inline TabView with conditional NewTabView/LegacyTabView and removed renderTabItem. |
| packages/react-native-bottom-tabs/ios/TabView/NewTabView.swift | New SwiftUI 18+ implementation using Tab(value:role:) and custom appearances. |
| packages/react-native-bottom-tabs/ios/TabView/LegacyTabView.swift | Legacy implementation extracted from original code, preserving pre-18 API. |
| packages/react-native-bottom-tabs/ios/TabView/AnyTabView.swift | Introduced protocol to unify new and legacy tab view interfaces. |
| packages/react-native-bottom-tabs/ios/TabAppearModifier.swift | Added modifier to centralize onAppear logic for tab updates. |
Comments suppressed due to low confidence (1)
packages/react-native-bottom-tabs/ios/TabView/NewTabView.swift:13
- There are currently no tests covering
NewTabView’s behavior with the new SwiftUI Tab API. Consider adding unit or snapshot tests for selection, badge display, and role assignment on supported OS versions.
TabView(selection: $props.selectedPage) {
packages/react-native-bottom-tabs/ios/TabView/LegacyTabView.swift
Outdated
Show resolved
Hide resolved
okwasniewski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are getting there! Thanks for applying the fixes.
Sorry for taking so long to review but I got sick last week 🥲
I'm going to merge this PR soon: #378
Can you rebase and implement the badge behavior properly? Afterwards we should be good to merge, also can you run swiftlint --fix ./packages in the root of the repo?
|
no problem, take your time to recover. |
|
Hey @47PADO47 looks like something got messed up during merging 😥 I don't see the changes anymore |
|
@okwasniewski that's strange, i can see them. i'll try to rebase again later |
|
Thank you for working on this! Just those two fixes I found were necessary to make old tab view work as before |
|
i think this pr is ready, let me know if any other changes are required |

PR Description
This pr adds support for the new swift Tab api on ios/ipadOS/tvOS 18+, macOS 15+ and visionOS 2+. This let us implement many new features (such as search role for the tab item, tabbar customization, swipe actions and context menus), while also opening up an opportunity to implement #296 in the future.
In order to implement it i had to create a separate file for each implementation because only by doing so and using
@available(iOS 18, macOS 15, visionOS 2, tvOS 18, *)onNewTabViewi could then add@AppStorage("sidebarCustomizations"). I tried to maintain every feature on each implementation and moved theTabViewImpl#renderTabItemtoLegacyTabView#renderTabItem. i was hoping to add a similar function to the NewTabView struct but in that case the Tab api gave an error about not conforming to View (strange since the same code works directly in the ForEach).As of now i have disabled customization for each Tab (using
.customizationBehavior(.disabled, for: .sidebar, .tabBar)), as we can then discuss in a followup pr/issue the js implementation, set Tab role to nil (same reason), disabled badges on the new tab (commented line) because even iftabData.badgeis an empty string, an empty red dot is created, and i could not figure out how to circumvent this. Finally, i found a strange behaviour with theNative Bottom Tabs with Custom Tab Barexample, where for the new tab implementation, the native tab is still visible, but even there i could not figure out why.Let me know your thoughts and if you have any suggestion on how to resolve these issues
How to test?
Open the app and test the examples
Screenshots
N/A, the look is the same, only a new edit button has appeared in the ipad/macos sidebar