Fix toast view liquid glass not updating background

This commit is contained in:
Leon Böttger committed 2026-04-05 11:24:08 +02:00
1 parent fcbe99dd85
commit 02ab04c69e
1 file changed
+17 -2
+17 -2
View File
@@ -439,8 +439,7 @@ struct AdaptiveToastBackgroundLayer: View {
var body: some View {
Group {
if #available(macOS 26.0, *) {
Color.clear
.glassEffect(.regular, in: .rect(cornerRadius: cornerRadius, style: .continuous))
GlassEffectBackgroundView(cornerRadius: cornerRadius)
} else {
VisualEffectView(material: .hudWindow, blendingMode: .behindWindow, cornerRadius: cornerRadius)
}
@@ -449,6 +448,22 @@ struct AdaptiveToastBackgroundLayer: View {
}
@available(macOS 26.0, *)
struct GlassEffectBackgroundView: NSViewRepresentable {
var cornerRadius: CGFloat = 0
func makeNSView(context: Context) -> NSGlassEffectView {
let v = NSGlassEffectView()
v.cornerRadius = cornerRadius
return v
}
func updateNSView(_ v: NSGlassEffectView, context: Context) {
v.cornerRadius = cornerRadius
}
}
// NSVisualEffectView wrapper for macOS 11 compatible blur/vibrancy
struct VisualEffectView: NSViewRepresentable {
var material: NSVisualEffectView.Material = .hudWindow