vOOice/VoiceInk/Views/Settings/EnhancementShortcutsView.swift
Beingpax ae387ad351 Improve API key management UI and enhance provider integration layout
- Reorganize provider connection status display
- Add visual separators between sections for better clarity
- Improve OpenRouter model picker with inline refresh button
- Enhance API key input styling with rounded borders
- Optimize Ollama configuration layout for consistency
- Refine button positioning and spacing throughout
2026-01-05 11:15:11 +05:45

132 lines
4.5 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import SwiftUI
import KeyboardShortcuts
struct EnhancementShortcutsView: View {
@ObservedObject private var shortcutSettings = EnhancementShortcutSettings.shared
var body: some View {
VStack(spacing: 8) {
// Toggle AI Enhancement
HStack(alignment: .center, spacing: 12) {
HStack(spacing: 4) {
Text("Toggle AI Enhancement")
.font(.system(size: 13))
InfoTip(
title: "Toggle AI Enhancement",
message: "Quickly enable or disable AI enhancement while recording. Available only when VoiceInk is running and the recorder is visible.",
learnMoreURL: "https://tryvoiceink.com/docs/enhancement-shortcuts"
)
}
Spacer()
HStack(spacing: 10) {
HStack(spacing: 4) {
KeyChip(label: "")
KeyChip(label: "E")
}
Toggle("", isOn: $shortcutSettings.isToggleEnhancementShortcutEnabled)
.toggleStyle(.switch)
.labelsHidden()
}
}
// Switch Enhancement Prompt
HStack(alignment: .center, spacing: 12) {
HStack(spacing: 4) {
Text("Switch Enhancement Prompt")
.font(.system(size: 13))
InfoTip(
title: "Switch Enhancement Prompt",
message: "Switch between your saved prompts using ⌘1 through ⌘0 to activate the corresponding prompt in the order they are saved. Available only when VoiceInk is running and the recorder is visible.",
learnMoreURL: "https://tryvoiceink.com/docs/enhancement-shortcuts"
)
}
Spacer()
HStack(spacing: 4) {
KeyChip(label: "")
KeyChip(label: "1 0")
}
}
}
.background(Color.clear)
}
}
struct EnhancementShortcutsSection: View {
@State private var isExpanded = false
var body: some View {
VStack(spacing: 0) {
Button {
withAnimation(.spring(response: 0.35, dampingFraction: 0.85)) {
isExpanded.toggle()
}
} label: {
HStack(spacing: 12) {
Text("Enhancement Shortcuts")
.font(.headline)
.foregroundColor(.primary)
Spacer()
Image(systemName: "chevron.down")
.rotationEffect(.degrees(isExpanded ? 0 : -90))
.foregroundColor(.secondary)
.font(.system(size: 13, weight: .medium))
}
.padding(.horizontal, 16)
.padding(.vertical, 12)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
if isExpanded {
Divider()
.transition(.opacity)
EnhancementShortcutsView()
.padding(.horizontal, 16)
.padding(.vertical, 12)
.transition(
.asymmetric(
insertion: .opacity.combined(with: .scale(scale: 0.98, anchor: .top)),
removal: .opacity
)
)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.background(CardBackground(isSelected: false))
}
}
// MARK: - Supporting Views
private struct KeyChip: View {
let label: String
var body: some View {
Text(label)
.font(.system(size: 12, weight: .medium, design: .monospaced))
.foregroundColor(.primary)
.padding(.horizontal, 8)
.padding(.vertical, 4)
.background(
RoundedRectangle(cornerRadius: 4, style: .continuous)
.fill(Color(NSColor.controlBackgroundColor))
)
.overlay(
RoundedRectangle(cornerRadius: 4, style: .continuous)
.strokeBorder(
Color(NSColor.separatorColor).opacity(0.5),
lineWidth: 0.5
)
)
}
}