11import SwiftUI
22import ServiceManagement
3+ import Sparkle
34
45struct SettingsView : View {
6+ let updater : SPUUpdater
57 @AppStorage ( " startAtLogin " ) private var startAtLogin : Bool = false
8+ @State private var automaticallyChecksForUpdates : Bool
9+ @State private var automaticallyDownloadsUpdates : Bool
10+
11+ init ( updater: SPUUpdater ) {
12+ self . updater = updater
13+ _automaticallyChecksForUpdates = State ( wrappedValue: updater. automaticallyChecksForUpdates)
14+ _automaticallyDownloadsUpdates = State ( wrappedValue: updater. automaticallyDownloadsUpdates)
15+ }
616
717 var body : some View {
818 Form {
919 Toggle ( isOn: $startAtLogin) {
1020 Text ( " Start Flitro at login " )
1121 }
12- . onChange ( of: startAtLogin) {
13- setLaunchAtLogin ( enabled: startAtLogin )
22+ . onChange ( of: startAtLogin) { newValue , _ in
23+ setLaunchAtLogin ( enabled: newValue )
1424 }
25+ Toggle ( " Automatically check for updates " , isOn: $automaticallyChecksForUpdates)
26+ . onChange ( of: automaticallyChecksForUpdates) { newValue, _ in
27+ updater. automaticallyChecksForUpdates = newValue
28+ }
29+ Toggle ( " Automatically download updates " , isOn: $automaticallyDownloadsUpdates)
30+ . disabled ( !automaticallyChecksForUpdates)
31+ . onChange ( of: automaticallyDownloadsUpdates) { newValue, _ in
32+ updater. automaticallyDownloadsUpdates = newValue
33+ }
1534 }
1635 . padding ( )
1736 . frame ( width: 320 )
@@ -28,4 +47,4 @@ struct SettingsView: View {
2847 // Handle error (e.g., show an alert)
2948 }
3049 }
31- }
50+ }
0 commit comments