Use legacy map app setting

This commit is contained in:
Garth Vander Houwen 2023-11-11 09:58:54 -08:00
parent 5346b3d0f4
commit 300c677b94
3 changed files with 32 additions and 16 deletions

View file

@ -24,6 +24,7 @@ extension UserDefaults {
case enableOfflineMaps
case mapTileServer
case mapTilesAboveLabels
case mapUseLegacy
}
func reset() {
@ -171,4 +172,13 @@ extension UserDefaults {
UserDefaults.standard.set(newValue, forKey: "mapTilesAboveLabels")
}
}
static var mapUseLegacy: Bool {
get {
UserDefaults.standard.bool(forKey: "mapUseLegacy")
}
set {
UserDefaults.standard.set(newValue, forKey: "mapUseLegacy")
}
}
}

View file

@ -25,12 +25,19 @@ struct ContentView: View {
}
.tag(Tab.nodes)
if #available(iOS 17.0, macOS 14.0, *) {
MeshMap()
//NodeMap()
.tabItem {
Label("map", systemImage: "map")
}
.tag(Tab.map)
if UserDefaults.mapUseLegacy {
NodeMap()
.tabItem {
Label("map", systemImage: "map")
}
.tag(Tab.map)
} else {
MeshMap()
.tabItem {
Label("map", systemImage: "map")
}
.tag(Tab.map)
}
} else {
NodeMap()
.tabItem {

View file

@ -13,6 +13,7 @@ struct AppSettings: View {
@State var meshtasticUsername: String = UserDefaults.meshtasticUsername
@State var provideLocation: Bool = UserDefaults.provideLocation
@State var blockRangeTest: Bool = UserDefaults.blockRangeTest
@State var useLegacyMap: Bool = UserDefaults.mapUseLegacy
@State var provideLocationInterval: Int = UserDefaults.provideLocationInterval
@State private var isPresentingCoreDataResetConfirm = false
@State private var isPresentingDeleteMapTilesConfirm = false
@ -35,6 +36,11 @@ struct AppSettings: View {
Label("range.test.blocked", systemImage: "x.circle")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Toggle(isOn: $useLegacyMap) {
Label("map.use.legacy", systemImage: "map")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
}
Section(header: Text("phone.gps")) {
let accuracy = Measurement(value: locationHelper.locationManager.location?.horizontalAccuracy ?? 300, unit: UnitLength.meters)
@ -123,16 +129,6 @@ struct AppSettings: View {
print("delete all tiles")
}
}
// ForEach(MapTileServer.allCases, id: \.self) { tsl in
// Button {
// tileManager.remove(for: tsl)
// totalDownloadedTileSize = tileManager.getAllDownloadedSize()
// } label: {
// Label("Delete \(tsl.description) Tiles", systemImage: "trash")
// .foregroundColor(.red)
// .font(.footnote)
// }
// }
}
}
}
@ -160,5 +156,8 @@ struct AppSettings: View {
self.bleManager.sendWantConfig()
}
}
.onChange(of: useLegacyMap) { newMapUseLegacy in
UserDefaults.mapUseLegacy = newMapUseLegacy
}
}
}