// An act, as a card.//// The owner's rulings of 12 and 13 Oct 2026: acts are cards — on the page, in// one row after the field cards, and in the tray the stack button raises; the// same cards in both. An act card is a field card's stock with the act's// object and a verb for its name, and its COLOUR says what the act does, the// same in every tool so a person learns it once (`ActCardReading.stock`). The// main act is first; it is not drawn differently. There are two gestures and// no menu://// tap fires an act that needs nothing just happens (Done, Join, Reopen);// the page lands its stamp and keeps an undo line.// hold fires an act that cannot be taken back (Bin, Cancel, Leave) carries// a red rule and fires on a hold of three quarters of a second,// an ink line drawing round the card; let go early and it// unwinds. No confirm popup anywhere.importSwiftUIenumActCardGesture: Equatable, Sendable {case fires, holds}structActCardReading: Equatable, Identifiable, Sendable {/// The act's id in its definition.var id: String/// The verb printed under the rule.var verb: Stringvar object: CardObject/// The main act: first on the page and in the tray.var main = falsevar gesture: ActCardGesture = .fires/// What the act does to the record, which decides its colour.var does: CommandDoes? = nil/// The act's colour, from what it does, as the theme prints each class/// (`theme.acts.<class>.stock`). An act held for a reason its definition/// does not name is a destructive one.func stock(_ acts: ThemeActs) -> ToolCardTint { acts.stock(does, held: gesture == .holds) }/// Lettered in red: only a held act that destroys — one held to put away/// (Archive) is lettered in ink like any other (architect, 13 Oct 2026).var isRed: Bool { gesture == .holds && (does == .destroys || does == nil) }/// The words on the card: a held act says it is held ("Hold to delete"),/// so a person never taps one and sees nothing (walker, 16 Oct 2026).var line: String { gesture == .holds ? CardWords.holdTo(verb) : verb }}structActCard: View { @Environment(\.theme) privatevar themelet act: ActCardReading/// Another card in the tray is being held: this one stands back.var standsBack = false/// The act fires: a tap on one that needs nothing, or a completed hold.var onFire: (ActCardReading) -> Void = { _ in }/// A hold began or ended, so the tray can stand its other cards back.var onHolding: (Bool) -> Void = { _ in }/// Its duration is the worn theme's, set by `beginHold` before every press —/// state is made before the environment reaches the view. @State privatevar hold = ActHold(duration: 0) @State privatevar drawn: CGFloat = 0 @State privatevar pressed = false @State privatevar thump: CGFloat = 1 @State privatevar timer: Task<Void, Never>? @State privatevar nudged: CGFloat = 0var body: someView {GeometryReader { geo in face(size: geo.size) } .aspectRatio(ActCardKnobs.cardAspect, contentMode: .fit) .scaleEffect(pressed ? ActCardKnobs.cardPressedScale : 1) .offset(y: hold.isHeld ? ActCardKnobs.cardHoldOffsetY : 0) .opacity(standsBack ? Double(ActCardKnobs.cardStandsBackOpacity) : 1) .modifier(ActCardNudge(phase: nudged)) .animation( .spring( response: Double(ActCardKnobs.cardPressSpringResponse), dampingFraction: Double(ActCardKnobs.cardPressSpringDamping)), value: pressed) .animation(.easeOut(duration: Double(ActCardKnobs.cardHoldLiftSeconds)), value: hold.isHeld) .animation(.easeOut(duration: Double(ActCardKnobs.cardStandsBackSeconds)), value: standsBack) .contentShape(Rectangle()) .onTapGesture(perform: tapped) .onLongPressGesture( minimumDuration: Double(ActCardKnobs.cardPressTrackSeconds), maximumDistance: ActCardKnobs.cardPressSlop, perform: {}, onPressingChanged: pressing) .onDisappear { timer?.cancel() } .accessibilityElement(children: .ignore) .accessibilityLabel(act.verb) .accessibilityHint(act.gesture == .holds ? CardWords.holdHint : "") .accessibilityAddTraits(.isButton)// A reader that cannot hold fires the act by activating it: the hold// is the sighted hand's confirmation, and activation is theirs. .accessibilityAction { fire() } .accessibilityIdentifier("act-\(act.id)") }privatefunc face(size: CGSize) -> someView {CardStock( paper: .stock(act.stock(theme.acts)), size: size,// The red rule and the red name belong to the rose stock, the act// that destroys: an act held to put away (Archive, on grey) is// lettered in ink like any other (architect, 13 Oct 2026). rule: act.isRed ? .red : .plain, line: act.line, lineInk: act.isRed ? .red : nil, seed: "act-" + act.id ) { side inCardObjectView(object: act.object, side: side * ActCardKnobs.cardActObjectFraction) .scaleEffect(thump) } .overlay {// The line a hold draws: ink, round the card's own edge, from the// top's middle and back to it.CardOutline(corner: ActCardKnobs.cardCornerFraction) .trim(from: 0, to: drawn) .stroke( theme.print(.ink), style: StrokeStyle(lineWidth: ActCardKnobs.cardHoldOutlineWidth, lineCap: .round, lineJoin: .round) ) .padding(ActCardKnobs.cardHoldOutlineInset) .accessibilityHidden(true) } }/// A tap fires. On an act that is held, a tap is not enough: the/// card shakes its head and its words say what it wants ("Hold to/// delete") — never nothing.privatefunc tapped() {switch act.gesture {case .fires: fire()case .holds: withAnimation(.linear(duration: Double(ActCardKnobs.cardNudgeSeconds))) { nudged += 1 } } }privatefunc pressing(_ down: Bool) {guard act.gesture == .holds else { pressed = downreturn } down ? beginHold() : endHold() }privatefunc beginHold() {let duration = Double(ActCardKnobs.cardHoldDurationSeconds)if !hold.isHeld { hold.duration = duration } hold.press(at: Date()) onHolding(true) withAnimation(.linear(duration: hold.duration)) { drawn = 1 } timer?.cancel() timer = Task { @MainActor intry? awaitTask.sleep(for: .seconds(hold.duration))guard !Task.isCancelled, hold.completes(at: Date()) else { return } _ = hold.release(at: Date()) drawn = 0 onHolding(false) fire() } }privatefunc endHold() {guard hold.isHeld else { return } timer?.cancel()// Let go: the act fires only if the whole time was served.let fires = hold.release(at: Date()) onHolding(false) withAnimation(.easeOut(duration: Double(ActCardKnobs.cardHoldUnwindSeconds))) { drawn = 0 }if fires { fire() } }/// The act fires, and its object lands on the card the way a stamp does:/// from above, at once.privatefunc fire() { thump = ActCardKnobs.stampThumpFrom withAnimation(.easeOut(duration: Double(ActCardKnobs.stampThumpDuration))) { thump = 1 } onFire(act) }}/// A held card's answer to a tap: a short shake from side to side, one/// whole `phase` a shake.structActCardNudge: GeometryEffect {var phase: CGFloatvar animatableData: CGFloat { get { phase } set { phase = newValue } }func effectValue(size: CGSize) -> ProjectionTransform {let x = ActCardKnobs.cardNudgeDistance * sin(phase * .pi * 2 * ActCardKnobs.cardNudgeShakes)returnProjectionTransform(CGAffineTransform(translationX: x, y: 0)) }}/// The sizes, counts and timings ActCard draws with: Swift's own, beside/// their reader — a theme sets only its tokens (`scale.tokens`).enumActCardKnobs {staticlet cardActObjectFraction: CGFloat = 0.92staticlet cardAspect: CGFloat = 0.75staticlet cardCornerFraction: CGFloat = 0.06staticlet cardHoldDurationSeconds: CGFloat = 0.75staticlet cardHoldLiftSeconds: CGFloat = 0.18staticlet cardHoldOffsetY: CGFloat = -4staticlet cardHoldOutlineInset: CGFloat = 1.25staticlet cardHoldOutlineWidth: CGFloat = 2.5staticlet cardHoldUnwindSeconds: CGFloat = 0.22staticlet cardNudgeDistance: CGFloat = 5staticlet cardNudgeSeconds: CGFloat = 0.36staticlet cardNudgeShakes: CGFloat = 3staticlet cardPressSlop: CGFloat = 44staticlet cardPressSpringDamping: CGFloat = 0.7staticlet cardPressSpringResponse: CGFloat = 0.24staticlet cardPressTrackSeconds: CGFloat = 60staticlet cardPressedScale: CGFloat = 0.96staticlet cardStandsBackOpacity: CGFloat = 0.5staticlet cardStandsBackSeconds: CGFloat = 0.18staticlet stampThumpDuration: CGFloat = 0.22staticlet stampThumpFrom: CGFloat = 1.3}extensionThemeActs {/// The stock an act of class `does` is printed on; `held` decides an act/// that names no class. Here rather than beside `ThemeActs`: what an act/// does is a definition's word, and the look (`CottonPaper`) names none.func stock(_ does: CommandDoes?, held: Bool) -> ToolCardTint {switch does {case .completes: return completescase .times: return timescase .moves: return movescase .destroys: return destroyscase .putsAway: return putsAwaycasenil: return held ? unnamedHeld : unnamed } }}