40 lines · 1.7 KB · SwiftRaw
// The hints row: the four kind words in typewriter, the guess underlined.import SwiftUI/// "todo · event · note · person", the guess wearing a red pencil underline.struct CaptureKindHints: View { @Environment(\.theme) private var theme let text: String private var guess: CaptureKindGuess? { CaptureKindGuess.guess(text) } var body: some View { HStack(spacing: 0) { ForEach(Array(CaptureKindGuess.row.enumerated()), id: \.element.rawValue) { index, kind in if index > 0 { Text(" · ") .paperBody(13.5, ink: .pencil) } Text(kind.rawValue) .paperBody(13.5, ink: kind == guess ? .ink : .pencil) .overlay(alignment: .bottom) { if kind == guess { PencilUnderline(seed: "hint-\(kind.rawValue)", theme: theme) .stroke(theme.print(.red), style: StrokeStyle(lineWidth: 1.3, lineCap: .round)) .frame(height: 5) .offset(y: 3) .blendMode(theme.printBlend) .accessibilityHidden(true) } } .accessibilityIdentifier("capture-hint-\(kind.rawValue)") } Spacer(minLength: 0) } .animation(.easeOut(duration: 0.18), value: guess) .accessibilityElement(children: .combine) .accessibilityLabel(guess.map { ShellLines.line("capture", "hints.looks_like", ["kind": $0.rawValue]) } ?? ShellLines.line("capture", "hints.label")) .accessibilityIdentifier("capture-hints") }}