From f5d9b356225193724407da0b97c840b4645d833f Mon Sep 17 00:00:00 2001 From: Michael Freno Date: Sun, 11 Jan 2026 14:31:52 -0500 Subject: [PATCH] glass fallback improved --- Gaze/Extensions/ViewExtensions.swift | 37 +++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/Gaze/Extensions/ViewExtensions.swift b/Gaze/Extensions/ViewExtensions.swift index 6ebb400..f34e9a2 100644 --- a/Gaze/Extensions/ViewExtensions.swift +++ b/Gaze/Extensions/ViewExtensions.swift @@ -17,25 +17,36 @@ extension View { self.glassEffect(style.toGlass(), in: shape) } else { self.background { - shape - .fill( - style.tintColor ?? .white - ) - .overlay( + ZStack { + if let tintColor = style.getTintColor() { shape - .stroke( - (style.tintColor ?? .white).opacity(0.2), - lineWidth: 1 + .fill(tintColor.opacity(0.8)) + } else { + shape + .fill(.ultraThinMaterial) + } + + // Border with tint color mixed with white + if let tintColor = style.getTintColor() { + shape + .strokeBorder( + Color( + red: (tintColor.cgColor?.components?[0] ?? 1.0) * 0.7 + 0.3, + green: (tintColor.cgColor?.components?[1] ?? 1.0) * 0.7 + 0.3, + blue: (tintColor.cgColor?.components?[2] ?? 1.0) * 0.7 + 0.3 + ).opacity(0.6), + lineWidth: 1.5 ) - ) - .shadow(color: .black.opacity(0.1), radius: 4, x: 0, y: 2) + } + } + .shadow(color: .black.opacity(0.1), radius: 4, x: 0, y: 2) } } } } struct GlassStyle { - let tintColor: Color? + private let tintColor: Color? private let isInteractive: Bool static let regular = GlassStyle(tintColor: nil, isInteractive: false) @@ -53,6 +64,10 @@ struct GlassStyle { GlassStyle(tintColor: tintColor, isInteractive: true) } + func getTintColor() -> Color? { + return tintColor + } + @available(macOS 26.0, *) func toGlass() -> Glass { var glass = Glass.regular