Files
Gaze/Gaze/Views/Onboarding/SettingsOnboardingView.swift
2026-01-08 08:22:42 -05:00

171 lines
6.2 KiB
Swift

//
// SettingsOnboardingView.swift
// Gaze
//
// Created by Mike Freno on 1/8/26.
//
import SwiftUI
struct SettingsOnboardingView: View {
@Binding var launchAtLogin: Bool
var onContinue: () -> Void
var onBack: (() -> Void)?
var body: some View {
VStack(spacing: 30) {
Spacer()
Image(systemName: "gearshape.fill")
.font(.system(size: 80))
.foregroundColor(.blue)
Text("Final Settings")
.font(.system(size: 36, weight: .bold))
Text("Configure app preferences and support the project")
.font(.title3)
.foregroundColor(.secondary)
.multilineTextAlignment(.center)
.padding(.horizontal, 40)
VStack(spacing: 20) {
// Launch at Login Toggle
HStack {
VStack(alignment: .leading, spacing: 4) {
Text("Launch at Login")
.font(.headline)
Text("Start Gaze automatically when you log in")
.font(.caption)
.foregroundColor(.secondary)
}
Spacer()
Toggle("", isOn: $launchAtLogin)
.labelsHidden()
.onChange(of: launchAtLogin) { oldValue, newValue in
applyLaunchAtLoginSetting(enabled: newValue)
}
}
.padding()
.glassEffect(in: .rect(cornerRadius: 12))
// Links Section
VStack(spacing: 12) {
Text("Support & Contribute")
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
// GitHub Link
Button(action: {
if let url = URL(string: "https://github.com/mikefreno/Gaze") {
NSWorkspace.shared.open(url)
}
}) {
HStack {
Image(systemName: "chevron.left.forwardslash.chevron.right")
.font(.title3)
VStack(alignment: .leading, spacing: 2) {
Text("View on GitHub")
.font(.subheadline)
.fontWeight(.semibold)
Text("Star the repo, report issues, contribute")
.font(.caption)
.foregroundColor(.secondary)
}
Spacer()
Image(systemName: "arrow.up.right")
.font(.caption)
}
.padding()
.frame(maxWidth: .infinity)
}
.buttonStyle(.plain)
.glassEffect(.regular.interactive(), in: .rect(cornerRadius: 10))
// Buy Me a Coffee
Button(action: {
if let url = URL(string: "https://buymeacoffee.com/placeholder") {
NSWorkspace.shared.open(url)
}
}) {
HStack {
Image(systemName: "cup.and.saucer.fill")
.font(.title3)
.foregroundColor(.orange)
VStack(alignment: .leading, spacing: 2) {
Text("Buy Me a Coffee")
.font(.subheadline)
.fontWeight(.semibold)
Text("Support development of Gaze")
.font(.caption)
.foregroundColor(.secondary)
}
Spacer()
Image(systemName: "arrow.up.right")
.font(.caption)
}
.padding()
.frame(maxWidth: .infinity)
.background(Color.orange.opacity(0.1))
.cornerRadius(10)
}
.buttonStyle(.plain)
.glassEffect(.regular.tint(.orange).interactive(), in: .rect(cornerRadius: 10))
}
.padding()
}
Spacer()
HStack(spacing: 12) {
if let onBack = onBack {
Button(action: onBack) {
HStack {
Image(systemName: "chevron.left")
Text("Back")
}
.font(.headline)
.frame(maxWidth: .infinity)
.padding()
}
.buttonStyle(.plain)
.glassEffect(.regular.interactive())
}
Button(action: onContinue) {
Text("Continue")
.font(.headline)
.frame(maxWidth: .infinity)
.padding()
}
.buttonStyle(.plain)
.glassEffect(.regular.tint(.blue).interactive())
}
.padding(.horizontal, 40)
}
.frame(width: 600, height: 500)
.padding()
.background(.clear)
}
private func applyLaunchAtLoginSetting(enabled: Bool) {
do {
if enabled {
try LaunchAtLoginManager.enable()
} else {
try LaunchAtLoginManager.disable()
}
} catch {
print("Failed to set launch at login: \(error)")
}
}
}
#Preview {
SettingsOnboardingView(
launchAtLogin: .constant(false),
onContinue: {},
onBack: {}
)
}