diff --git a/Demo/Demo/ContentView.swift b/Demo/Demo/ContentView.swift index 2b15391..53037f1 100644 --- a/Demo/Demo/ContentView.swift +++ b/Demo/Demo/ContentView.swift @@ -20,6 +20,5 @@ struct ContentView: View { } .padding() .frame(minWidth: 500, minHeight: 350) - .background(VisualEffect.nonVibrant()) } } diff --git a/Sources/MacControlCenterUI/Utilities/VisualEffect.swift b/Sources/MacControlCenterUI/Utilities/VisualEffect.swift index 35f8c9b..f218f57 100644 --- a/Sources/MacControlCenterUI/Utilities/VisualEffect.swift +++ b/Sources/MacControlCenterUI/Utilities/VisualEffect.swift @@ -92,12 +92,24 @@ extension VisualEffect { extension View { /// Applies the appropriate window background effect for the menu based on the current platform. + @ViewBuilder func menuBackgroundEffectForCurrentPlatform() -> some View { if #available(macOS 26.0, *) { - return backgroundStyle(.ultraThinMaterial /* .thinMaterial */ ) + menuBackgroundEffectForCurrentPlatformBase() .windowResizeAnchor(.topLeading) // helps with smooth menu window resize animations } else { - return background(VisualEffect.popoverWindow()) + menuBackgroundEffectForCurrentPlatformBase() + } + } + + @ViewBuilder + private func menuBackgroundEffectForCurrentPlatformBase() -> some View { + if #available(macOS 27.0, *) { + backgroundStyle(.regularMaterial) + } else if #available(macOS 26.0, *) { + backgroundStyle(.ultraThinMaterial) + } else { + background(VisualEffect.popoverWindow()) } }