// The todo's check, and the line along a check slip's foot — drawn by every// slip whose definition names a toggle (`SlipFace`) and the project// overview's todo rows.//// They lived with the Todos tool's board card until the Todos screens became// their table's list and page (rebuild item 4); the card went, the check and// the foot it shared stay here.importSwiftUI// MARK: - The slip's foot/// What the board's slip types along its foot, and the two sizes it lays.////// Pure, so the sentence a person reads under a todo is settled by a test/// rather than by reading a view body.enumTodoSlipFoot {/// The day, the time and the project, in that order, joined by the page's/// separator — or nothing at all when the slip carries none of them. On/// an upcoming list the day is left to its heading (`upcomingFoot`); the/// project is always said, since no heading names it.staticfunc line(day: String?, meta: String?, project: String? = nil) -> String? {let parts = [day, meta, project] .compactMap { $0 } .filter { !$0.isEmpty }return parts.isEmpty ? nil : parts.joined(separator: " \u{00B7} ") }}// MARK: - The check/// The check on a slip's paper — every check slip's, ONE view, so a todo's/// check is the same object wherever it is drawn.////// A square, 1.5pt stroke, radius 3; done draws the red tick over it,/// overshooting the square the way a pen does. Its own control, with the 44pt/// target a thumb needs, laid out at the square's own size.structTodoPaperCheck: View {let done: Boollet side: CGFloat/// What the todo is called, for the spoken "Complete …" / "Reopen …".let label: String/// `true` to complete, `false` to reopen.let onToggle: (Bool) -> Void @Environment(\.cottonHaptics) privatevar haptics @Environment(\.theme) privatevar themevar body: someView {Button { done ? haptics.select() : haptics.success() onToggle(!done) } label: {TodoCheckSquare(done: done, side: side) .padding((SlipCheckKnobs.slipCheckTarget - side) * 0.5) .contentShape(Rectangle()) } .buttonStyle(.plain) .padding(-(SlipCheckKnobs.slipCheckTarget - side) * 0.5) .accessibilityLabel(ShellLines.line("faces", done ? "slip.reopen" : "slip.complete", ["label": label])) .accessibilityAddTraits(done ? [.isButton, .isSelected] : .isButton) }}/// The check's drawing and nothing else: a square, 1.5pt stroke, radius 3,/// and done's red tick over it. The board's check wraps it in a control.structTodoCheckSquare: View { @Environment(\.theme) privatevar themelet done: Boollet side: CGFloatvar body: someView { ZStack {RoundedRectangle(cornerRadius: SlipCheckKnobs.slipCheckCornerRadius, style: .continuous) .strokeBorder(theme.print(.ink), lineWidth: SlipCheckKnobs.slipCheckLineWidth) .blendMode(theme.printBlend)if done {HandTick(theme: theme) .stroke( theme.print(.red), style: StrokeStyle(lineWidth: max(SlipCheckKnobs.slipCheckTickMinWidth, side * SlipCheckKnobs.slipCheckTickWidthFraction), lineCap: .round, lineJoin: .round) ) .frame(width: side * SlipCheckKnobs.slipCheckTickWidthRatio, height: side * SlipCheckKnobs.slipCheckTickHeightRatio) .offset(x: side * SlipCheckKnobs.slipCheckTickOffsetXRatio, y: -side * SlipCheckKnobs.slipCheckTickOffsetYRatio) } } .frame(width: side, height: side) }}/// The sizes, counts and timings SlipCheck draws with: Swift's own, beside/// their reader — a theme sets only its tokens (`scale.tokens`).enumSlipCheckKnobs {staticlet slipCheckCornerRadius: CGFloat = 3staticlet slipCheckLineWidth: CGFloat = 1.5staticlet slipCheckTarget: CGFloat = 44staticlet slipCheckTickHeightRatio: CGFloat = 1.33staticlet slipCheckTickMinWidth: CGFloat = 2.5staticlet slipCheckTickOffsetXRatio: CGFloat = 0.17staticlet slipCheckTickOffsetYRatio: CGFloat = 0.33staticlet slipCheckTickWidthFraction: CGFloat = 0.12staticlet slipCheckTickWidthRatio: CGFloat = 1.22}