forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserDefaults.swift
More file actions
37 lines (34 loc) · 1.64 KB
/
UserDefaults.swift
File metadata and controls
37 lines (34 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import Foundation
public extension UserDefaults {
static var shared = UserDefaults(suiteName: "5YKZ4Y3DAW.group.com.intii.CopilotForXcode")!
static func setupDefaultSettings() {
func setDefaultValue<T>(_ value: T, forKey: String) {
let userDefaults = UserDefaults.shared
if userDefaults.value(forKey: forKey) == nil {
userDefaults.set(value, forKey: forKey)
}
}
setDefaultValue(true, forKey: SettingsKey.quitXPCServiceOnXcodeAndAppQuit)
setDefaultValue(false, forKey: SettingsKey.realtimeSuggestionToggle)
setDefaultValue(1 as Double, forKey: SettingsKey.realtimeSuggestionDebounce)
setDefaultValue(false, forKey: SettingsKey.automaticallyCheckForUpdate)
setDefaultValue(
PresentationMode.floatingWidget.rawValue,
forKey: SettingsKey.suggestionPresentationMode
)
setDefaultValue(
WidgetColorScheme.dark.rawValue,
forKey: SettingsKey.widgetColorScheme
)
}
}
public enum SettingsKey {
public static let nodePath = "NodePath"
public static let realtimeSuggestionToggle = "RealtimeSuggestionToggle"
public static let realtimeSuggestionDebounce = "RealtimeSuggestionDebounce"
public static let quitXPCServiceOnXcodeAndAppQuit = "QuitXPCServiceOnXcodeAndAppQuit"
public static let suggestionPresentationMode = "SuggestionPresentationMode"
public static let automaticallyCheckForUpdate = "AutomaticallyCheckForUpdate"
public static let suggestionWidgetPositionMode = "SuggestionWidgetPositionMode"
public static let widgetColorScheme = "WidgetColorScheme"
}