// The record button's toast (lane voiceline, architect 16 Oct 2026, from the // owner's 286 report; smooth, owner 02:20 IST 16 Oct 2026: no live // transcript; architect 21:05 IST 16 Oct 2026: no caption under the fan). // // At rest the bottom is bare: nothing is drawn between the caps' foot and the // record button, on any database. While the person speaks nothing is drawn — // the button's pulse is the listening. After the words are taken ONE toast // says what was understood and what happened ("Saved as a thought · Undo", // "Opened People", "Nothing came through"), then goes. It stands at the toast // edge, the top of the screen (`atToastEdge`, the owner 17 Nov 2026: every // toast at the top, never over the fan), never inside the record button's // bottom inset, which is clipped and cut it to a sliver (the owner's 289 // screenshots). // Every line is the thought definition's `voice` words. One line // (`voice_line_lines`): a toast too long for it keeps its start and fades its // end (`voice_line_fade`). import SwiftUI /// What the record button's toast says now, and its act: a kept thought's /// Undo, a refused microphone's Open Settings. `FanRecord` says it; the fan /// draws it above itself (`FanToastKey`). struct FanToast: Equatable, @unchecked Sendable { let words: String var act: Act? struct Act { let label: String let run: () -> Void } static func == (lhs: FanToast, rhs: FanToast) -> Bool { lhs.words == rhs.words && lhs.act?.label == rhs.act?.label } } /// The record button's toast, handed up from the button to the board, which /// hands it to the fan to draw in the page region. struct FanToastKey: PreferenceKey { static let defaultValue: FanToast? = nil static func reduce(value: inout FanToast?, nextValue: () -> FanToast?) { value = value ?? nextValue() } } struct FanVoiceLine: View { let toast: FanToast @Environment(\.theme) private var theme /// The line's height: its lines of the words' size, with the words' /// own room above and below. static func height(scale: ThemeScale) -> Double { Double(scale[.voiceLineLines]) * Double(scale[.fanRecordPillSize] + scale[.fanRecordPillPad]) } var body: some View { let scale = theme.scale HStack(spacing: scale[.fanCapsGap]) { // A short line stands centred; a long one keeps its start and // fades its end, inside the line's own width. ViewThatFits(in: .horizontal) { text Color.clear .overlay(alignment: .leading) { text } .clipped() .mask(fade) } .frame(maxWidth: .infinity) if let act = toast.act { Button(act.label) { act.run() } .font(theme.type.body(scale[.fanRecordHintSize])) .foregroundStyle(theme.colors.accent.color) .accessibilityIdentifier("fan-record-undo") } } .frame(height: Self.height(scale: scale)) .padding(.horizontal, scale[.fanRecordPillPad]) .frame(maxWidth: .infinity) // The words stand on a strip of the pill's paper stock, so they read // over whatever the page draws at its foot. .background { Capsule() .fill(SearchGrammar.fill) .overlay(Capsule().strokeBorder(CottonColors.hairline, lineWidth: ComposerCardKnobs.chromeHairline)) } .cottonContentMargin() .accessibilityElement(children: .combine) .accessibilityIdentifier("fan-voice-line") } /// The line's words: one line at their natural width, never wrapped. private var text: some View { let scale = theme.scale return Text(toast.words) .font(theme.type.hand(scale[.fanRecordPillSize])) .foregroundStyle(theme.colors.ink.color) .lineLimit(Int(scale[.voiceLineLines])) .fixedSize(horizontal: true, vertical: false) } /// The line's end dissolves over `voice_line_fade` points. private var fade: some View { HStack(spacing: 0) { Color.black LinearGradient(colors: [.black, .clear], startPoint: .leading, endPoint: .trailing) .frame(width: theme.scale[.voiceLineFade]) } } } /// The record button's lines: the thought definition's `voice` words. public typealias VoiceWords = DefinitionVoiceWords extension DefinitionVoiceWords { /// The database's thought definition's lines; blank where no tool draws /// thoughts there. static func reading(_ definitions: TableDefinitions) -> VoiceWords { definitions.playing(.thought)?.voice ?? VoiceWords(_generated: (), saved: "", undo: "", undone: "", opened: "{name}", back: "", ran: "", nothing: "", denied: "", settings: "") } /// "Opened {name}", filled. func opened(_ name: String) -> String { opened.replacingOccurrences(of: "{name}", with: name) } }