// A screen's BOARD (design note 26203e21 §4): the parts Home, the Tools // screen and the database page draw, in order, from a CLOSED set. The board // is a synced row (`cotton_board_definitions`) the core answers through // `definitions.board` — a person's own row, or this build's shipped default — // so a layout change is a database change, never a build. // // The app reads no part of a board's format: the core resolves every setting // (`board::default_of`) and answers what each part draws // (`shell.today`'s `parts.board`, `BoardEntry`). A kind the core does not know // answers `unknown` and is passed over, never a blank screen and never a refusal. import CottonValues import Foundation import CottonKit public typealias BoardDefinition = DefinitionBoardDefinition extension DefinitionBoardDefinition { public init(id: String, parts: [BoardPart]) { self.init(_generated: (), id: id, parts: parts) } } public typealias BoardVariant = DefinitionBoardVariant /// One part of a board, as stored: its kind and its settings. What a part /// DRAWS is the core's answer (`shell.today`'s `parts.board`, `BoardEntry`). public typealias BoardPart = DefinitionBoardPart /// Which of a table's rows a `list` part keeps: those whose columns hold /// `filter` (`records.list`'s `where`), kept by the table's own date to /// `period` (`this_month`, `today`, `next_7_days`). Empty keeps every row. public struct BoardRowKeep: Hashable, Sendable { public var filter: [String: RecordValue] public var period: String? public init(filter: [String: RecordValue] = [:], period: String? = nil) { self.filter = filter self.period = period } public var keepsAll: Bool { filter.isEmpty && period == nil } } /// How the `tools` part lays out the tiles: a sideways row or a grid. Home /// draws its tiles as the grid whatever the part says: on the phone the fan /// under it is the frame's (`FanSurface.swift`), never the board's. public enum BoardToolsFace: String, Sendable { case row, grid } /// The notices a `notices` part can show — the closed set the app draws, /// each once (`BoardNotices`). The crate holds the same words /// (`cotton_core::definitions::board::NOTICE_KINDS`). public enum BoardNoticeKind: String, CaseIterable, Sendable { /// This build is older than the database needs. case update /// A held database's copy still arriving. case arriving /// A held database this device cannot read. case unreadable /// The off-Mac backup has stopped. case backup /// A device asking to join. case joinRequests /// What an assistant is working on. case workingOn /// The last read of the database was refused. case readRefusal /// A Mac that cannot be reached. case attention /// The chosen project's own page. case project } public enum BoardToolsSize: String, Sendable { case large, small } // ── This build's own boards ────────────────────────────────────────────── // // What a screen draws while its row is read, and when the read fails: the // boards the crate ships (`crates/cotton-core/kits/shell/boards/.json`), // as the core decoded them (`DefinitionCatalogue`) — never a Swift copy of a // board, and never this app's own read of the file. extension BoardDefinition { /// Every board this build ships, as the core handed them over. public static var shippedBoards: [BoardDefinition] { DefinitionCatalogue.shippedBoards.values.sorted { $0.id < $1.id } } /// Home: the head with its cap and its two tags, the notices, and the /// tools in the person's arrangement. public static var home: BoardDefinition { shipped("home") } /// The Tools screen: every tool as a tile, and About at the foot. public static var tools: BoardDefinition { shipped("tools") } /// The database page is Home, one database at a time. public static var database: BoardDefinition { shipped("database") } /// This build's own board for the screen `id`; Home's for an id it ships none for. /// A build whose core handed over no board at all draws an empty one — /// the open screen has already said why (`DefinitionCatalogue.receiveLastResort`). public static func shipped(_ id: String) -> BoardDefinition { let boards = shippedBoards return boards.first { $0.id == id } ?? boards.first { $0.id == "home" } ?? BoardDefinition(id: id, parts: []) } }