// The one confirm dialog — a decision that cannot be taken back, asked once.//// ## The dress (phase 20, 2026-09-14)//// A question is a SLIP OF PAPER put down over the screen: a small torn cream// slip, lifted, on the screen's own plaster dimmed behind it. The question is// set in the serif — it is the slip's title — and the sentence under it is// typed. Under a pencil line sit the two verbs, typed: Cancel in pencil, and// the act itself in RED INK when it erases something, in ink when it does not.//// What went: the 56pt glyph disc and the two filled buttons. A disc with a// trash can in it is a badge, not a thing on paper, and a filled red button on// a slip is a sticker. The red INK is what says danger now, and it says it on// the one word that does the damage.//// ## Two rules the caller does not get to choose//// * **The dialog IS the decision.** Nothing is erased by the tap that opens// it, and `onConfirm` is the only path to the act.// * **Neither verb works while `isLoading`.** A double-tapped Empty is two// erasures, and the second one cannot be undone any more than the first.// `confirm()` and `cancel()` hold that rule, and the test calls them.//// A full-screen overlay rather than a `.sheet`, because this is a question// ABOVE the screen you are reading and a sheet is a surface you go INTO.// `.alert` is not this: an alert is the platform's own card in the platform's// own voice.importSwiftUIpublicenumConfirmDecisionTone: Sendable {/// The act erases something. The verb is red ink, and the button carries/// the destructive role so VoiceOver says so.case danger/// Everything else. The verb is ink.case primary/// The ink the act's verb is typed in.var verbInk: PaperInk {switchself {case .danger: return .redcase .primary: return .ink } }/// The button's role — what a screen reader announces before the word.var role: ButtonRole? {switchself {case .danger: return .destructivecase .primary: returnnil } }}/// The slip's measurements, by name.enumConfirmDecisionSlip {staticlet maxWidth: CGFloat = 320staticlet inset: CGFloat = 24staticlet titleSize: CGFloat = 21staticlet messageSize: CGFloat = 14staticlet verbSize: CGFloat = 16/// How much the plaster behind the slip is dimmed.staticlet scrim: Double = 0.30}publicstructConfirmDecisionDialog: View {privatelet title: Stringprivatelet message: Stringprivatelet confirmLabel: Stringprivatelet cancelLabel: Stringprivatelet tone: ConfirmDecisionToneprivatelet isLoading: Boolprivatelet identifier: String?privatelet onConfirm: () -> Voidprivatelet onCancel: () -> Void/// A second answer beside the first ("Only this one" / "Every one"): the/// verbs then stand one under the other, Cancel last.privatevar otherLabel: String?privatevar onOther: (() -> Void)? @Environment(\.theme) privatevar themepublicinit( title: String, message: String, confirmLabel: String, cancelLabel: String? = nil, tone: ConfirmDecisionTone = .danger, isLoading: Bool = false, identifier: String? = nil, onConfirm: @escaping () -> Void, onCancel: @escaping () -> Void ) {self.title = titleself.message = messageself.confirmLabel = confirmLabelself.cancelLabel = cancelLabel ?? "Cancel"self.tone = toneself.isLoading = isLoadingself.identifier = identifierself.onConfirm = onConfirmself.onCancel = onCancel }/// Take the act — unless it is already in flight.publicfunc confirm() {guard !isLoading else { return } onConfirm() }/// The slip with a second answer under the first.publicfunc other(_ label: String?, _ act: @escaping () -> Void) -> ConfirmDecisionDialog {var copy = self copy.otherLabel = label copy.onOther = actreturn copy }/// Take the second answer — unless an act is already in flight.publicfunc chooseOther() {guard !isLoading else { return } onOther?() }/// Put the slip away — unless the act is already in flight, when walking/// away would leave it finishing behind a screen that no longer says so.publicfunc cancel() {guard !isLoading else { return } onCancel() }/// The slip's seed: the caller's identifier when it has one, so the same/// question is the same slip every time it is asked.var seed: String { "question-\(identifier ?? title)" }publicvar body: someView { ZStack {CottonColors.ink.opacity(ConfirmDecisionSlip.scrim) .ignoresSafeArea()// The scrim dismisses: the one gesture a modal question must// always answer. .onTapGesture { cancel() } slip } .accessibilityIdentifier(identifier ?? "") .accessibilityAddTraits(.isModal) }privatevar slip: someView {Paper(dye: .cream, edge: .torn, seed: seed, shadow: .lifted, inset: ConfirmDecisionSlip.inset) { VStack(spacing: 0) {Text(title) .paperTitle(ConfirmDecisionSlip.titleSize) .multilineTextAlignment(.center) .fixedSize(horizontal: false, vertical: true) .padding(.top, 6) .padding(.bottom, 10)Text(message) .paperBody(ConfirmDecisionSlip.messageSize) .lineSpacing(3) .multilineTextAlignment(.center) .fixedSize(horizontal: false, vertical: true) .padding(.bottom, 20)PencilRule(seed: seed, theme: theme) .stroke(theme.print(.pencil), lineWidth: 0.9) .blendMode(theme.printBlend) .frame(height: 2)iflet otherLabel { VStack(spacing: 0) { verb(confirmLabel, "confirm", action: confirm) verb(otherLabel, "other", action: chooseOther)Button(action: cancel) {Text(cancelLabel) .paperBody(ConfirmDecisionSlip.verbSize, ink: .pencil) .frame(maxWidth: .infinity, minHeight: 48) .contentShape(Rectangle()) } .buttonStyle(OpacityButtonStyle(pressed: 0.6)) .accessibilityIdentifier(identifier.map { "\($0)-cancel" } ?? "") } .padding(.top, 4) } else { HStack(spacing: 0) {Button(action: cancel) {Text(cancelLabel) .paperBody(ConfirmDecisionSlip.verbSize, ink: .pencil) .frame(maxWidth: .infinity, minHeight: 48) .contentShape(Rectangle()) } .buttonStyle(OpacityButtonStyle(pressed: 0.6)) .disabled(isLoading) .accessibilityIdentifier(identifier.map { "\($0)-cancel" } ?? "")Button(role: tone.role, action: confirm) { ZStack {if isLoading {// The ONE place this app draws a native// indicator outside the migration screen: the// slip is already drawn, and what is in flight// is the act rather than a screen.ProgressView().tint(theme.print(tone.verbInk)) } else {Text(confirmLabel) .paperBody(ConfirmDecisionSlip.verbSize, ink: tone.verbInk) } } .frame(maxWidth: .infinity, minHeight: 48) .contentShape(Rectangle()) } .buttonStyle(OpacityButtonStyle(pressed: 0.6)) .disabled(isLoading) .accessibilityIdentifier(identifier.map { "\($0)-confirm" } ?? "") } .padding(.top, 4) .opacity(isLoading ? 0.6 : 1) } } }// The slip is as tall as its words. `Paper` fills a height it is// PROPOSED, and the ZStack over the screen proposes the whole screen. .fixedSize(horizontal: false, vertical: true) .frame(maxWidth: ConfirmDecisionSlip.maxWidth) .padding(.horizontal, 28) }}extensionConfirmDecisionDialog {/// One of two answers, typed in the act's ink.fileprivatefunc verb(_ label: String, _ name: String, action: @escaping () -> Void) -> someView {Button(role: tone.role, action: action) {Text(label) .paperBody(ConfirmDecisionSlip.verbSize, ink: tone.verbInk) .frame(maxWidth: .infinity, minHeight: 48) .contentShape(Rectangle()) } .buttonStyle(OpacityButtonStyle(pressed: 0.6)) .accessibilityIdentifier(identifier.map { "\($0)-\(name)" } ?? "") }}extensionView {/// Ask a question that cannot be taken back, over this screen.////// Public for the Mac's own Settings pages, which ask their one question/// (the recovery key) on the same slip — the reason the slip is the/// look's (`CottonPaper`) and asks nothing of a record. How far a write to/// a repeating record reaches is `CottonUI`'s question (`scopeDecision`).publicfunc confirmDecision( isPresented: Bool, title: String, message: String, confirmLabel: String, cancelLabel: String? = nil, tone: ConfirmDecisionTone = .danger, isLoading: Bool = false, identifier: String? = nil, onConfirm: @escaping () -> Void, onCancel: @escaping () -> Void ) -> someView { overlay {if isPresented {ConfirmDecisionDialog( title: title, message: message, confirmLabel: confirmLabel, cancelLabel: cancelLabel, tone: tone, isLoading: isLoading, identifier: identifier, onConfirm: onConfirm, onCancel: onCancel ) .transition(.opacity) } } .animation(.easeInOut(duration: 0.15), value: isPresented) }}