Merge pull request #3642 from ericholguin/ios-26-fixes

ui: Fixes for iOS 26 toolbars
This commit is contained in:
Daniel D’Aquino
2026-03-18 17:21:59 -07:00
committed by GitHub
5 changed files with 52 additions and 0 deletions
+2
View File
@@ -254,6 +254,7 @@ struct ContentView: View {
ToolbarItem(placement: .navigationBarLeading) {
TopbarSideMenuButton(damus_state: damus, isSideBarOpened: $isSideBarOpened)
}
.hideToolbarBackground()
ToolbarItem(placement: .navigationBarTrailing) {
HStack(alignment: .center) {
@@ -271,6 +272,7 @@ struct ContentView: View {
}
}
}
.hideToolbarBackground()
}
}
.background(DamusColors.adaptableWhite)
@@ -124,6 +124,8 @@ struct NotificationsView: View {
}
)
}
.hideToolbarBackground()
ToolbarItem(placement: .navigationBarTrailing) {
if showTrustedButton {
TrustedNetworkButton(filter: $filter.friend_filter) {
@@ -133,6 +135,7 @@ struct NotificationsView: View {
}
}
}
.hideToolbarBackground()
}
.onChange(of: filter.friend_filter) { val in
state.settings.friend_filter = val
@@ -503,6 +503,8 @@ struct ProfileView: View {
.padding(.top, max(5, 15 + (yOffset / 30)))
}
}
.hideToolbarBackground()
if showFollowBtnInBlurrBanner() {
ToolbarItem(placement: .topBarTrailing) {
FollowButtonView(
@@ -512,12 +514,14 @@ struct ProfileView: View {
)
.padding(.top, 8)
}
.hideToolbarBackground()
} else {
ToolbarItem(placement: .topBarTrailing) {
navActionSheetButton
.padding(.top, 5)
.accentColor(DamusColors.white)
}
.hideToolbarBackground()
}
}
.toolbarBackground(.hidden)
@@ -0,0 +1,35 @@
//
// ToolbarItemModifier.swift
// damus
//
import SwiftUI
/// Extension that adds the `.hideToolbarBackground()` modifier to toolbar content.
///
/// This modifier conditionally applies `.sharedBackgroundVisibility(.hidden)` on iOS 26+,
/// eliminating the need for duplicated `if #available(iOS 26.0, *)` checks throughout the codebase.
///
/// - Usage:
/// ```swift
/// .toolbar {
/// ToolbarItem(placement: .navigationBarLeading) {
/// Button("Action") { }
/// }
/// .hideToolbarBackground()
/// }
/// ```
@available(iOS 15.0, *)
extension ToolbarContent {
/// Hides the toolbar background on iOS 26+, leaving it unchanged on earlier versions.
///
/// Apply this modifier to `ToolbarItem` views to suppress the shared background
/// visibility introduced in iOS 26 without duplicating version checks.
func hideToolbarBackground() -> some ToolbarContent {
if #available(iOS 26.0, *) {
return self.sharedBackgroundVisibility(.hidden)
} else {
return self
}
}
}