#if os(macOS) import SwiftUI import Defaults /// Custom OSD panel that mimics macOS native OSD appearance /// Supports volume, brightness, and keyboard backlight displays struct CustomOSDView: View { @Binding var type: SneakContentType @Binding var value: CGFloat @Binding var icon: String @Default(.osdMaterial) var osdMaterial @Default(.osdIconColorStyle) var osdIconColorStyle @Environment(\.colorScheme) var colorScheme private let iconSize: CGFloat = 56 private let progressBarHeight: CGFloat = 6 private let spacing: CGFloat = 20 private let segmentCount: Int = 16 var body: some View { VStack(spacing: spacing) { // Icon ZStack { Image(systemName: symbolName) .font(.system(size: iconSize, weight: .regular)) .foregroundStyle(iconColor) .symbolRenderingMode(.hierarchical) } .frame(width: 80, height: 60, alignment: .center) // Fixed container for icon // Progress/Value Indicator progressView .frame(width: 140) .padding(.top, 4) // Lower the bar slightly } .frame(width: 200, height: 200) .background( RoundedRectangle(cornerRadius: 18, style: .continuous) .fill(.black.opacity(0.1)) // Subtle backing for shadow source .shadow(color: Color.black.opacity(0.25), radius: 24, x: 0, y: 8) ) .background( backgroundView .clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous)) ) .clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous)) } // MARK: - Symbol Logic private var symbolName: String { if !icon.isEmpty { return icon } switch type { case .volume: if value < 0.01 { return "speaker.slash.fill" } else if value < 0.33 { return "speaker.fill" } else if value < 0.66 { return "speaker.wave.1.fill" } else { return "speaker.wave.3.fill" } case .brightness: return "sun.max.fill" case .backlight: return value >= 0.5 ? "light.max" : "light.min" default: return "questionmark" } } private var iconColor: Color { switch osdIconColorStyle { case .white: return .white case .whiteTransparent: return .white.opacity(0.85) case .lightGray: return Color(white: 0.85) case .darkGray: return Color(white: 0.3) case .black: return .black case .blackTransparent: return .black.opacity(0.85) case .auto: return colorScheme == .dark ? .white : .black case .autoTransparent: return colorScheme == .dark ? .white.opacity(0.85) : .black.opacity(0.85) } } private var textColor: Color { switch osdIconColorStyle { case .white, .whiteTransparent, .lightGray: return .white case .darkGray, .black, .blackTransparent: return .black case .auto, .autoTransparent: return colorScheme == .dark ? .white : .black } } // MARK: - Progress View private var progressView: some View { HStack(spacing: 3) { ForEach(0..