import SwiftUI /// A destructive action waiting for a yes: ↵ confirms, esc cancels. struct ConfirmOverlay: View { let request: ConfirmRequest var onConfirm: () -> Void var onClose: () -> Void var body: some View { OverlayShell(.sized(width: 460), onDismiss: onClose) { VStack(alignment: .leading, spacing: 0) { Text(request.title).typeRole(Typography.dialogTitle).foregroundStyle(Palette.text1) if let body = request.body { Text(body) .typeRole(TypeRole(.monoRegular, 12, lineHeight: 19.2)) .foregroundStyle(Palette.text4) .fixedSize(horizontal: false, vertical: true) .padding(.top, 12) } HStack(spacing: 8) { Spacer() Button(action: onClose) { HStack(spacing: 8) { Text("Cancel") Keycap("esc") } } .buttonStyle(.secondary) // The model dismisses the overlay itself; closing here first would drop the pending request. Button(action: onConfirm) { HStack(spacing: 8) { Text(request.confirmLabel) Keycap("↵", style: .onDeep) } } .buttonStyle(.destructive) } .padding(.top, 20) } .padding(20) .frame(maxWidth: .infinity, alignment: .leading) .background(OverlayKeyCatcher(onKey: handle)) } } private func handle(_ key: OverlayKey) -> Bool { switch key { case .enter: onConfirm() case .escape: onClose() default: return false } return true } }