11import LaunchAgentManager
2+ import Preferences
23import SwiftUI
3- import XPCShared
44
55final class Settings : ObservableObject {
6- @AppStorage ( SettingsKey . quitXPCServiceOnXcodeAndAppQuit, store : . shared )
7- var quitXPCServiceOnXcodeAndAppQuit : Bool = false
8- @AppStorage ( SettingsKey . realtimeSuggestionToggle, store : . shared )
9- var realtimeSuggestionToggle : Bool = false
10- @AppStorage ( SettingsKey . realtimeSuggestionDebounce, store : . shared )
11- var realtimeSuggestionDebounce : Double = 0.7
12- @AppStorage ( SettingsKey . suggestionPresentationMode, store : . shared )
13- var suggestionPresentationModeRawValue : Int = 0
14- @AppStorage ( SettingsKey . automaticallyCheckForUpdate, store : . shared )
15- var automaticallyCheckForUpdate : Bool = false
16- @AppStorage ( SettingsKey . suggestionWidgetPositionMode, store : . shared )
17- var suggestionWidgetPositionModeRawValue : Int = 0
18- @AppStorage ( SettingsKey . widgetColorScheme, store : . shared )
19- var widgetColorScheme : Int = 0
6+ @AppStorage ( \ . quitXPCServiceOnXcodeAndAppQuit)
7+ var quitXPCServiceOnXcodeAndAppQuit : Bool
8+ @AppStorage ( \ . realtimeSuggestionToggle)
9+ var realtimeSuggestionToggle : Bool
10+ @AppStorage ( \ . realtimeSuggestionDebounce)
11+ var realtimeSuggestionDebounce : Double
12+ @AppStorage ( \ . suggestionPresentationMode)
13+ var suggestionPresentationMode : Preferences . PresentationMode
14+ @AppStorage ( \ . automaticallyCheckForUpdate)
15+ var automaticallyCheckForUpdate : Bool
16+ @AppStorage ( \ . suggestionWidgetPositionMode)
17+ var suggestionWidgetPositionMode : SuggestionWidgetPositionMode
18+ @AppStorage ( \ . widgetColorScheme)
19+ var widgetColorScheme : WidgetColorScheme
2020 init ( ) { }
2121}
2222
2323struct SettingsView : View {
2424 @StateObject var settings = Settings ( )
2525 @State var editingRealtimeSuggestionDebounce : Double = UserDefaults . shared
26- . value ( forKey : SettingsKey . realtimeSuggestionDebounce) as? Double ?? 0.7
26+ . value ( for : \ . realtimeSuggestionDebounce)
2727
2828 var body : some View {
2929 Section {
@@ -38,44 +38,42 @@ struct SettingsView: View {
3838 }
3939 . toggleStyle ( . switch)
4040
41- Picker ( selection: $settings. suggestionPresentationModeRawValue ) {
41+ Picker ( selection: $settings. suggestionPresentationMode ) {
4242 ForEach ( PresentationMode . allCases, id: \. rawValue) {
4343 switch $0 {
4444 case . comment:
45- Text ( " Comment " )
45+ Text ( " Comment " ) . tag ( $0 )
4646 case . floatingWidget:
47- Text ( " Floating Widget " )
47+ Text ( " Floating Widget " ) . tag ( $0 )
4848 }
4949 }
5050 } label: {
5151 Text ( " Present suggestions in " )
5252 }
5353
54- if settings. suggestionPresentationModeRawValue == PresentationMode . floatingWidget
55- . rawValue
56- {
57- Picker ( selection: $settings. suggestionWidgetPositionModeRawValue) {
54+ if settings. suggestionPresentationMode == PresentationMode . floatingWidget {
55+ Picker ( selection: $settings. suggestionWidgetPositionMode) {
5856 ForEach ( SuggestionWidgetPositionMode . allCases, id: \. rawValue) {
5957 switch $0 {
6058 case . fixedToBottom:
61- Text ( " Fixed to Bottom " )
59+ Text ( " Fixed to Bottom " ) . tag ( $0 )
6260 case . alignToTextCursor:
63- Text ( " Follow Text Cursor " )
61+ Text ( " Follow Text Cursor " ) . tag ( $0 )
6462 }
6563 }
6664 } label: {
6765 Text ( " Widget position " )
6866 }
69-
67+
7068 Picker ( selection: $settings. widgetColorScheme) {
7169 ForEach ( WidgetColorScheme . allCases, id: \. rawValue) {
7270 switch $0 {
7371 case . system:
74- Text ( " System " )
72+ Text ( " System " ) . tag ( $0 )
7573 case . light:
76- Text ( " Light " )
74+ Text ( " Light " ) . tag ( $0 )
7775 case . dark:
78- Text ( " Dark " )
76+ Text ( " Dark " ) . tag ( $0 )
7977 }
8078 }
8179 } label: {
0 commit comments