// The one empty/notice state, and the one skeleton.//// `QuietState` is a THIN WRAPPER over the kit's one empty state (phase 20,// 2026-09-14): a blank sheet — `ObjectEmpty(sheet:)`, picture 37 — with the// title as its first typed line, the sentence as its second, and AT MOST ONE// forward verb. Omitting the verb's closure types it as a statement (a sent// state) rather than drawing a control that does nothing. A screen that holds// something other than sheets (people, photos, projects) passes its own blank// object to `ObjectEmpty` directly.//// A TOOL'S EMPTY LIST STANDS ITS OWN PICTURE (walker294 rows 84, 108–110:// Members and Social read "No … yet" under a blank grey card that said// nothing about the tool). Given the definition's `picture`, the empty state// draws that object — the stories' bundle, the guest book — in place of the// blank sheet; with none it keeps the sheet.//// `SkeletonText` is the other half of this file. A screen's loading state is a// SKELETON behind `isLoading`, never a spinner: the shape of what is coming is// information, and a spinner is not. On paper the shape is blank paper — slips// at the size of the lines that are coming, or pencil-ruled lines when the// skeleton already stands on a sheet.importCottonValuesimportSwiftUI/// What a `QuietState` hands the empty state — pure, so a test can read it.structQuietStateLines: Equatable {let line1: Stringlet line2: String?let actionLabel: String?/// A verb with no closure is a statement, not a control.let isStatement: Boolinit(title: String, message: String, actionLabel: String?, hasAction: Bool) { line1 = title// An empty sentence is no second line, not a blank one. line2 = message.isEmpty ? nil : messageself.actionLabel = actionLabel isStatement = actionLabel != nil && !hasAction }}publicstructQuietState: View {privatelet lines: QuietStateLines/// The action's own name, which is a SEPARATE identifier from the state's/// — every caller passes `<state>-retry`. A retry a test cannot press by/// name is a retry no test presses.privatelet actionIdentifier: String?privatelet action: (() -> Void)?/// The tool's own picture and name, stood in place of the blank sheet.privatelet picture: ToolPicture?privatelet name: Stringpublicinit( title: String, message: String, actionLabel: String? = nil, actionIdentifier: String? = nil, picture: ToolPicture? = nil, name: String = "", action: (() -> Void)? = nil ) {self.lines = QuietStateLines( title: title, message: message, actionLabel: actionLabel, hasAction: action != nil)self.actionIdentifier = actionIdentifierself.picture = pictureself.name = nameself.action = action }publicvar body: someView {Group {iflet picture {ObjectEmpty( object: ToolObject(name: name, picture: picture, printing: .contentOnly) .frame(height: QuietStateKnobs.pictureSide), line1: lines.line1, line2: lines.line2, actionLabel: lines.actionLabel, actionIdentifier: actionIdentifier, action: action ) } else {ObjectEmpty( sheet: .cream, line1: lines.line1, line2: lines.line2, actionLabel: lines.actionLabel, actionIdentifier: actionIdentifier, action: action ) } } .padding(.horizontal, 28) }}/// The sizes QuietState draws with: Swift's own, beside their reader.enumQuietStateKnobs {/// The tool's picture stands in the blank sheet's height.staticlet pictureSide: CGFloat = 108}/// A skeleton is shown only when the answer is SLOW.////// A `read.*` over the local file answers in single-digit milliseconds, and a/// skeleton painted on a screen's first frame — before the read has even been/// asked — is a flash of grey bars over an answer that was about to arrive./// Every skeleton on the phone is therefore invisible for its first/// `SkeletonRule.delay` and paints only if it is still standing after that:/// an answer that lands inside the window never presents one, and a slow one/// (the first open after a restore, a page behind a fold) says "reading" as/// it should. Applied INSIDE the skeleton components rather than at each of/// the hundred call sites, so a screen cannot forget it.////// The number: a local answer is milliseconds — `read.people` in 3 ms, two/// hundred messages in 32 ms, measured on the Mac over the owner's own file —/// a frame is 16, and the perceptual floor for "something is happening" is/// about 100. Under that a skeleton reads as flicker; at about 200 a page that/// has drawn nothing starts to read as stuck. So the window is 150 (architect,/// 11 Oct): every local answer lands inside it many times over — reads no/// longer queue behind one connection, so a board's tiles do not push the/// list's answer out of it — and only a read that is genuinely slow — the/// first open after a restore, a page behind a fold — ever presents one. One/// constant for the whole phone, which the board's first draw waits no longer/// than either (`BoardSurface.read`); `SkeletonRuleTests` holds it.enumSkeletonRule {publicstaticlet delay: Duration = .milliseconds(150)}/// Invisible until it has stood for `SkeletonRule.delay`, keeping its layout/// so the content that replaces it does not jump. The two skeleton components/// below wear it, and ONLY they do: `SkeletonSweepTests` holds that the/// modifier is spelled nowhere else and that every `skeleton` a screen draws/// is one of the two — a hand-built skeleton is a hand-built chance to paint/// on the first frame.structSkeletonDelay: ViewModifier { @State privatevar due = falsefunc body(content: Content) -> someView { content .opacity(due ? 1 : 0) .task {try? awaitTask.sleep(for: SkeletonRule.delay)guard !Task.isCancelled else { return } due = true } }}extensionView {/// A skeleton that waits `SkeletonRule.delay` before it paints.func skeletonDelayed() -> someView { modifier(SkeletonDelay()) }}/// The one page-shaped skeleton: a few paragraphs of `SkeletonText`, so every/// screen waits under the same shape and the same delay.////// It replaced a skeleton per screen — blank cards at half opacity shaped like/// each list's own cells — most of which forgot the delay and painted on the/// first frame. The skeleton is a RARE fallback now (`AnswerCache` seeds a/// screen the person has been to; a first visit answers inside the window),/// and a fallback nobody should see is not worth a shape per screen.publicstructSkeletonPage: View {privatelet rows: Intprivatelet identifier: String?/// - Parameters:/// - rows: how many two-line paragraphs stand in — a list's worth./// - identifier: the accessibility identifier a screen's tests look for.publicinit(rows: Int = 4, identifier: String? = nil) {self.rows = rowsself.identifier = identifier }publicvar body: someView { VStack(alignment: .leading, spacing: 20) {ForEach(0..<max(1, rows), id: \.self) { _ inSkeletonText(lines: 2) } } .padding(.top, 8) .frame(maxWidth: .infinity, alignment: .leading) .accessibilityElement(children: .ignore) .accessibilityIdentifier(identifier ?? "skeleton-page") }}publicstructSkeletonText: View {privatelet lines: Intprivatelet lineWidth: CGFloatprivatelet lastLineWidth: CGFloatprivatelet lineHeight: CGFloat @Environment(\.isOnPaper) privatevar isOnPaper @Environment(\.theme) privatevar theme/// - Parameters:/// - lineWidth: the fraction every line but the last takes. A paragraph/// skeleton wants full-width lines with a short last one; a skeleton/// standing in for a LIST of short things (a project name) wants every/// bar the same short width/// - lineHeight: the bar's height. The default is a body line; a row of/// `rowTitle` text is 20 (`h-5`).publicinit( lines: Int = 2, lastLineWidth: CGFloat = 0.45, lineWidth: CGFloat = 1, lineHeight: CGFloat = 14 ) {self.lines = linesself.lastLineWidth = lastLineWidthself.lineWidth = lineWidthself.lineHeight = lineHeight }/// The fraction line `index` of `lines` takes.staticfunc width(index: Int, lines: Int, lineWidth: CGFloat, lastLineWidth: CGFloat) -> CGFloat { index == max(1, lines) - 1 ? lastLineWidth : lineWidth }publicvar body: someView { VStack(alignment: .leading, spacing: 8) {ForEach(0..<max(1, lines), id: \.self) { index in bar(index) .frame(height: lineHeight) .frame(maxWidth: .infinity, alignment: .leading) .scaleEffect( x: SkeletonText.width( index: index, lines: lines, lineWidth: lineWidth, lastLineWidth: lastLineWidth), y: 1, anchor: .leading ) } } .accessibilityHidden(true) .skeletonDelayed() }/// A blank slip of paper at the line's size — or, already on a sheet, a/// pencil rule where the line will be typed. @ViewBuilder privatefunc bar(_ index: Int) -> someView {if isOnPaper {PencilRule(seed: "skeleton-\(index)", theme: theme) .stroke(theme.print(.pencil), lineWidth: 1) .blendMode(theme.printBlend) .opacity(0.5) } else {PaperSurface(dye: .cream, edge: .cut, seed: "skeleton-\(index)") .modifier(PaperLift(shadow: .resting)) } }}