// The rubber stamp, out of the todo card and into the kit. // // DONE is a stamp and the text under it stays readable — the owner's rule, and // the reason there is no strike-through anywhere in the app. A stamp is one of // the two things in the kit that is still a photograph (the caps are the other), // because rubber on paper is ink that missed: the gaps ARE the object, and a // drawn one is a badge. // // It is positioned by the CALLER. A stamp lands where the hand put it, but // never on a heading. // // `stamp-keep` (a green KEEP, for the decide queue) is named in the paper-kit // spec and is NOT in the tree: generating it needs the image pipeline's API key, // which this machine has not got. There is no `.keep` case rather than a case // that draws nothing — a silent hole is worse than a missing verb. import CottonPaper import SwiftUI /// The stamps there are. The raw value is the imageset's name. public enum StampKind: String, CaseIterable, Sendable { case done = "stamp-done" case dropped = "stamp-dropped" /// The stamp a record's status earns, or none. public static func of(status: String) -> StampKind? { switch status { case "done": return .done case "dropped": return .dropped default: return nil } } /// What the stamp says, for a reader that cannot see it. public var spoken: String { switch self { case .done: return "Done" case .dropped: return "Dropped" } } } public struct Stamp: View { private let kind: StampKind private let width: CGFloat private let scale: CGFloat public init(_ kind: StampKind, width: CGFloat, scale: CGFloat = 1) { self.kind = kind self.width = width self.scale = scale } @Environment(\.theme) private var theme public var body: some View { switch theme.family { case .paper: rubber case .plain: label } } /// A flat family's stamp: the word in a ruled box, in the state's colour, /// laid in the box the rubber one takes — the picture's own proportion, /// held by the picture itself unseen — so it lands in the same place and /// the text under it reads on every platform the picture is drawn at. @ViewBuilder private var label: some View { let ink = kind == .done ? theme.colors.success.color : theme.colors.inkSecondary.color let word = Text(kind.spoken.uppercased()) .font(theme.type.interface(width * StampKnobs.stampLabelSize, weight: .semibold)) .tracking(width * StampKnobs.stampLabelTracking) .lineLimit(1) .foregroundStyle(ink) .padding(.horizontal, width * StampKnobs.stampLabelHorizontalPadding) .padding(.vertical, width * StampKnobs.stampLabelVerticalPadding) .overlay( RoundedRectangle(cornerRadius: theme.scale.radius * 0.5) .strokeBorder(ink, lineWidth: theme.scale.stroke * StampKnobs.stampLabelStrokeScale) ) Group { if let picture = CottonMedia.image(kind.rawValue) { picture.resizable().scaledToFit().hidden().accessibilityHidden(true).overlay { word } } else { word } } .frame(width: width) .opacity(Double(StampKnobs.stampOpacity)) .scaleEffect(scale) .allowsHitTesting(false) .accessibilityHidden(true) } @ViewBuilder private var rubber: some View { if let picture = CottonMedia.image(kind.rawValue) { picture .resizable() .interpolation(.high) .scaledToFit() .frame(width: width) .blendMode(.multiply) .opacity(Double(StampKnobs.stampOpacity)) .scaleEffect(scale) .allowsHitTesting(false) .accessibilityHidden(true) } } // The thump a stamp lands with (1.3 → 1.0 in 220 ms) is the screen's, not // the stamp's, because WHEN it lands is the screen's fact — a card arriving // already stamped must not thump. A screen reads the worn theme's // `stamp_thump_from` and `stamp_thump_duration`. } /// The sizes, counts and timings Stamp draws with: Swift's own, beside /// their reader — a theme sets only its tokens (`scale.tokens`). enum StampKnobs { static let stampFootTiltDegrees: CGFloat = -9 static let stampLabelHorizontalPadding: CGFloat = 0.08 static let stampLabelSize: CGFloat = 0.16 static let stampLabelStrokeScale: CGFloat = 1.5 static let stampLabelTracking: CGFloat = 0.01 static let stampLabelVerticalPadding: CGFloat = 0.03 static let stampOpacity: CGFloat = 0.92 }