ui: Fixes for iOS 26 toolbars
Note: This will only become user-facing once we switch to liquid glass mode, therefore no changelog entry is needed now. Changelog-None Closes: https://github.com/damus-io/damus/issues/3702 Co-Authored-by: Daniel D’Aquino <daniel@daquino.me> Signed-off-by: ericholguin <ericholguin@apache.org>
This commit is contained in:
committed by
Daniel D’Aquino
parent
69ba4b2c38
commit
d99443be6d
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user