mirror of
https://github.com/yattee/yattee.git
synced 2026-07-20 14:22:02 +00:00
Views without an explicit background sat on the translucent window material, which picks up a wallpaper tint (bluish in dark mode) and clashed with views drawing windowBackgroundColor, making the video info header gradient fade visibly mismatch. Add opaqueWindowBackground() and apply it centrally in NavigationDestinationHandlerModifier to both stack roots and pushed destinations, plus VideoInfoView for presentations outside navigation stacks. Claude-Session: https://claude.ai/code/session_0154KH8RAVAvm6iVanhmoW8o
34 lines
1009 B
Swift
34 lines
1009 B
Swift
//
|
|
// OpaqueWindowBackground.swift
|
|
// Yattee
|
|
//
|
|
// Unified opaque background for main content views on macOS.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// Applies an opaque window background on macOS.
|
|
///
|
|
/// Without an explicit background, content sits on the translucent window
|
|
/// material, which picks up a wallpaper tint (often bluish in dark mode) and
|
|
/// clashes with views that draw `windowBackgroundColor` themselves (lists,
|
|
/// gradient fades). No-op on other platforms.
|
|
struct OpaqueWindowBackgroundModifier: ViewModifier {
|
|
func body(content: Content) -> some View {
|
|
#if os(macOS)
|
|
content
|
|
.background(Color(nsColor: .windowBackgroundColor).ignoresSafeArea())
|
|
#else
|
|
content
|
|
#endif
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
/// Gives the view an opaque window background on macOS so all main content
|
|
/// views share the same background color. No-op on iOS/tvOS.
|
|
func opaqueWindowBackground() -> some View {
|
|
modifier(OpaqueWindowBackgroundModifier())
|
|
}
|
|
}
|