// Every word Cotton Meetings shows is a kit line (`kits/shell/lines/ // meetings.json`). This is the one reader, so a screen never spells English. #if os(iOS) import CottonKit import CottonValues import Foundation enum MeetingsWords { static func line(_ path: String, _ fills: [String: String] = [:]) -> String { ShellLines.line("meetings", path, fills) } /// What the recorder is doing, in a few words. static func headline(_ stage: MeetingRecorderStage, kind: MeetingKind) -> String { switch stage { case .recording: return line(kind == .memo ? "recorder.recording_memo" : "recorder.recording") case .paused(.person): return line("recorder.paused") case .paused(.interruption): return line("recorder.silenced") case .asking, .opening: return line("recorder.starting") case .finishing: return line("recorder.finishing") case .saving: return line("recorder.filing") case .failed(let why): return line("recorder.failed", ["why": why]) case .blocked: return line("recorder.no_microphone") case .idle, .saved: return "" } } /// The status line a meeting card carries. `onThisPhone`: this phone is /// the one transcribing it now. static func status(_ status: MeetingStatus, phoneMayTranscribe: Bool, onThisPhone: Bool = false) -> String { switch status { case .recording: return line("status.recording") case .waiting: return line(phoneMayTranscribe ? "status.waiting" : "status.waiting_charge") case .transcribing: return line(onThisPhone ? "status.transcribing_phone" : "status.transcribing") case .ready: return line("status.ready") case .failed(let why): guard let why, !why.isEmpty else { return line("status.failed_plain") } // The core says why by a word of the set's `why.*`. return line("status.failed", ["why": ShellLines.shipped("meetings", "why.\(why)") ?? why]) } } /// A meeting's title, or its dated stand-in. static func title(_ row: MeetingRow) -> String { if let title = row.title, !title.isEmpty { return title } let day = row.startedAt.map { $0.formatted(date: .abbreviated, time: .shortened) } ?? "" return line(row.kind == .memo ? "home.untitled_memo" : "home.untitled_meeting", ["day": day]) } /// A length as a clock: 4:05, 1:02:07. static func clock(_ ms: Double) -> String { let total = max(0, Int(ms / 1000)) let hours = total / 3600, minutes = (total % 3600) / 60, seconds = total % 60 return hours > 0 ? String(format: "%d:%02d:%02d", hours, minutes, seconds) : String(format: "%d:%02d", minutes, seconds) } } #endif