Cotton code
157 lines · 7.3 KB · SwiftRaw
// One glyph vocabulary, and one place the translation happens.//// Lucide names every icon in kebab-case; SwiftUI draws SF Symbols and names// them in dot-case. The tables here keep the LUCIDE names — the tool directory// (`HomeData.findTools`), the Asked of you rows, the settings rows and the add fan// all carry the icon name as data — and translating at the point of use would// put FIFTY hand-written SF names into tables whose whole purpose is that they// are the same tables the app already agreed. (Fifty is what the four carry// between them, counted: `GlyphTests` asserts the figure. The table below is// sixty-four, because the fourteen extra are the marks the views and the Find// sections name at their own point of use — the Fab's `plus`, the two corner// circles, the export and update pills, and the code-hosting four.)//// So: the tables stay in the app's own vocabulary and this is the ONE// translation. That also makes the swap auditable — a symbol nobody chose is a// symbol nobody can defend, and `GlyphTests` walks all four tables and fails on// any name this file does not answer, and on any SF name it answers WITH that// the system does not draw.//// **An unmapped name answers `nil`, and a view draws no glyph rather than a// wrong one.** Falling back on a question-mark symbol would put a visible// defect on a real screen and call it handled; falling back on a plausible// neighbour would be worse, because nobody would ever notice. The test is what// makes `nil` unreachable in practice.import Foundationpublic enum Glyph {    /// The SF Symbol for a lucide name, or `nil` when this app has not chosen    /// one. See the header for why `nil` is not a fallback.    public static func symbol(_ lucide: String) -> String? { table[lucide] }    /// Every lucide name the phone's tables carry, with the symbol chosen for    /// it. Alphabetical, so a diff reads as one line.    ///    /// Where two lucide names would collapse onto one symbol they are pulled    /// apart deliberately: `message-square` (a chat thread) and    /// `message-circle` (an assistant's question) sit on the same screen and    /// must not become the same picture here.    static let table: [String: String] = [        "alarm-clock": "alarm",        // The Imports tool's: what was brought into the database, boxed.        "archive": "archivebox",        "arrow-up": "arrow.up",        // The update banner's pill. Lucide's `arrow-up-circle` is the same        // picture SF draws for `arrow.up.circle`.        "arrow-up-circle": "arrow.up.circle",        "arrow-up-right": "arrow.up.right",        "at-sign": "at",        "audio-lines": "waveform",        "bell": "bell",        "book-open": "book",        "book-open-text": "book.pages",        "bot": "cpu",        "brain": "brain",        // The Birthdays switch on `/settings#notifications`.        "cake": "birthday.cake",        // The capture fan's Camera row — a photograph taken onto the thought.        "camera": "camera",        "calendar": "calendar",        "calendar-check": "calendar.badge.checkmark",        "calendar-clock": "calendar.badge.clock",        "calendar-days": "calendar",        "check": "checkmark",        "circle-alert": "exclamationmark.circle",        // The Todo-reminders switch on `/settings#notifications`, among others.        "circle-check": "checkmark.circle",        "circle-dashed": "circle.dashed",        "circle-user": "person.crop.circle",        "clapperboard": "film",        // The update banner's mark. `cloud.slash` and NOT `icloud.slash`: the        // sentence beside it is about the person's OWN server refusing this        // build, and iCloud's cloud would name somebody else's service.        "cloud-off": "icloud.slash",        "code": "chevron.left.forwardslash.chevron.right",        "database": "cylinder",        "eye": "eye",        "file-text": "doc.text",        "file-up": "arrow.up.doc",        "file-warning": "exclamationmark.triangle",        "folder-open": "folder",        "git-pull-request": "arrow.triangle.pull",        "hard-drive": "internaldrive",        "headset": "headphones",        // Find's "Recent" rows — the searches this phone remembers.        "history": "clock.arrow.circlepath",        "image": "photo",        "images": "photo.on.rectangle",        "inbox": "tray",        "info": "info.circle",        // The Passwords row. Lucide's `key-round` and SF's `key` are the same        // picture; `lock` would name the vault's state rather than what a row        // of it holds.        "key-round": "key",        "keyboard": "keyboard",        // A settings card's marks are all-or-none: a `nil` here drops the 36pt        // icon inset under one row and leaves its label and hairline standing        // left of the others.        "layout-grid": "square.grid.2x2",        // Everything (Spec 9.3): every table of the database, a shelf of them.        "library": "books.vertical",        "lightbulb": "lightbulb",        // The finishing spinner in the composer's dictation control. It is the        // one place this app draws motion in a glyph, and it is the SAME        // picture as "sync is working" on purpose.        "link-2": "link",        "loader": "arrow.triangle.2.circlepath",        // lucide `log-out`. SF's name reads backwards and is the right mark:        // an arrow leaving a frame.        "log-out": "rectangle.portrait.and.arrow.right",        "mail": "envelope",        "map-pin": "mappin.and.ellipse",        "map-pin-off": "mappin.slash",        "message-circle": "message",        "message-circle-warning": "exclamationmark.bubble",        "message-square": "bubble.left",        "message-square-plus": "plus.bubble",        "mic": "mic",        "monitor-smartphone": "laptopcomputer.and.iphone",        "newspaper": "newspaper",        "notebook-text": "note.text",        "pencil": "pencil",        "phone": "phone",        // The Connections tool's: what Cotton keeps reading from outside.        "plug": "powerplug",        "plus": "plus",        "qr-code": "qrcode",        "quote": "quote.opening",        "refresh-cw": "arrow.triangle.2.circlepath",        "search": "magnifyingglass",        "settings-2": "gearshape",        // The verb "send this somewhere yourself" — the export card's action.        "share": "square.and.arrow.up",        "smartphone": "iphone",        // Find's Decisions section — the same mark the project page's own        // Decisions section wears (`ProjectFacts`), so the two never differ.        "signpost": "signpost.right",        "smile": "face.smiling",        "sparkles": "sparkles",        // The dictation STOP. Lucide's `square` is the filled stop every        // recorder draws; SF's outline would read as an empty checkbox        // inside a filled disc, so the fill is chosen deliberately.        "square": "square.fill",        "square-pen": "square.and.pencil",        "tag": "tag",        "target": "target",        // Find's two session sections — a session is a terminal a person        // talks to, and it is the mark the tool directory already uses.        "terminal": "terminal",        "trash-2": "trash",        "user-plus": "person.crop.circle.badge.plus",        "users": "person.2",        "video": "video",        "wallet": "creditcard",        "x": "xmark",    ]}