vOOice/VoiceInk/Views/EnhancementSettingsView.swift
2025-06-30 11:27:45 +05:45

120 lines
5.9 KiB
Swift

import SwiftUI
struct EnhancementSettingsView: View {
@EnvironmentObject private var enhancementService: AIEnhancementService
@State private var isEditingPrompt = false
@State private var isSettingsExpanded = true
@State private var selectedPromptForEdit: CustomPrompt?
var body: some View {
ScrollView {
VStack(spacing: 32) {
// Main Settings Sections
VStack(spacing: 24) {
// Enable/Disable Toggle Section
VStack(alignment: .leading, spacing: 12) {
HStack {
VStack(alignment: .leading, spacing: 4) {
HStack {
Text("Enable Enhancement")
.font(.headline)
InfoTip(
title: "AI Enhancement",
message: "AI enhancement lets you pass the transcribed audio through LLMS to post-process using different prompts suitable for different use cases like e-mails, summary, writing, etc.",
learnMoreURL: "https://www.youtube.com/@tryvoiceink/videos"
)
}
Text("Turn on AI-powered enhancement features")
.font(.caption)
.foregroundColor(.secondary)
}
Spacer()
Toggle("", isOn: $enhancementService.isEnhancementEnabled)
.toggleStyle(SwitchToggleStyle(tint: .blue))
.labelsHidden()
.scaleEffect(1.2)
}
HStack(spacing: 20) {
VStack(alignment: .leading, spacing: 4) {
Toggle("Clipboard Context", isOn: $enhancementService.useClipboardContext)
.toggleStyle(.switch)
.disabled(!enhancementService.isEnhancementEnabled)
Text("Use text from clipboard to understand the context")
.font(.caption)
.foregroundColor(enhancementService.isEnhancementEnabled ? .secondary : .secondary.opacity(0.5))
}
VStack(alignment: .leading, spacing: 4) {
Toggle("Context Awareness", isOn: $enhancementService.useScreenCaptureContext)
.toggleStyle(.switch)
.disabled(!enhancementService.isEnhancementEnabled)
Text("Learn what is on the screen to understand the context")
.font(.caption)
.foregroundColor(enhancementService.isEnhancementEnabled ? .secondary : .secondary.opacity(0.5))
}
}
}
.padding()
.background(CardBackground(isSelected: false))
// 1. AI Provider Integration Section
VStack(alignment: .leading, spacing: 16) {
Text("AI Provider Integration")
.font(.headline)
APIKeyManagementView()
.background(CardBackground(isSelected: false))
}
.padding()
.background(Color(.windowBackgroundColor).opacity(0.4))
.cornerRadius(10)
.opacity(enhancementService.isEnhancementEnabled ? 1.0 : 0.6)
// 3. Enhancement Modes & Assistant Section
VStack(alignment: .leading, spacing: 16) {
Text("Enhancement Prompt")
.font(.headline)
// Prompts Section
VStack(alignment: .leading, spacing: 12) {
PromptSelectionGrid(
prompts: enhancementService.allPrompts,
selectedPromptId: enhancementService.selectedPromptId,
onPromptSelected: { prompt in
enhancementService.setActivePrompt(prompt)
},
onEditPrompt: { prompt in
selectedPromptForEdit = prompt
},
onDeletePrompt: { prompt in
enhancementService.deletePrompt(prompt)
},
onAddNewPrompt: {
isEditingPrompt = true
}
)
}
}
.padding()
.background(CardBackground(isSelected: false))
.opacity(enhancementService.isEnhancementEnabled ? 1.0 : 0.6)
}
}
.padding(24)
}
.frame(minWidth: 600, minHeight: 500)
.background(Color(NSColor.controlBackgroundColor))
.sheet(isPresented: $isEditingPrompt) {
PromptEditorView(mode: .add)
}
.sheet(item: $selectedPromptForEdit) { prompt in
PromptEditorView(mode: .edit(prompt))
}
}
}