Skip to content

Conversation

@47PADO47
Copy link
Contributor

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, *) on NewTabView i could then add @AppStorage("sidebarCustomizations"). I tried to maintain every feature on each implementation and moved the TabViewImpl#renderTabItem to LegacyTabView#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 if tabData.badge is 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 the Native Bottom Tabs with Custom Tab Bar example, 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

@changeset-bot
Copy link

changeset-bot bot commented Jun 14, 2025

⚠️ No Changeset found

Latest commit: bbcb542

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@okwasniewski okwasniewski requested a review from Copilot June 17, 2025 17:00

This comment was marked as outdated.

Copy link
Member

@okwasniewski okwasniewski left a 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.

Copy link

@hennessyevan hennessyevan left a 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

@okwasniewski okwasniewski requested a review from Copilot July 6, 2025 15:34
Copy link

Copilot AI left a 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 NewTabView and LegacyTabView and toggled between them in TabViewImpl based on platform availability.
  • Moved tab appearance logic into TabAppearModifier and unified view signatures under a new AnyTabView protocol.
  • Simplified TabViewImpl by replacing inline renderTabItem logic with a tabContent computed 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) {

Copy link
Member

@okwasniewski okwasniewski left a 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?

@47PADO47
Copy link
Contributor Author

47PADO47 commented Jul 6, 2025

no problem, take your time to recover.
glad we've been able to tackle the badge problem, i'll rebase and push fixes as soon as i can

@okwasniewski
Copy link
Member

Hey @47PADO47 looks like something got messed up during merging 😥 I don't see the changes anymore

@47PADO47
Copy link
Contributor Author

47PADO47 commented Jul 8, 2025

@okwasniewski that's strange, i can see them. i'll try to rebase again later

image

@okwasniewski
Copy link
Member

Thank you for working on this! Just those two fixes I found were necessary to make old tab view work as before

@47PADO47
Copy link
Contributor Author

i think this pr is ready, let me know if any other changes are required

@okwasniewski okwasniewski added this pull request to the merge queue Jul 13, 2025
Merged via the queue into callstack:main with commit c1a0dd7 Jul 13, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants