Skip to content

Commit 9773034

Browse files
committed
Add frosted mode for desktop info
1 parent f68b622 commit 9773034

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

SupportCompanion/Preferences.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class Preferences: ObservableObject {
9999

100100
@AppStorage("DesktopInfoBackgroundOpacity") var desktopInfoBackgroundOpacity: Double = 0.001
101101

102+
@AppStorage("DesktopInfoBackgroundFrosted") var desktopInfoBackgroundFrosted: Bool = false
103+
102104
@AppStorage("DesktopInfoWindowPosition") var desktopInfoWindowPosition: String = "LowerRight"
103105
@Published var currentWindowPosition: String = "LowerRight"
104106

SupportCompanion/Views/TransparentView.swift

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,19 @@ struct TransparentView: View {
1818

1919
var body: some View {
2020
ZStack {
21+
if appState.preferences.desktopInfoBackgroundFrosted {
22+
BlurEffectView(
23+
material: .fullScreenUI,
24+
blendingMode: .behindWindow
25+
)
26+
.clipShape(RoundedRectangle(cornerRadius: 15))
27+
.edgesIgnoringSafeArea(.all)
28+
}
29+
2130
RoundedRectangle(cornerRadius: 15)
22-
.fill(Color.black.opacity(appState.preferences.desktopInfoBackgroundOpacity))
23-
.shadow(radius: 10) // Shadow for depth
24-
.clipShape(RoundedRectangle(cornerRadius: 15)) // Ensure clipping
31+
.fill(Color.black.opacity(appState.preferences.desktopInfoBackgroundOpacity))
32+
.shadow(radius: 10) // Shadow for depth
33+
.clipShape(RoundedRectangle(cornerRadius: 15))
2534

2635
VStack(alignment: .leading) {
2736
// Title for the Info View
@@ -253,6 +262,25 @@ struct TransparentView: View {
253262
}
254263
}
255264

265+
struct BlurEffectView: NSViewRepresentable {
266+
let material: NSVisualEffectView.Material
267+
let blendingMode: NSVisualEffectView.BlendingMode
268+
269+
func makeNSView(context: Context) -> NSVisualEffectView {
270+
let view = NSVisualEffectView()
271+
view.material = material // Set material to ultra-thin equivalent
272+
view.blendingMode = blendingMode // Set blending mode to behindWindow or withinWindow
273+
view.state = .active // Ensure the effect is active
274+
return view
275+
}
276+
277+
func updateNSView(_ nsView: NSVisualEffectView, context: Context) {
278+
nsView.material = material
279+
nsView.blendingMode = blendingMode
280+
nsView.state = .active
281+
}
282+
}
283+
256284
struct SectionHeaderTransparent: View {
257285
let title: String
258286
let addHeader: Bool

0 commit comments

Comments
 (0)