2022-06-09 21:22:39 -07:00
|
|
|
//
|
|
|
|
|
// UserSettings.swift
|
2022-06-09 22:11:54 -07:00
|
|
|
// MeshtasticApple
|
2022-06-09 21:22:39 -07:00
|
|
|
//
|
|
|
|
|
// Created by Garth Vander Houwen on 6/9/22.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
|
|
class UserSettings: ObservableObject {
|
|
|
|
|
@Published var meshtasticUsername: String {
|
|
|
|
|
didSet {
|
|
|
|
|
UserDefaults.standard.set(meshtasticUsername, forKey: "meshtasticusername")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Published var preferredPeripheralId: String {
|
|
|
|
|
didSet {
|
|
|
|
|
UserDefaults.standard.set(preferredPeripheralId, forKey: "preferredPeripheralId")
|
2022-12-07 16:50:24 -08:00
|
|
|
UserDefaults.standard.synchronize()
|
2022-06-09 21:22:39 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Published var provideLocation: Bool {
|
|
|
|
|
didSet {
|
|
|
|
|
UserDefaults.standard.set(provideLocation, forKey: "provideLocation")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Published var provideLocationInterval: Int {
|
|
|
|
|
didSet {
|
|
|
|
|
UserDefaults.standard.set(provideLocationInterval, forKey: "provideLocationInterval")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Published var keyboardType: Int {
|
|
|
|
|
didSet {
|
|
|
|
|
UserDefaults.standard.set(keyboardType, forKey: "keyboardType")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Published var meshMapType: String {
|
|
|
|
|
didSet {
|
|
|
|
|
UserDefaults.standard.set(meshMapType, forKey: "meshMapType")
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-21 21:57:22 -08:00
|
|
|
@Published var meshMapCenteringMode: Int {
|
|
|
|
|
didSet {
|
|
|
|
|
UserDefaults.standard.set(meshMapCenteringMode, forKey: "meshMapCenteringMode")
|
|
|
|
|
UserDefaults.standard.synchronize()
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-22 13:16:33 -08:00
|
|
|
@Published var meshMapRecentering: Bool {
|
|
|
|
|
didSet {
|
2023-03-19 19:32:33 -07:00
|
|
|
UserDefaults.standard.set(meshMapRecentering, forKey: "meshMapRecentering")
|
2023-02-22 13:16:33 -08:00
|
|
|
UserDefaults.standard.synchronize()
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-09 21:22:39 -07:00
|
|
|
@Published var meshMapCustomTileServer: String {
|
|
|
|
|
didSet {
|
|
|
|
|
UserDefaults.standard.set(meshMapCustomTileServer, forKey: "meshMapCustomTileServer")
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-24 21:14:08 -08:00
|
|
|
@Published var meshMapUserTrackingMode: Int {
|
|
|
|
|
didSet {
|
|
|
|
|
UserDefaults.standard.set(meshMapUserTrackingMode, forKey: "meshMapUserTrackingMode")
|
|
|
|
|
UserDefaults.standard.synchronize()
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-19 22:11:46 -07:00
|
|
|
@Published var meshMapShowNodeHistory: Bool {
|
|
|
|
|
didSet {
|
|
|
|
|
UserDefaults.standard.set(meshMapShowNodeHistory, forKey: "meshMapShowNodeHistory")
|
|
|
|
|
UserDefaults.standard.synchronize()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Published var meshMapShowRouteLines: Bool {
|
|
|
|
|
didSet {
|
|
|
|
|
UserDefaults.standard.set(meshMapShowRouteLines, forKey: "meshMapShowRouteLines")
|
|
|
|
|
UserDefaults.standard.synchronize()
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-06 10:33:18 -08:00
|
|
|
|
2022-06-09 21:22:39 -07:00
|
|
|
init() {
|
|
|
|
|
|
|
|
|
|
self.meshtasticUsername = UserDefaults.standard.object(forKey: "meshtasticusername") as? String ?? ""
|
|
|
|
|
self.preferredPeripheralId = UserDefaults.standard.object(forKey: "preferredPeripheralId") as? String ?? ""
|
|
|
|
|
self.provideLocation = UserDefaults.standard.object(forKey: "provideLocation") as? Bool ?? false
|
|
|
|
|
self.provideLocationInterval = UserDefaults.standard.object(forKey: "provideLocationInterval") as? Int ?? 900
|
|
|
|
|
self.keyboardType = UserDefaults.standard.object(forKey: "keyboardType") as? Int ?? 0
|
2023-02-20 20:00:00 -08:00
|
|
|
self.meshMapType = UserDefaults.standard.string(forKey: "meshMapType") ?? "standard"
|
2023-02-21 21:57:22 -08:00
|
|
|
self.meshMapCenteringMode = UserDefaults.standard.object(forKey: "meshMapCenteringMode") as? Int ?? 0
|
2023-02-28 12:25:44 -08:00
|
|
|
self.meshMapRecentering = UserDefaults.standard.object(forKey: "meshMapRecentering") as? Bool ?? false
|
2022-06-09 21:22:39 -07:00
|
|
|
self.meshMapCustomTileServer = UserDefaults.standard.string(forKey: "meshMapCustomTileServer") ?? ""
|
2023-02-24 21:14:08 -08:00
|
|
|
self.meshMapUserTrackingMode = UserDefaults.standard.object(forKey: "meshMapUserTrackingMode") as? Int ?? 0
|
2023-03-19 22:11:46 -07:00
|
|
|
self.meshMapShowNodeHistory = UserDefaults.standard.object(forKey: "meshMapShowNodeHistory") as? Bool ?? true
|
|
|
|
|
self.meshMapShowRouteLines = UserDefaults.standard.object(forKey: "meshMapShowRouteLines") as? Bool ?? false
|
2022-06-09 21:22:39 -07:00
|
|
|
}
|
|
|
|
|
}
|