Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/calm-tabs-scroll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-native-bottom-tabs": patch
---

Fix `scrollEdgeAppearance` on iOS 26 and newer.
18 changes: 18 additions & 0 deletions packages/react-native-bottom-tabs/ios/TabViewImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/// SwiftUI implementation of TabView used to render React Native views.
struct TabViewImpl: View {
@ObservedObject var props: TabViewProps
@Environment(\.colorScheme) private var colorScheme
#if os(macOS)
@Weak var tabBar: NSTabView?
#else
Expand Down Expand Up @@ -81,6 +82,9 @@
}
#if !os(macOS)
.configureAppearance(props: props, tabBar: tabBar)
.onChange(of: colorScheme) { _ in
updateTabBarAppearance(props: props, tabBar: tabBar)
}
#endif
.tintColor(props.selectedActiveTintColor)
.getSidebarAdaptable(enabled: props.sidebarAdaptable ?? false)
Expand Down Expand Up @@ -135,7 +139,7 @@
if #available(iOS 18.0, tvOS 18.0, visionOS 2.0, *),
let tabController = tabBar.delegate as? UITabBarController,
let index = tabController.tabs.firstIndex(where: { $0.viewController?.tabBarItem === item })
{

Check warning on line 142 in packages/react-native-bottom-tabs/ios/TabViewImpl.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration (opening_brace)
return index
}
return tabBarIndex
Expand All @@ -146,6 +150,20 @@

tabBar.isHidden = props.tabBarHidden

#if os(iOS)
if #available(iOS 26.0, *) {
let traits = tabBar.window?.traitCollection ?? tabBar.traitCollection
if props.scrollEdgeAppearance == "transparent" {
tabBar.backgroundColor = nil
} else if let barTintColor = props.barTintColor {
tabBar.backgroundColor = barTintColor.resolvedColor(with: traits)
} else {
let isOpaque = props.scrollEdgeAppearance == "opaque" || !props.translucent
tabBar.backgroundColor = isOpaque ? UIColor.systemBackground.resolvedColor(with: traits) : nil
}
}
#endif

if props.scrollEdgeAppearance == "transparent" {
configureTransparentAppearance(tabBar: tabBar, props: props)
return
Expand Down Expand Up @@ -484,7 +502,7 @@
.foregroundColor: color,
.paragraphStyle: paragraphStyle,
]
let titleSize = (title as NSString).size(withAttributes: attributes)

Check warning on line 505 in packages/react-native-bottom-tabs/ios/TabViewImpl.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Legacy Objective-C Reference Type Violation: Prefer Swift value types to bridged Objective-C reference types (legacy_objc_type)
let imageSize = CGSize(
width: max(iconSize.width, ceil(titleSize.width)) + 8,
height: iconSize.height + 3 + ceil(titleSize.height)
Expand All @@ -511,7 +529,7 @@

tintedIcon.draw(in: iconFrame)

(title as NSString).draw(

Check warning on line 532 in packages/react-native-bottom-tabs/ios/TabViewImpl.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Legacy Objective-C Reference Type Violation: Prefer Swift value types to bridged Objective-C reference types (legacy_objc_type)
in: CGRect(
x: 0,
y: iconSize.height + 3,
Expand Down Expand Up @@ -682,4 +700,4 @@
self
}
}
}

Check warning on line 703 in packages/react-native-bottom-tabs/ios/TabViewImpl.swift

View workflow job for this annotation

GitHub Actions / swift-lint

File Length Violation: File should contain 400 lines or less: currently contains 703 (file_length)
Loading