diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index 97e99b98..07c230ad 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -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") + } + } } diff --git a/Meshtastic/Views/ContentView.swift b/Meshtastic/Views/ContentView.swift index c3e03235..75e6fb8e 100644 --- a/Meshtastic/Views/ContentView.swift +++ b/Meshtastic/Views/ContentView.swift @@ -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 { diff --git a/Meshtastic/Views/Settings/AppSettings.swift b/Meshtastic/Views/Settings/AppSettings.swift index 859f5a3f..f7a3bf16 100644 --- a/Meshtastic/Views/Settings/AppSettings.swift +++ b/Meshtastic/Views/Settings/AppSettings.swift @@ -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 + } } }