145 lines
4.9 KiB
Swift
145 lines
4.9 KiB
Swift
import SwiftUI
|
|
|
|
struct DictionarySettingsView: View {
|
|
@State private var selectedSection: DictionarySection = .spellings
|
|
|
|
enum DictionarySection: String, CaseIterable {
|
|
case spellings = "Correct Spellings"
|
|
case replacements = "Word Replacements"
|
|
|
|
var description: String {
|
|
switch self {
|
|
case .spellings:
|
|
return "Train VoiceInk to recognize industry terms, names, and technical words"
|
|
case .replacements:
|
|
return "Automatically replace specific words/phrases with custom formatted text "
|
|
}
|
|
}
|
|
|
|
var icon: String {
|
|
switch self {
|
|
case .spellings:
|
|
return "character.book.closed.fill"
|
|
case .replacements:
|
|
return "arrow.2.squarepath"
|
|
}
|
|
}
|
|
}
|
|
|
|
var body: some View {
|
|
ScrollView {
|
|
VStack(spacing: 0) {
|
|
heroSection
|
|
mainContent
|
|
}
|
|
}
|
|
.frame(minWidth: 600, minHeight: 500)
|
|
.background(Color(NSColor.controlBackgroundColor))
|
|
}
|
|
|
|
private var heroSection: some View {
|
|
VStack(spacing: 24) {
|
|
Image(systemName: "brain.filled.head.profile")
|
|
.font(.system(size: 40))
|
|
.foregroundStyle(.blue)
|
|
.padding(20)
|
|
.background(Circle()
|
|
.fill(Color(.windowBackgroundColor).opacity(0.9))
|
|
.shadow(color: .black.opacity(0.1), radius: 10, y: 5))
|
|
|
|
VStack(spacing: 8) {
|
|
Text("Dictionary Settings")
|
|
.font(.system(size: 28, weight: .bold))
|
|
Text("Enhance VoiceInk's transcription accuracy by teaching it your vocabulary")
|
|
.font(.system(size: 15))
|
|
.foregroundStyle(.secondary)
|
|
.multilineTextAlignment(.center)
|
|
.frame(maxWidth: 400)
|
|
}
|
|
}
|
|
.padding(.vertical, 40)
|
|
.frame(maxWidth: .infinity)
|
|
}
|
|
|
|
private var mainContent: some View {
|
|
VStack(spacing: 40) {
|
|
sectionSelector
|
|
|
|
selectedSectionContent
|
|
}
|
|
.padding(.horizontal, 32)
|
|
.padding(.vertical, 40)
|
|
}
|
|
|
|
private var sectionSelector: some View {
|
|
VStack(alignment: .leading, spacing: 20) {
|
|
Text("Select Section")
|
|
.font(.title2)
|
|
.fontWeight(.semibold)
|
|
|
|
HStack(spacing: 20) {
|
|
ForEach(DictionarySection.allCases, id: \.self) { section in
|
|
SectionCard(
|
|
section: section,
|
|
isSelected: selectedSection == section,
|
|
action: { selectedSection = section }
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private var selectedSectionContent: some View {
|
|
VStack(alignment: .leading, spacing: 20) {
|
|
switch selectedSection {
|
|
case .spellings:
|
|
DictionaryView()
|
|
.background(Color(.windowBackgroundColor).opacity(0.4))
|
|
.cornerRadius(10)
|
|
case .replacements:
|
|
WordReplacementView()
|
|
.background(Color(.windowBackgroundColor).opacity(0.4))
|
|
.cornerRadius(10)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct SectionCard: View {
|
|
let section: DictionarySettingsView.DictionarySection
|
|
let isSelected: Bool
|
|
let action: () -> Void
|
|
|
|
var body: some View {
|
|
Button(action: action) {
|
|
VStack(alignment: .leading, spacing: 12) {
|
|
Image(systemName: section.icon)
|
|
.font(.system(size: 28))
|
|
.symbolRenderingMode(.hierarchical)
|
|
.foregroundStyle(isSelected ? .blue : .secondary)
|
|
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
Text(section.rawValue)
|
|
.font(.headline)
|
|
|
|
Text(section.description)
|
|
.font(.subheadline)
|
|
.foregroundStyle(.secondary)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.padding()
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 16)
|
|
.fill(Color(.windowBackgroundColor).opacity(0.4))
|
|
.shadow(color: isSelected ? .blue.opacity(0.2) : .clear, radius: 8, y: 4)
|
|
.overlay(
|
|
RoundedRectangle(cornerRadius: 16)
|
|
.stroke(isSelected ? .blue.opacity(0.5) : .clear, lineWidth: 2)
|
|
)
|
|
)
|
|
}
|
|
.buttonStyle(.plain)
|
|
}
|
|
} |