Cotton code
123 lines · 5.2 KB · SwiftRaw
// What a kind is called.//// A kind wears NO colour (the constitution's rule): identity is a glyph and a// word in quiet ink.import Foundation/// Every kind a badge or a mark can name.////// The first ten are the ROUTED kinds — what filing a thought can produce. The/// rest are kinds the router cannot create but a screen still shows; they will/// never move into the routed table, so they are declared here beside it rather/// than pretending to be routable.public enum BadgeKind: String, CaseIterable, Sendable {    // Routed    case todo    case event    case note    case journal    case personNote = "person_note"    case location    case page    case transaction    case mood    case sessionMessage = "session_message"    // Borrowed    case person    case thought    case meeting    case document    case newsEdition = "news_edition"    case photo    case video    case secret    case repository    case pull    case issue    case decision    case emailThread = "email_thread"    /// The kinds filing a thought can produce.    public static let routed: [BadgeKind] = [        .todo, .event, .note, .journal, .personNote, .location, .page, .transaction, .mood,        .sessionMessage,    ]    /// The SF Symbol this kind wears. The phone names a Lucide glyph; the    /// nearest system symbol is used here rather than shipping an icon set,    /// because the app loads no font and no asset it does not need.    public var symbol: String {        switch self {        case .todo: return "checkmark.circle"        case .event: return "calendar"        case .note: return "note.text"        case .journal: return "book"        case .personNote: return "person.crop.circle"        case .location: return "mappin.and.ellipse"        case .page: return "text.book.closed"        // A banknote, not one country's currency sign: a money record is in        // whatever currency its account holds.        case .transaction: return "banknote"        case .mood: return "face.smiling"        // The paper plane: a message SENT somewhere, which is what the record        // is — not an inbox, which would say it arrived here.        case .sessionMessage: return "paperplane"        case .person: return "person"        case .thought: return "tray"        case .meeting: return "mic"        case .document: return "doc.text"        case .newsEdition: return "newspaper"        case .photo: return "photo"        case .video: return "video"        case .secret: return "key"        case .repository: return "shippingbox"        case .pull: return "arrow.triangle.pull"        case .issue: return "exclamationmark.circle"        case .decision: return "checkmark.seal"        case .emailThread: return "envelope"        }    }    /// What filing PRODUCES, said the way the owner would say it — never the    /// table's name. "Person note", not "Person": it writes a note onto a    /// person who already exists rather than making a contact out of a    /// sentence. "Money", not "Transaction". "Sent to a session", not "Session    /// message".    public var label: String {        switch self {        case .todo: return ShellLines.line("format", "mark.todo")        case .event: return ShellLines.line("format", "mark.event")        case .note: return ShellLines.line("format", "mark.note")        case .journal: return ShellLines.line("format", "mark.journal")        case .personNote: return ShellLines.line("format", "mark.person_note")        case .location: return ShellLines.line("format", "mark.location")        case .page: return ShellLines.line("format", "mark.page")        case .transaction: return ShellLines.line("format", "mark.transaction")        case .mood: return ShellLines.line("format", "mark.mood")        // The app's one spelling of it, shared with the session screens.        case .sessionMessage: return CottonStrings.sentToASession        case .person: return ShellLines.line("format", "mark.person")        case .thought: return ShellLines.line("format", "mark.thought")        case .meeting: return ShellLines.line("format", "mark.meeting")        case .document: return ShellLines.line("format", "mark.document")        case .newsEdition: return ShellLines.line("format", "mark.news_edition")        case .photo: return ShellLines.line("format", "mark.photo")        case .video: return ShellLines.line("format", "mark.video")        case .secret: return ShellLines.line("format", "mark.secret")        case .repository: return ShellLines.line("format", "mark.repository")        case .pull: return ShellLines.line("format", "mark.pull")        case .issue: return ShellLines.line("format", "mark.issue")        case .decision: return ShellLines.line("format", "mark.decision")        case .emailThread: return ShellLines.line("format", "mark.email_thread")        }    }    /// What a kind is called when all the screen has is the stored word.    ///    /// A kind this build has a label for wears it; one it has not — a kind a    /// newer build added — is read out as words rather than drawn as stored.    public static func label(forKind kind: String) -> String {        BadgeKind(rawValue: kind)?.label ?? PlainWords.sentence(kind) ?? "Record"    }}