mirror of
https://github.com/pawelorzech/FastMemos.git
synced 2026-01-29 19:54:29 +00:00
feat: implement launch at login functionality with settings UI.
This commit is contained in:
parent
4b9ae74d1a
commit
d7db888aad
2 changed files with 25 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue