Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MeshMap: add setting to hide location precision circles #921

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -19883,6 +19883,9 @@
},
"Show Alerts" : {

},
"Show Location Precision" : {

},
"Show Node History" : {

Expand Down
4 changes: 4 additions & 0 deletions Meshtastic/Extensions/UserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extension UserDefaults {
case meshMapRecentering
case meshMapShowNodeHistory
case meshMapShowRouteLines
case meshMapShowLocationPrecision
case enableMapConvexHull
case enableMapRecentering
case enableMapNodeHistoryPins
Expand Down Expand Up @@ -96,6 +97,9 @@ extension UserDefaults {

@UserDefault(.meshMapDistance, defaultValue: 800000)
static var meshMapDistance: Double

@UserDefault(.meshMapShowLocationPrecision, defaultValue: true)
Copy link
Contributor Author

@powersjcb powersjcb Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's three default values related to these configs (which is a bit confusing)

static var meshMapShowLocationPrecision: Bool

@UserDefault(.enableMapWaypoints, defaultValue: false)
static var enableMapWaypoints: Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
Expand Down