forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsSidebar.swift
More file actions
698 lines (646 loc) · 29.3 KB
/
Copy pathSettingsSidebar.swift
File metadata and controls
698 lines (646 loc) · 29.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
import OmiTheme
import SwiftUI
// MARK: - Search Data Model
struct SettingsSearchItem: Identifiable {
let id = UUID()
let name: String
let subtitle: String
let keywords: [String]
let section: SettingsContentView.SettingsSection
let icon: String
let settingId: String
var breadcrumb: String {
return section.rawValue
}
static let allSearchableItems: [SettingsSearchItem] = [
// General
SettingsSearchItem(
name: "Rewind", subtitle: "Screen capture and audio recording",
keywords: ["monitor", "screenshot", "capture", "audio", "recording", "microphone", "speech"],
section: .general, icon: "gearshape", settingId: "general.rewind"),
SettingsSearchItem(
name: "System Audio", subtitle: "When to record audio from other apps",
keywords: [
"system audio", "meeting", "zoom", "google meet", "teams", "call", "capture", "recording",
"speaker",
], section: .general, icon: "speaker.wave.2", settingId: "general.systemaudio"),
SettingsSearchItem(
name: "Notifications", subtitle: "Proactive alerts and status",
keywords: ["alerts", "notify"], section: .general, icon: "gearshape",
settingId: "general.notifications"),
SettingsSearchItem(
name: "Ask omi", subtitle: "Show or hide the floating chat bar",
keywords: ["floating bar", "chat bar"], section: .general, icon: "gearshape",
settingId: "general.askomi"),
SettingsSearchItem(
name: "Font Size", subtitle: "Adjust text size across the app",
keywords: ["text size", "zoom", "scale", "reset"], section: .general, icon: "gearshape",
settingId: "general.fontsize"),
SettingsSearchItem(
name: "Reset Window Size", subtitle: "Restore the default window dimensions",
keywords: ["resize", "window", "default size"], section: .general, icon: "gearshape",
settingId: "general.resetwindow"),
// Rewind
SettingsSearchItem(
name: "Rewind", subtitle: "Browse your screen history",
keywords: ["screen history", "screenshots", "recording"], section: .rewind,
icon: "clock.arrow.circlepath", settingId: "rewind.rewind"),
SettingsSearchItem(
name: "Screen Capture", subtitle: "Toggle screen capture on or off",
keywords: ["screen capture", "screenshot", "monitor", "recording", "rewind"],
section: .rewind, icon: "rectangle.dashed.badge.record", settingId: "rewind.screencapture"),
SettingsSearchItem(
name: "Audio Recording", subtitle: "Toggle audio recording and transcription",
keywords: ["audio", "microphone", "recording", "transcription", "mic"], section: .rewind,
icon: "mic.fill", settingId: "rewind.audiorecording"),
SettingsSearchItem(
name: "Storage", subtitle: "View frame count and disk usage",
keywords: ["frames", "storage", "disk", "space", "gb"], section: .rewind,
icon: "clock.arrow.circlepath", settingId: "rewind.storage"),
SettingsSearchItem(
name: "Excluded Apps", subtitle: "Screen capture is paused when these apps are active",
keywords: ["exclude", "ignore", "block apps", "blocklist", "reset to defaults"],
section: .rewind, icon: "clock.arrow.circlepath", settingId: "rewind.excludedapps"),
SettingsSearchItem(
name: "Battery Optimization", subtitle: "Saves power by reducing screenshot frequency",
keywords: ["battery", "power", "energy", "low power"], section: .rewind,
icon: "clock.arrow.circlepath", settingId: "rewind.battery"),
SettingsSearchItem(
name: "Data Retention", subtitle: "How long to keep screen recordings",
keywords: ["retention", "storage", "delete old", "keep data"], section: .rewind,
icon: "clock.arrow.circlepath", settingId: "rewind.retention"),
// Transcription
SettingsSearchItem(
name: "Transcription Settings", subtitle: "Configure speech-to-text options",
keywords: ["language", "vocabulary", "speech"], section: .transcription, icon: "waveform",
settingId: "transcription.settings"),
SettingsSearchItem(
name: "Language Mode", subtitle: "Choose single or multi-language transcription",
keywords: ["language", "multilingual", "single language"], section: .transcription,
icon: "waveform", settingId: "transcription.languagemode"),
SettingsSearchItem(
name: "Voice Assistant Languages",
subtitle: "Languages you speak to Omi over push-to-talk",
keywords: ["voice", "push to talk", "ptt", "language", "russian", "multilingual"],
section: .transcription, icon: "person.wave.2",
settingId: "transcription.voicelanguages"),
SettingsSearchItem(
name: "Custom Vocabulary",
subtitle: "Improve recognition of names, brands, and technical terms",
keywords: ["vocabulary", "words", "custom words", "dictionary"], section: .transcription,
icon: "waveform", settingId: "transcription.vocabulary"),
SettingsSearchItem(
name: "Local VAD Gate", subtitle: "Skip silence to reduce transcription cost",
keywords: ["vad", "silence", "gate", "cost", "deepgram"], section: .transcription,
icon: "waveform", settingId: "transcription.vadgate"),
// Notifications
SettingsSearchItem(
name: "Notification Settings", subtitle: "Control how often you receive notifications",
keywords: ["daily summary", "frequency", "alerts"], section: .notifications, icon: "bell",
settingId: "notifications.settings"),
SettingsSearchItem(
name: "Notification Frequency", subtitle: "How often to receive notifications",
keywords: ["frequency", "how often", "interval"], section: .notifications, icon: "bell",
settingId: "notifications.frequency"),
SettingsSearchItem(
name: "Focus Notifications", subtitle: "Show notification on focus changes",
keywords: ["focus", "distraction", "notify focus"], section: .notifications, icon: "bell",
settingId: "notifications.focus"),
SettingsSearchItem(
name: "Task Notifications",
subtitle: "Allow interruptions when a task needs attention",
keywords: ["task", "action item", "notify task", "interruption", "proactive"],
section: .notifications, icon: "bell",
settingId: "notifications.task"),
SettingsSearchItem(
name: "Insight Notifications", subtitle: "Show notification when an insight is generated",
keywords: ["insight", "insights", "notify insight"], section: .notifications, icon: "bell",
settingId: "notifications.insight"),
SettingsSearchItem(
name: "Memory Notifications", subtitle: "Show notification when a memory is extracted",
keywords: ["memory", "facts", "notify memory"], section: .notifications, icon: "bell",
settingId: "notifications.memory"),
SettingsSearchItem(
name: "Daily Summary",
subtitle: "Receive a daily summary of your conversations and activities",
keywords: ["daily", "summary", "digest", "end of day"], section: .notifications, icon: "bell",
settingId: "notifications.dailysummary"),
SettingsSearchItem(
name: "Summary Time", subtitle: "When to send your daily summary",
keywords: ["time", "schedule", "when", "hour"], section: .notifications, icon: "bell",
settingId: "notifications.summarytime"),
// Privacy
SettingsSearchItem(
name: "Privacy", subtitle: "Control your data and privacy settings",
keywords: ["data", "encryption", "cloud sync", "recordings"], section: .privacy,
icon: "lock.shield", settingId: "privacy.privacy"),
SettingsSearchItem(
name: "Store Recordings",
subtitle: "Allow omi to store audio recordings of your conversations",
keywords: ["store", "save recordings", "audio storage"], section: .privacy,
icon: "lock.shield", settingId: "privacy.storerecordings"),
SettingsSearchItem(
name: "Private Cloud Sync", subtitle: "Sync your data securely to your private cloud storage",
keywords: ["cloud", "sync", "private cloud"], section: .privacy, icon: "lock.shield",
settingId: "privacy.cloudsync"),
SettingsSearchItem(
name: "Encryption", subtitle: "Server-side encryption for your data",
keywords: ["encrypt", "security", "end to end"], section: .privacy, icon: "lock.shield",
settingId: "privacy.encryption"),
SettingsSearchItem(
name: "What We Track", subtitle: "View analytics and telemetry data we collect",
keywords: ["tracking", "analytics", "telemetry", "data collection"], section: .privacy,
icon: "lock.shield", settingId: "privacy.tracking"),
// Account
SettingsSearchItem(
name: "Account", subtitle: "Your profile and email", keywords: ["profile", "email"],
section: .account, icon: "person.circle", settingId: "account.account"),
SettingsSearchItem(
name: "Sign Out", subtitle: "Sign out of your omi account",
keywords: ["sign out", "log out", "logout", "signout"], section: .account,
icon: "person.circle", settingId: "account.signout"),
// Plan and Usage
SettingsSearchItem(
name: "Plan and Usage", subtitle: "Subscription status and usage limits",
keywords: ["subscription", "billing", "plan", "usage", "stripe", "architect", "unlimited"],
section: .planUsage, icon: "creditcard", settingId: "planusage.overview"),
SettingsSearchItem(
name: "Current Plan", subtitle: "See your current subscription and renewal status",
keywords: ["current plan", "renewal", "billing"], section: .planUsage, icon: "creditcard",
settingId: "planusage.current"),
SettingsSearchItem(
name: "Upgrade Plan", subtitle: "Buy Operator or Architect",
keywords: ["upgrade", "buy", "pricing", "checkout", "architect", "operator", "unlimited"], section: .planUsage,
icon: "creditcard", settingId: "planusage.purchase"),
// About
SettingsSearchItem(
name: "Software Updates", subtitle: "Check for and manage app updates",
keywords: ["update", "auto update", "sparkle", "version", "check for updates", "check now"],
section: .about, icon: "info.circle", settingId: "about.updates"),
SettingsSearchItem(
name: "Automatic Updates", subtitle: "Check for updates automatically in the background",
keywords: ["auto check", "background updates", "check automatically"], section: .about,
icon: "info.circle", settingId: "about.autoupdates"),
SettingsSearchItem(
name: "Auto-Install Updates",
subtitle: "Automatically download and install updates when available",
keywords: ["auto install", "automatic install", "download updates", "install updates"],
section: .about, icon: "info.circle", settingId: "about.autoinstall"),
SettingsSearchItem(
name: "Update Channel", subtitle: "Choose between stable and beta update channels",
keywords: ["channel", "beta", "stable", "release channel"], section: .about,
icon: "info.circle", settingId: "about.channel"),
SettingsSearchItem(
name: "Version Info", subtitle: "Current app version and build number",
keywords: ["version", "build", "app version", "build number"], section: .about,
icon: "info.circle", settingId: "about.version"),
SettingsSearchItem(
name: "Report an Issue", subtitle: "Help us improve omi",
keywords: ["bug", "feedback", "report", "issue"], section: .about, icon: "info.circle",
settingId: "about.reportissue"),
// Advanced subsections
SettingsSearchItem(
name: "Reset Onboarding", subtitle: "Restart setup wizard for this app build only",
keywords: ["reset", "onboarding", "restart", "setup"], section: .advanced,
icon: "arrow.counterclockwise", settingId: "advanced.resetonboarding"),
SettingsSearchItem(
name: "AI User Profile", subtitle: "AI-generated summary of your preferences and habits",
keywords: ["profile", "generate", "generate now", "regenerate"], section: .advanced,
icon: "brain", settingId: "advanced.aiuserprofile"),
SettingsSearchItem(
name: "Your Stats", subtitle: "View your usage statistics and activity",
keywords: ["statistics", "conversations", "usage"], section: .advanced, icon: "chart.bar",
settingId: "advanced.stats"),
SettingsSearchItem(
name: "AI Provider", subtitle: "Choose between your omi account and Claude for desktop chat",
keywords: ["provider", "agent sdk", "claude code", "acp", "bridge mode"], section: .advanced,
icon: "cpu", settingId: "aichat.provider"),
SettingsSearchItem(
name: "Workspace", subtitle: "Set a project directory for desktop chat context",
keywords: ["workspace", "project", "directory", "folder", "working directory"],
section: .advanced, icon: "cpu", settingId: "aichat.workspace"),
SettingsSearchItem(
name: "Browser Extension",
subtitle: "Lets the AI use your Chrome browser with all your logged-in sessions",
keywords: [
"playwright", "chrome", "browser extension", "browser", "set up", "reconfigure", "token",
], section: .advanced, icon: "cpu", settingId: "aichat.browserextension"),
SettingsSearchItem(
name: "Dev Mode", subtitle: "Developer tools and debugging options",
keywords: ["developer", "debug", "dev mode", "development"], section: .advanced, icon: "cpu",
settingId: "aichat.devmode"),
SettingsSearchItem(
name: "Goals", subtitle: "Track personal goals with AI-powered progress detection",
keywords: ["goal", "target", "objective", "tracking"], section: .advanced, icon: "target",
settingId: "advanced.goals"),
SettingsSearchItem(
name: "Auto-Generate Goals",
subtitle: "Automatically suggest new goals daily based on your conversations and tasks",
keywords: ["auto generate", "suggest goals", "daily goals"], section: .advanced,
icon: "target", settingId: "advanced.goals.autogenerate"),
SettingsSearchItem(
name: "Ask omi Floating Bar",
subtitle: "Configure the floating bar appearance and visibility",
keywords: ["floating bar", "ask omi", "show bar"], section: .floatingBar, icon: "sparkles",
settingId: "floatingbar.show"),
SettingsSearchItem(
name: "Background Style", subtitle: "Toggle between solid and transparent background",
keywords: ["background", "solid", "transparent", "blur"], section: .floatingBar,
icon: "sparkles", settingId: "floatingbar.background"),
SettingsSearchItem(
name: "Draggable Floating Bar",
subtitle: "Allow repositioning the floating bar by dragging it",
keywords: ["drag", "move", "reposition", "draggable"], section: .floatingBar,
icon: "sparkles", settingId: "floatingbar.draggable"),
SettingsSearchItem(
name: "Typed Questions", subtitle: "Speak replies aloud for typed floating-bar questions",
keywords: ["typed", "text", "speech", "tts", "audio answers"], section: .floatingBar,
icon: "sparkles", settingId: "floatingbar.typedvoiceanswers"),
SettingsSearchItem(
name: "Screen Sharing in Chat",
subtitle: "Let Ask Omi capture your screen when you ask about it",
keywords: ["screenshot", "screen", "capture", "share screen", "vision", "see my screen"],
section: .floatingBar, icon: "camera.viewfinder", settingId: "floatingbar.screenshare"),
SettingsSearchItem(
name: "Voice Speed", subtitle: "Adjust the playback speed for voice replies",
keywords: ["voice speed", "speech speed", "playback speed", "tts speed"],
section: .floatingBar, icon: "sparkles", settingId: "floatingbar.voicespeed"),
SettingsSearchItem(
name: "Shortcuts", subtitle: "Configure Open Omi and push-to-talk keyboard shortcuts",
keywords: ["shortcuts", "keyboard", "hotkeys", "push to talk"], section: .shortcuts,
icon: "keyboard", settingId: "floatingbar.shortcut"),
SettingsSearchItem(
name: "Open Omi Shortcut", subtitle: "Global shortcut to open the Omi app from anywhere",
keywords: ["shortcut", "hotkey", "keyboard", "global shortcut"], section: .shortcuts,
icon: "keyboard", settingId: "floatingbar.shortcut"),
SettingsSearchItem(
name: "Push to Talk", subtitle: "Hold a key to speak, release to send your question to AI",
keywords: ["push to talk", "ptt", "hold to talk", "microphone key"], section: .shortcuts,
icon: "keyboard", settingId: "floatingbar.ptt"),
SettingsSearchItem(
name: "Double-tap for Locked Mode",
subtitle: "Double-tap the push-to-talk key to keep listening hands-free",
keywords: ["double tap", "locked mode", "hands free", "listening"], section: .shortcuts,
icon: "keyboard", settingId: "floatingbar.doubletap"),
SettingsSearchItem(
name: "Push-to-Talk Sounds",
subtitle: "Play audio feedback when starting and ending voice input",
keywords: ["sounds", "audio feedback", "ptt sounds"], section: .shortcuts, icon: "keyboard",
settingId: "floatingbar.pttsounds"),
SettingsSearchItem(
name: "Multiple Chat Sessions", subtitle: "Create separate chat threads",
keywords: ["multi chat", "threads"], section: .advanced, icon: "slider.horizontal.3",
settingId: "advanced.preferences.multichat"),
SettingsSearchItem(
name: "Launch at Login", subtitle: "Start omi automatically when you log in",
keywords: ["startup", "login", "boot"], section: .advanced, icon: "slider.horizontal.3",
settingId: "advanced.preferences.launchatlogin"),
SettingsSearchItem(
name: "Report Issue", subtitle: "Send app logs and report a problem",
keywords: ["bug", "feedback", "logs", "report"], section: .advanced,
icon: "wrench.and.screwdriver", settingId: "advanced.troubleshooting.reportissue"),
SettingsSearchItem(
name: "Rescan Files", subtitle: "Re-index your files and update your AI profile",
keywords: ["index", "reindex", "rescan", "files", "scan", "file indexing", "profile"],
section: .advanced, icon: "wrench.and.screwdriver",
settingId: "advanced.troubleshooting.rescanfiles"),
]
}
/// Settings sidebar that replaces the main sidebar when in settings
struct SettingsSidebar: View {
@Binding var selectedSection: SettingsContentView.SettingsSection
@Binding var highlightedSettingId: String?
let onBack: () -> Void
@State private var isBackHovered = false
@State private var searchQuery = ""
@FocusState private var isSearchFocused: Bool
private let expandedWidth: CGFloat = 260
private let iconWidth: CGFloat = 20
// Merged nav: `.account` hosts Account & Plan (renders `.planUsage` content
// too) and `.notifications` hosts Notifications & Privacy (renders `.privacy`
// content too). The absorbed cases stay routable for deep links/automation
// and highlight their merged item via `sidebarItem`.
private let visibleSections: [SettingsContentView.SettingsSection] = [
.general,
.account,
.transcription,
.floatingBar,
.notifications,
.rewind,
.shortcuts,
.advanced,
.about,
]
private var filteredSearchItems: [SettingsSearchItem] {
guard !searchQuery.isEmpty else { return [] }
let words = searchQuery.lowercased().split(separator: " ").map(String.init)
guard !words.isEmpty else { return [] }
return SettingsSearchItem.allSearchableItems.filter { item in
let nameLower = item.name.lowercased()
let subtitleLower = item.subtitle.lowercased()
let keywordsLower = item.keywords.map { $0.lowercased() }
return words.allSatisfy { word in
nameLower.contains(word) || subtitleLower.contains(word)
|| keywordsLower.contains(where: { $0.contains(word) })
}
}
}
var body: some View {
VStack(alignment: .leading, spacing: 0) {
// Back button header
backButton
.padding(.top, OmiSpacing.md)
.padding(.horizontal, OmiSpacing.lg)
Spacer().frame(height: OmiSpacing.xxl)
// Settings title
Text("Settings")
.scaledFont(size: OmiType.heading, weight: .bold)
.foregroundColor(OmiColors.textPrimary)
.padding(.horizontal, OmiSpacing.lg)
.padding(.bottom, OmiSpacing.md)
// Search field
searchField
.padding(.horizontal, OmiSpacing.md)
.padding(.bottom, OmiSpacing.md)
if searchQuery.isEmpty {
// Normal settings sections
ScrollView(showsIndicators: false) {
VStack(alignment: .leading, spacing: OmiSpacing.hairline) {
ForEach(visibleSections, id: \.self) { section in
SettingsSidebarItem(
section: section,
isSelected: selectedSection.sidebarItem == section,
iconWidth: iconWidth,
onTap: {
OmiMotion.withGated(.easeInOut(duration: 0.15)) {
selectedSection = section
}
}
)
}
}
}
.padding(.horizontal, OmiSpacing.sm)
} else {
// Search results
searchResultsList
.padding(.horizontal, OmiSpacing.sm)
}
Spacer()
}
.frame(width: expandedWidth)
.background(OmiColors.backgroundPrimary)
}
private var searchField: some View {
HStack(spacing: OmiSpacing.sm) {
Image(systemName: "magnifyingglass")
.scaledFont(size: OmiType.body)
.foregroundColor(isSearchFocused ? OmiColors.accent : OmiColors.textTertiary)
.omiAnimation(.easeInOut(duration: 0.15), value: isSearchFocused)
TextField("Search settings...", text: $searchQuery)
.textFieldStyle(.plain)
.scaledFont(size: OmiType.body)
.foregroundColor(OmiColors.textPrimary)
.focused($isSearchFocused)
if !searchQuery.isEmpty {
Button {
searchQuery = ""
} label: {
Image(systemName: "xmark.circle.fill")
.scaledFont(size: OmiType.caption)
.foregroundColor(OmiColors.textTertiary)
}
.buttonStyle(.plain)
}
}
.padding(.horizontal, OmiSpacing.sm)
.padding(.vertical, OmiSpacing.sm)
.background(
RoundedRectangle(cornerRadius: OmiChrome.elementRadius)
.fill(OmiColors.backgroundTertiary)
.overlay(
RoundedRectangle(cornerRadius: OmiChrome.elementRadius)
.stroke(
isSearchFocused ? OmiColors.accent.opacity(0.5) : Color.clear, lineWidth: 1)
)
)
}
private var searchResultsList: some View {
ScrollView(showsIndicators: false) {
VStack(alignment: .leading, spacing: OmiSpacing.hairline) {
if filteredSearchItems.isEmpty {
Text("No results")
.scaledFont(size: OmiType.body)
.foregroundColor(OmiColors.textTertiary)
.padding(.horizontal, OmiSpacing.md)
.padding(.vertical, OmiSpacing.xl)
} else {
ForEach(filteredSearchItems) { item in
SettingsSearchResultRow(item: item) {
OmiMotion.withGated(.easeInOut(duration: 0.15)) {
selectedSection = item.section
}
searchQuery = ""
let targetId = item.settingId
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
highlightedSettingId = targetId
}
}
}
}
}
}
}
private var backButton: some View {
Button(action: onBack) {
HStack(spacing: OmiSpacing.sm) {
Image(systemName: "chevron.left")
.scaledFont(size: OmiType.body, weight: .semibold)
.foregroundColor(OmiColors.textSecondary)
Text("Back")
.scaledFont(size: OmiType.body, weight: .medium)
.foregroundColor(OmiColors.textSecondary)
Spacer()
}
.padding(.horizontal, OmiSpacing.md)
.padding(.vertical, OmiSpacing.sm)
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: OmiChrome.elementRadius)
.fill(isBackHovered ? OmiColors.backgroundTertiary.opacity(0.5) : Color.clear)
)
}
.buttonStyle(.plain)
.onHover { hovering in
isBackHovered = hovering
}
}
}
// MARK: - Settings Sidebar Item
struct SettingsSidebarItem: View {
let section: SettingsContentView.SettingsSection
let isSelected: Bool
let iconWidth: CGFloat
let onTap: () -> Void
@State private var isHovered = false
private var icon: String {
switch section {
case .general: return "gearshape"
case .rewind: return "clock.arrow.circlepath"
case .transcription: return "waveform"
case .notifications: return "bell"
case .privacy: return "lock.shield"
case .account: return "person.circle"
case .planUsage: return "creditcard"
case .aiChat: return "cpu"
case .floatingBar: return "sparkles"
case .shortcuts: return "keyboard"
case .advanced: return "chart.bar"
case .about: return "info.circle"
}
}
var body: some View {
Group {
if section == .aiChat {
EmptyView()
} else {
Button(action: onTap) {
HStack(spacing: OmiSpacing.md) {
Image(systemName: icon)
.scaledFont(size: OmiType.subheading)
.foregroundColor(isSelected ? OmiColors.textPrimary : OmiColors.textTertiary)
.frame(width: iconWidth)
Text(section.displayTitle)
.scaledFont(size: OmiType.body, weight: isSelected ? .medium : .regular)
.foregroundColor(isSelected ? OmiColors.textPrimary : OmiColors.textSecondary)
Spacer()
}
.padding(.horizontal, OmiSpacing.md)
.padding(.vertical, OmiSpacing.md)
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: OmiChrome.smallControlRadius)
.fill(
isSelected
? OmiColors.backgroundTertiary.opacity(0.8)
: (isHovered ? OmiColors.backgroundTertiary.opacity(0.5) : Color.clear))
)
}
.buttonStyle(.plain)
.onHover { hovering in
isHovered = hovering
}
}
}
}
}
// MARK: - Settings Subsection Item
struct SettingsSubsectionItem: View {
let subsection: SettingsContentView.AdvancedSubsection
let isSelected: Bool
let iconWidth: CGFloat
let onTap: () -> Void
@State private var isHovered = false
var body: some View {
Button(action: onTap) {
HStack(spacing: OmiSpacing.sm) {
// Indentation spacer
Spacer()
.frame(width: iconWidth + 12)
Image(systemName: subsection.icon)
.scaledFont(size: OmiType.body)
.foregroundColor(isSelected ? OmiColors.textPrimary : OmiColors.textTertiary)
.frame(width: 16)
Text(subsection.rawValue)
.scaledFont(size: OmiType.body, weight: isSelected ? .medium : .regular)
.foregroundColor(isSelected ? OmiColors.textPrimary : OmiColors.textSecondary)
Spacer()
}
.padding(.horizontal, OmiSpacing.md)
.padding(.vertical, OmiSpacing.sm)
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: OmiChrome.elementRadius)
.fill(
isSelected
? OmiColors.backgroundTertiary.opacity(0.6)
: (isHovered ? OmiColors.backgroundTertiary.opacity(0.3) : Color.clear))
)
}
.buttonStyle(.plain)
.onHover { hovering in
isHovered = hovering
}
}
}
// MARK: - Settings Search Result Row
struct SettingsSearchResultRow: View {
let item: SettingsSearchItem
let onTap: () -> Void
@State private var isHovered = false
var body: some View {
Button(action: onTap) {
HStack(spacing: OmiSpacing.sm) {
Image(systemName: item.icon)
.scaledFont(size: OmiType.body)
.foregroundColor(OmiColors.textTertiary)
.frame(width: 20)
VStack(alignment: .leading, spacing: OmiSpacing.hairline) {
Text(item.name)
.scaledFont(size: OmiType.body, weight: .medium)
.foregroundColor(OmiColors.textPrimary)
Text(item.breadcrumb)
.scaledFont(size: OmiType.caption)
.foregroundColor(OmiColors.textTertiary)
}
Spacer()
}
.padding(.horizontal, OmiSpacing.md)
.padding(.vertical, OmiSpacing.sm)
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: OmiChrome.elementRadius)
.fill(isHovered ? OmiColors.backgroundTertiary.opacity(0.5) : Color.clear)
)
}
.buttonStyle(.plain)
.onHover { hovering in
isHovered = hovering
}
}
}
// MARK: - Setting Highlight Modifier
struct SettingHighlightModifier: ViewModifier {
let settingId: String
@Binding var highlightedSettingId: String?
@State private var isHighlighted = false
func body(content: Content) -> some View {
content
.id(settingId)
.overlay(
RoundedRectangle(cornerRadius: OmiChrome.elementRadius)
.fill(isHighlighted ? OmiColors.accent.opacity(0.12) : Color.clear)
.omiAnimation(.easeInOut(duration: 0.3), value: isHighlighted)
.allowsHitTesting(false)
)
.onChange(of: highlightedSettingId) { _, newId in
if newId == settingId {
OmiMotion.withGated { isHighlighted = true }
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
OmiMotion.withGated(.easeInOut(duration: 0.5)) { isHighlighted = false }
if highlightedSettingId == settingId { highlightedSettingId = nil }
}
}
}
}
}
#if canImport(PreviewsMacros)
#Preview {
SettingsSidebar(
selectedSection: .constant(.advanced),
highlightedSettingId: .constant(nil),
onBack: {}
)
.preferredColorScheme(.dark)
}
#endif