mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
98 lines
3.5 KiB
Swift
98 lines
3.5 KiB
Swift
//
|
|
// UserSettings.swift
|
|
// MeshtasticApple
|
|
//
|
|
// 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")
|
|
UserDefaults.standard.synchronize()
|
|
}
|
|
}
|
|
@Published var preferredPeripheralId: String {
|
|
didSet {
|
|
UserDefaults.standard.set(preferredPeripheralId, forKey: "preferredPeripheralId")
|
|
UserDefaults.standard.synchronize()
|
|
}
|
|
}
|
|
@Published var provideLocation: Bool {
|
|
didSet {
|
|
UserDefaults.standard.set(provideLocation, forKey: "provideLocation")
|
|
}
|
|
}
|
|
@Published var provideLocationInterval: Int {
|
|
didSet {
|
|
UserDefaults.standard.set(provideLocationInterval, forKey: "provideLocationInterval")
|
|
UserDefaults.standard.synchronize()
|
|
}
|
|
}
|
|
@Published var keyboardType: Int {
|
|
didSet {
|
|
UserDefaults.standard.set(keyboardType, forKey: "keyboardType")
|
|
UserDefaults.standard.synchronize()
|
|
}
|
|
}
|
|
@Published var meshMapType: String {
|
|
didSet {
|
|
UserDefaults.standard.set(meshMapType, forKey: "meshMapType")
|
|
UserDefaults.standard.synchronize()
|
|
}
|
|
}
|
|
@Published var meshMapCenteringMode: Int {
|
|
didSet {
|
|
UserDefaults.standard.set(meshMapCenteringMode, forKey: "meshMapCenteringMode")
|
|
UserDefaults.standard.synchronize()
|
|
}
|
|
}
|
|
@Published var meshMapRecentering: Bool {
|
|
didSet {
|
|
UserDefaults.standard.set(meshMapRecentering, forKey: "meshMapRecentering")
|
|
UserDefaults.standard.synchronize()
|
|
}
|
|
}
|
|
@Published var meshMapCustomTileServer: String {
|
|
didSet {
|
|
UserDefaults.standard.set(meshMapCustomTileServer, forKey: "meshMapCustomTileServer")
|
|
UserDefaults.standard.synchronize()
|
|
}
|
|
}
|
|
@Published var meshMapUserTrackingMode: Int {
|
|
didSet {
|
|
UserDefaults.standard.set(meshMapUserTrackingMode, forKey: "meshMapUserTrackingMode")
|
|
UserDefaults.standard.synchronize()
|
|
}
|
|
}
|
|
@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()
|
|
}
|
|
}
|
|
|
|
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
|
|
self.meshMapType = UserDefaults.standard.string(forKey: "meshMapType") ?? "standard"
|
|
self.meshMapCenteringMode = UserDefaults.standard.object(forKey: "meshMapCenteringMode") as? Int ?? 0
|
|
self.meshMapRecentering = UserDefaults.standard.object(forKey: "meshMapRecentering") as? Bool ?? false
|
|
self.meshMapCustomTileServer = UserDefaults.standard.string(forKey: "meshMapCustomTileServer") ?? ""
|
|
self.meshMapUserTrackingMode = UserDefaults.standard.object(forKey: "meshMapUserTrackingMode") as? Int ?? 0
|
|
self.meshMapShowNodeHistory = UserDefaults.standard.object(forKey: "meshMapShowNodeHistory") as? Bool ?? true
|
|
self.meshMapShowRouteLines = UserDefaults.standard.object(forKey: "meshMapShowRouteLines") as? Bool ?? false
|
|
}
|
|
}
|