style(mac): hud glass voice overlay

This commit is contained in:
Peter Steinberger
2025-12-12 16:39:11 +00:00
parent 3f1bcac077
commit af78762421
2 changed files with 45 additions and 6 deletions

View File

@@ -0,0 +1,38 @@
import AppKit
import SwiftUI
struct VisualEffectView: NSViewRepresentable {
var material: NSVisualEffectView.Material
var blendingMode: NSVisualEffectView.BlendingMode
var state: NSVisualEffectView.State
var emphasized: Bool
init(
material: NSVisualEffectView.Material,
blendingMode: NSVisualEffectView.BlendingMode = .behindWindow,
state: NSVisualEffectView.State = .active,
emphasized: Bool = false)
{
self.material = material
self.blendingMode = blendingMode
self.state = state
self.emphasized = emphasized
}
func makeNSView(context _: Context) -> NSVisualEffectView {
let view = NSVisualEffectView()
view.material = self.material
view.blendingMode = self.blendingMode
view.state = self.state
view.isEmphasized = self.emphasized
return view
}
func updateNSView(_ nsView: NSVisualEffectView, context _: Context) {
nsView.material = self.material
nsView.blendingMode = self.blendingMode
nsView.state = self.state
nsView.isEmphasized = self.emphasized
}
}

View File

@@ -510,12 +510,13 @@ private struct VoiceWakeOverlayView: View {
.padding(.vertical, 8)
.padding(.horizontal, 10)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.background(
RoundedRectangle(cornerRadius: 12, style: .continuous)
.strokeBorder(Color.white.opacity(0.12), lineWidth: 1)
.background(
RoundedRectangle(cornerRadius: 12, style: .continuous)
.fill(.regularMaterial)))
.background {
let shape = RoundedRectangle(cornerRadius: 12, style: .continuous)
VisualEffectView(material: .hudWindow, blendingMode: .behindWindow)
.clipShape(shape)
.overlay(shape.strokeBorder(Color.white.opacity(0.16), lineWidth: 1))
}
.shadow(color: Color.black.opacity(0.22), radius: 14, x: 0, y: -2)
.onHover { self.isHovering = $0 }
// Close button rendered above and outside the clipped bubble