From d7db888aad6d100427e7ad65b3b1e1ecadde8a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Orzech?= Date: Sun, 18 Jan 2026 02:39:36 +0000 Subject: [PATCH] feat: implement launch at login functionality with settings UI. --- FastMemos/ViewModels/AppState.swift | 13 +++++++++++++ FastMemos/Views/SettingsView.swift | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/FastMemos/ViewModels/AppState.swift b/FastMemos/ViewModels/AppState.swift index 5df7709..a7df51c 100644 --- a/FastMemos/ViewModels/AppState.swift +++ b/FastMemos/ViewModels/AppState.swift @@ -1,5 +1,6 @@ import Foundation import SwiftUI +import ServiceManagement /// Global app state that persists settings and manages authentication class AppState: ObservableObject { @@ -10,11 +11,23 @@ class AppState: ObservableObject { @Published var isLoading: Bool = false @Published var lastError: String? + @Published var launchAtLogin: Bool = false { + didSet { + if launchAtLogin { + try? SMAppService.mainApp.register() + } else { + try? SMAppService.mainApp.unregister() + } + } + } + private let keychainService = KeychainService() private lazy var apiService = MemosAPIService() init() { loadSettings() + // Check current launch at login status + launchAtLogin = SMAppService.mainApp.status == .enabled } // MARK: - Settings Persistence diff --git a/FastMemos/Views/SettingsView.swift b/FastMemos/Views/SettingsView.swift index c976663..95a9789 100644 --- a/FastMemos/Views/SettingsView.swift +++ b/FastMemos/Views/SettingsView.swift @@ -25,6 +25,18 @@ struct SettingsView: View { ScrollView { VStack(alignment: .leading, spacing: 20) { + // General Section + VStack(alignment: .leading, spacing: 8) { + Label("General", systemImage: "gearshape") + .font(.subheadline) + .fontWeight(.medium) + + Toggle("Launch at login", isOn: $appState.launchAtLogin) + .toggleStyle(.switch) + } + + Divider() + // Default Visibility Section VStack(alignment: .leading, spacing: 8) { Label("Default Visibility", systemImage: "eye")