// The one empty state: a blank object of the screen's own kind, and two typed// lines.//// It replaced the accent disc with a glyph in it (the retired// `EmptyStateMedallion`), which was the old design system's answer and is a// badge rather than a thing.// A screen of notes that has no notes shows an empty SHEET; a screen of people// with nobody in it shows an empty PRINT; a board with no projects shows a bare// cap — each of which says what the screen would hold without anybody reading a// word. The words are then short, typed, and about what to do next.//// The object is passed in rather than chosen here, because only the screen knows// what it holds; `ObjectEmpty.sheet` and `.print` are the two the kit can make// on its own.importSwiftUIpublicstructObjectEmpty<Object: View>: View { @Environment(\.theme) privatevar themeprivatelet object: Objectprivatelet line1: Stringprivatelet line2: String?privatelet actionLabel: String?privatelet actionIdentifier: String?privatelet action: (() -> Void)?/// Under a project scope the first line says what the list is empty OF/// (Mac redesign spec §4) — "Nothing in Garden yet" — rather than the/// screen's own words for an empty workspace. Empty on the phone. @Environment(\.cottonProjectScope) privatevar scope/// - Parameters:/// - actionLabel: the one forward verb. With no `action` it is a/// STATEMENT — typed under the lines, not a control ("Sent")./// - actionIdentifier: the verb's own accessibility identifier, separate/// from the state's, so a test can press it by name.publicinit( object: Object, line1: String, line2: String? = nil, actionLabel: String? = nil, actionIdentifier: String? = nil, action: (() -> Void)? = nil ) {self.object = objectself.line1 = line1self.line2 = line2self.actionLabel = actionLabelself.actionIdentifier = actionIdentifierself.action = action }publicvar body: someView { VStack(spacing: ObjectEmptyKnobs.objectEmptyActionGap) {// The object and its words are ONE element to a screen reader; the// verb under them stays its own, or nobody could press it by name. VStack(spacing: ObjectEmptyKnobs.objectEmptyObjectGap) { object .frame(maxWidth: ObjectEmptyKnobs.objectEmptyObjectMaxWidth) .opacity(Double(ObjectEmptyKnobs.objectEmptyObjectOpacity))// **BOTH LINES ARE THE SECONDARY INK.** The second was the// tertiary (#ABABAB), which on the paper ground (#EEE3D6) is// under 2:1 — the Mac walk read the /code empty state's two// lines as "very low contrast" (finding 23), and every empty// state in the app draws through here. What separates the// lines is the SIZE; the tertiary ink is for a mark beside// something, not for a sentence somebody has to read. VStack(spacing: ObjectEmptyKnobs.objectEmptyLineGap) {Text(ScopeWording.nothingIn(scope.map(\.name)) ?? line1) .font(theme.type.body(theme.scale.bodySize + 1)) .foregroundStyle(theme.colors.inkSecondary.color)iflet line2 {Text(line2) .font(theme.type.body(theme.scale.bodySize - 1)) .foregroundStyle(theme.colors.inkSecondary.color) } } .multilineTextAlignment(.center) } .accessibilityElement(children: .combine)iflet actionLabel {iflet action {Button(actionLabel, action: action) .buttonStyle(MotionButtonStyle()) .font(theme.type.body(theme.scale.bodySize)) .foregroundStyle(theme.colors.accent.color) .frame(minHeight: ObjectEmptyKnobs.objectEmptyActionMinHeight) .accessibilityIdentifier(actionIdentifier ?? "") } else {Text(actionLabel) .font(theme.type.body(theme.scale.bodySize)) .foregroundStyle(theme.colors.inkSecondary.color) } } } .frame(maxWidth: .infinity) .padding(.vertical, ObjectEmptyKnobs.objectEmptyVerticalPadding) }}/// The blank sheet an empty paper screen shows. Its own view rather than an/// erased one: `AnyView` is the route table's alone (`NavigationTests`), and a/// concrete type is what lets `ObjectEmpty.init(sheet:)` below be a constrained/// initialiser rather than a factory that throws away its type.structEmptySheet: View { @Environment(\.theme) privatevar themeprivatelet dye: PaperDyeprivatelet edge: PaperEdgepublicinit(dye: PaperDye = .cream, edge: PaperEdge = .cut) {self.dye = dyeself.edge = edge }publicvar body: someView {PaperSurface(dye: dye, edge: edge, seed: "empty") .frame(height: ObjectEmptyKnobs.objectEmptySheetHeight) .modifier(PaperLift(shadow: PaperShadow.resting)) }}extensionObjectEmptywhereObject == EmptySheet {/// An empty sheet — for a screen that holds paper.init( sheet dye: PaperDye = .cream, edge: PaperEdge = .cut, line1: String, line2: String? = nil, actionLabel: String? = nil, actionIdentifier: String? = nil, action: (() -> Void)? = nil ) {self.init( object: EmptySheet(dye: dye, edge: edge), line1: line1, line2: line2, actionLabel: actionLabel, actionIdentifier: actionIdentifier, action: action ) }}extensionObjectEmptywhereObject == EmptyPrint {/// An empty print — for a screen that holds photographs.publicinit( print seed: String = "empty", line1: String, line2: String? = nil, actionLabel: String? = nil, action: (() -> Void)? = nil ) {self.init( object: EmptyPrint(seed: seed, size: .grid), line1: line1, line2: line2, actionLabel: actionLabel, action: action ) }}/// The sizes, counts and timings ObjectEmpty draws with: Swift's own, beside/// their reader — a theme sets only its tokens (`scale.tokens`).enumObjectEmptyKnobs {staticlet objectEmptyActionGap: CGFloat = 18staticlet objectEmptyActionMinHeight: CGFloat = 44staticlet objectEmptyLineGap: CGFloat = 6staticlet objectEmptyObjectGap: CGFloat = 18staticlet objectEmptyObjectMaxWidth: CGFloat = 168staticlet objectEmptyObjectOpacity: CGFloat = 0.85staticlet objectEmptySheetHeight: CGFloat = 108staticlet objectEmptyVerticalPadding: CGFloat = 34}