import SwiftUI /// Displays a window thumbnail with an always-visible title below it. struct WindowThumbnailView: View { let windowInfo: WindowInfo let size: CGSize let isSelected: Bool var showAppBadge: Bool = true private var thumbnailHeight: CGFloat { size.height - LayoutGeometry.titleHeight } var body: some View { VStack(spacing: 0) { // Thumbnail ZStack(alignment: .topLeading) { RoundedRectangle(cornerRadius: 8) .fill(.ultraThinMaterial) if let thumbnail = windowInfo.thumbnail { Image(decorative: thumbnail, scale: 1.0) .resizable() .scaledToFill() .frame(width: size.width, height: thumbnailHeight) .clipped() .clipShape(RoundedRectangle(cornerRadius: 6)) } else { Image(systemName: "macwindow") .font(.system(size: min(32, size.width * 0.3))) .foregroundStyle(.secondary) .frame(maxWidth: .infinity, maxHeight: .infinity) } // App icon badge in compact mode if showAppBadge, let icon = windowInfo.appIcon { Image(nsImage: icon) .resizable() .frame(width: 80, height: 80) .shadow(color: .black.opacity(0.5), radius: 3) .padding(6) } } .frame(width: size.width, height: thumbnailHeight) .overlay( RoundedRectangle(cornerRadius: 8) .stroke(isSelected ? Color.accentColor : Color.white.opacity(0.2), lineWidth: isSelected ? 3 : 1) ) .shadow(color: .black.opacity(0.3), radius: isSelected ? 8 : 4) // Always-visible title (includes app name in compact mode) Text(displayTitle) .font(.system(size: 16, weight: .medium)) .foregroundStyle(.white) .lineLimit(1) .truncationMode(.middle) .frame(width: size.width, height: LayoutGeometry.titleHeight) } .contentShape(Rectangle()) } private var displayTitle: String { return "\(windowInfo.appName) — \(windowInfo.title)" } }