-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.swift
45 lines (38 loc) · 1.34 KB
/
Settings.swift
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
38
39
40
41
42
43
44
45
//
// Settings.swift
//
import Foundation
struct Settings {
enum DefaultBackendServer: String {
case test = "1"
case dev = "0"
private static let key = "defaultBackendServer"
private static let defaultValue: DefaultBackendServer = .test
static var selectedValue: DefaultBackendServer {
get {
let value = UserDefaults.standard.object(forKey: key) as? String
return DefaultBackendServer(rawValue: value ?? defaultValue.rawValue) ?? defaultValue
}
set {
UserDefaults.standard.set(newValue.rawValue, forKey: key)
}
}
}
enum DefaultNavigationApp: Double {
case waze = 3.5
case googleMaps = 2.0
case maps = 1.0
case chooseFromAvailableApps = 0.0
private static let key = "defaultNavigationApp"
private static let defaultValue: DefaultNavigationApp = .chooseFromAvailableApps
static var selectedValue: DefaultNavigationApp {
get {
let value = UserDefaults.standard.object(forKey: key) as? Double
return DefaultNavigationApp(rawValue: value ?? defaultValue.rawValue) ?? defaultValue
}
set {
UserDefaults.standard.set(newValue.rawValue, forKey: key)
}
}
}
}