From 3840c049485ded1ecefb43915331fb9f4a600213 Mon Sep 17 00:00:00 2001 From: Jacob Powers Date: Sun, 8 Sep 2024 05:45:05 +0000 Subject: [PATCH 1/3] add new toggle for location precision --- Localizable.xcstrings | 3 +++ Meshtastic/Extensions/UserDefaults.swift | 4 ++++ Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift | 8 ++++++++ Meshtastic/Views/Nodes/MeshMap.swift | 7 ++++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Localizable.xcstrings b/Localizable.xcstrings index 05c2bbb80..506eaf52e 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -19883,6 +19883,9 @@ }, "Show Alerts" : { + }, + "Show Location Precision" : { + }, "Show Node History" : { diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index 740f04e27..747352b5a 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -50,6 +50,7 @@ extension UserDefaults { case meshMapRecentering case meshMapShowNodeHistory case meshMapShowRouteLines + case meshMapShowLocationPrecision case enableMapConvexHull case enableMapRecentering case enableMapNodeHistoryPins @@ -96,6 +97,9 @@ extension UserDefaults { @UserDefault(.meshMapDistance, defaultValue: 800000) static var meshMapDistance: Double + + @UserDefault(.meshMapShowLocationPrecision, defaultValue: true) + static var meshMapShowLocationPrecision: Bool @UserDefault(.enableMapWaypoints, defaultValue: false) static var enableMapWaypoints: Bool diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift index 38b96a5d4..2fdae0eb6 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift @@ -18,6 +18,7 @@ struct MapSettingsForm: View { @AppStorage("meshMapShowRouteLines") private var routeLines = false @AppStorage("enableMapConvexHull") private var convexHull = false @AppStorage("enableMapWaypoints") private var waypoints = true + @AppStorage("meshMapShowLocationPrecision") private var showLocationPrecision = true @Binding var traffic: Bool @Binding var pointsOfInterest: Bool @Binding var mapLayer: MapLayer @@ -56,6 +57,13 @@ struct MapSettingsForm: View { .onChange(of: meshMapDistance) { newMeshMapDistance in UserDefaults.meshMapDistance = newMeshMapDistance } + Toggle(isOn: $showLocationPrecision) { + Label("Show Location Precision", systemImage: "circle.dotted.and.circle") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .onTapGesture { + UserDefaults.meshMapShowLocationPrecision = !showLocationPrecision + } Toggle(isOn: $waypoints) { Label("Show Waypoints ", systemImage: "signpost.right.and.left") } diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index 595abb154..c0793b934 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -120,7 +120,12 @@ struct MeshMap: View { .padding() } .sheet(isPresented: $editingSettings) { - MapSettingsForm(traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMap: $isMeshMap) + MapSettingsForm( + traffic: $showTraffic, + pointsOfInterest: $showPointsOfInterest, + mapLayer: $selectedMapLayer, + meshMap: $isMeshMap + ) } .onChange(of: router.navigationState) { guard case .map = router.navigationState.selectedTab else { return } From bef2c99422f6d88b15655d307018f4c98de69cc6 Mon Sep 17 00:00:00 2001 From: Jacob Powers Date: Sun, 8 Sep 2024 05:52:18 +0000 Subject: [PATCH 2/3] hide location precision circles --- .../Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift index edfec3bee..f0097aab8 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift @@ -14,6 +14,7 @@ struct MeshMapContent: MapContent { /// Parameters @Binding var showUserLocation: Bool @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false + @AppStorage("meshMapShowLocationPrecision") private var showLocationPrecision = true @AppStorage("meshMapShowRouteLines") private var showRouteLines = false @AppStorage("enableMapConvexHull") private var showConvexHull = false @Binding var showTraffic: Bool @@ -134,7 +135,7 @@ struct MeshMapContent: MapContent { if 10...19 ~= position.precisionBits { let pp = PositionPrecision(rawValue: Int(position.precisionBits)) let radius: CLLocationDistance = pp?.precisionMeters ?? 0 - if radius > 0.0 { + if radius > 0.0 && showLocationPrecision { MapCircle(center: position.coordinate, radius: radius) .foregroundStyle(Color(nodeColor).opacity(0.25)) .stroke(.white, lineWidth: 2) From 279e49c9534fe74500cda8a504b7652f9dc1538b Mon Sep 17 00:00:00 2001 From: Jacob Powers Date: Sun, 8 Sep 2024 06:05:24 +0000 Subject: [PATCH 3/3] revert code style diff --- Meshtastic/Views/Nodes/MeshMap.swift | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index c0793b934..595abb154 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -120,12 +120,7 @@ struct MeshMap: View { .padding() } .sheet(isPresented: $editingSettings) { - MapSettingsForm( - traffic: $showTraffic, - pointsOfInterest: $showPointsOfInterest, - mapLayer: $selectedMapLayer, - meshMap: $isMeshMap - ) + MapSettingsForm(traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMap: $isMeshMap) } .onChange(of: router.navigationState) { guard case .map = router.navigationState.selectedTab else { return }