mirror of
https://github.com/pawelorzech/FastMemos.git
synced 2026-01-30 04:04:31 +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 Foundation
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import ServiceManagement
|
||||||
|
|
||||||
/// Global app state that persists settings and manages authentication
|
/// Global app state that persists settings and manages authentication
|
||||||
class AppState: ObservableObject {
|
class AppState: ObservableObject {
|
||||||
|
|
@ -10,11 +11,23 @@ class AppState: ObservableObject {
|
||||||
@Published var isLoading: Bool = false
|
@Published var isLoading: Bool = false
|
||||||
@Published var lastError: String?
|
@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 let keychainService = KeychainService()
|
||||||
private lazy var apiService = MemosAPIService()
|
private lazy var apiService = MemosAPIService()
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
loadSettings()
|
loadSettings()
|
||||||
|
// Check current launch at login status
|
||||||
|
launchAtLogin = SMAppService.mainApp.status == .enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Settings Persistence
|
// MARK: - Settings Persistence
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,18 @@ struct SettingsView: View {
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
VStack(alignment: .leading, spacing: 20) {
|
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
|
// Default Visibility Section
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
Label("Default Visibility", systemImage: "eye")
|
Label("Default Visibility", systemImage: "eye")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue