1bdb8824ac
Add preset-driven polish scenarios (Settings, onboarding, ScenarioChip) with ScenarioPrompt and style directives; drive keyboard height from content (240pt) and use viewIsAppearing encapsulated-height offset for smoother keyboard switches; remove redundant StatusBadge and hide system dictation via hasDictationKey.
60 lines
1.9 KiB
Swift
60 lines
1.9 KiB
Swift
// ScenarioChip.swift
|
|
// OSGKeyboard · Keyboard Extension
|
|
//
|
|
// Compact chip on the keyboard top bar for quick polish scenario
|
|
// switching. Same Menu pattern as `TranslationChip`.
|
|
|
|
import SwiftUI
|
|
import OSGKeyboardShared
|
|
|
|
struct ScenarioChip: View {
|
|
@Environment(\.themePalette) private var palette: ThemePalette
|
|
|
|
@ObservedObject var state: KeyboardViewController.State
|
|
|
|
var body: some View {
|
|
Menu {
|
|
ForEach(PolishScenarioCatalog.all) { scenario in
|
|
Button {
|
|
state.setPolishScenarioId(scenario.id)
|
|
} label: {
|
|
if scenario.id == state.polishScenarioId {
|
|
Label(displayLabel(for: scenario), systemImage: "checkmark")
|
|
} else {
|
|
Text(displayLabel(for: scenario))
|
|
}
|
|
}
|
|
}
|
|
} label: {
|
|
label
|
|
}
|
|
.menuStyle(.button)
|
|
.accessibilityLabel(ExtL10n.text("keyboard.scenario.a11y"))
|
|
.accessibilityHint(ExtL10n.text("keyboard.scenario.a11yHint"))
|
|
}
|
|
|
|
private var label: some View {
|
|
HStack(spacing: 4) {
|
|
Image(systemName: "text.bubble")
|
|
Text(chipText)
|
|
Image(systemName: "chevron.down")
|
|
.font(.system(size: 8, weight: .bold))
|
|
}
|
|
.font(TypeStyle.caption2)
|
|
.foregroundStyle(palette.textPrimary)
|
|
.padding(.horizontal, Spacing.xs + 2)
|
|
.padding(.vertical, 6)
|
|
.frame(minHeight: 28)
|
|
.background(palette.surfaceElevated, in: Capsule())
|
|
.overlay(Capsule().stroke(palette.divider, lineWidth: 0.5))
|
|
}
|
|
|
|
private var chipText: String {
|
|
PolishScenarioCatalog.chipLabel(for: state.polishScenarioId)
|
|
}
|
|
|
|
private func displayLabel(for scenario: PolishScenario) -> String {
|
|
PolishScenarioCatalog.displayName(for: scenario.id)
|
|
}
|
|
}
|