From d59eb073260bba862b1c657f4954d1b1f4920932 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 17 Feb 2024 15:37:28 -0800 Subject: [PATCH] Turn of node history and route lines on the mesh map --- Meshtastic.xcodeproj/project.pbxproj | 8 +-- .../Nodes/Helpers/Map/MapSettingsForm.swift | 33 ++++++------ .../Nodes/Helpers/Map/NodeMapSwiftUI.swift | 3 +- Meshtastic/Views/Nodes/MeshMap.swift | 53 +------------------ 4 files changed, 26 insertions(+), 71 deletions(-) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index c7601ad9..c6bef2b3 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -1545,7 +1545,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.2.24; + MARKETING_VERSION = 2.2.23; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1579,7 +1579,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.2.24; + MARKETING_VERSION = 2.2.23; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1701,7 +1701,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.2.24; + MARKETING_VERSION = 2.2.23; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1734,7 +1734,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.2.24; + MARKETING_VERSION = 2.2.23; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift index f094d5e8..4c18ef19 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapSettingsForm.swift @@ -19,6 +19,7 @@ struct MapSettingsForm: View { @Binding var traffic: Bool @Binding var pointsOfInterest: Bool @Binding var mapLayer: MapLayer + @Binding var meshMap: Bool var body: some View { @@ -38,21 +39,23 @@ struct MapSettingsForm: View { .onChange(of: mapLayer) { newMapLayer in UserDefaults.mapLayer = newMapLayer } - Toggle(isOn: $nodeHistory) { - Label("Node History", systemImage: "building.columns.fill") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - .onTapGesture { - self.nodeHistory.toggle() - UserDefaults.enableMapNodeHistoryPins = self.nodeHistory - } - Toggle(isOn: $routeLines) { - Label("Route Lines", systemImage: "road.lanes") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - .onTapGesture { - self.routeLines.toggle() - UserDefaults.enableMapRouteLines = self.routeLines + if !meshMap { + Toggle(isOn: $nodeHistory) { + Label("Node History", systemImage: "building.columns.fill") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .onTapGesture { + self.nodeHistory.toggle() + UserDefaults.enableMapNodeHistoryPins = self.nodeHistory + } + Toggle(isOn: $routeLines) { + Label("Route Lines", systemImage: "road.lanes") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + .onTapGesture { + self.routeLines.toggle() + UserDefaults.enableMapRouteLines = self.routeLines + } } Toggle(isOn: $convexHull) { Label("Convex Hull", systemImage: "button.angledbottom.horizontal.right") diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index 23eca04b..40dd5271 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -38,6 +38,7 @@ struct NodeMapSwiftUI: View { @State var selectedPosition: PositionEntity? @State var showWaypoints = false @State var selectedWaypoint: WaypointEntity? + @State var isMeshMap = false @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: false)], predicate: NSPredicate( @@ -207,7 +208,7 @@ struct NodeMapSwiftUI: View { .padding() } .sheet(isPresented: $isEditingSettings) { - MapSettingsForm(nodeHistory: $showNodeHistory, routeLines: $showRouteLines, convexHull: $showConvexHull, traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer) + MapSettingsForm(nodeHistory: $showNodeHistory, routeLines: $showRouteLines, convexHull: $showConvexHull, traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMap: $isMeshMap) .onChange(of: (selectedMapLayer)) { newMapLayer in switch selectedMapLayer { case .standard: diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index dfed0c38..5263bc37 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -40,6 +40,7 @@ struct MeshMap: View { @State var editingWaypoint: WaypointEntity? @State var selectedWaypoint: WaypointEntity? @State var newWaypointCoord :CLLocationCoordinate2D? + @State var isMeshMap = true var delay: Double = 0 @State private var scale: CGFloat = 0.5 @@ -147,54 +148,6 @@ struct MeshMap: View { .stroke(Color(UIColor(hex: UInt32(route.color))), style: solid) } - /// Node Route Lines - if showRouteLines { - let nodePositions = Array(position.nodePosition!.positions!) as! [PositionEntity] - let routeCoords = nodePositions.compactMap({(pos) -> CLLocationCoordinate2D in - return pos.nodeCoordinate ?? LocationHelper.DefaultLocation - }) - let gradient = LinearGradient( - colors: [Color(nodeColor.lighter().lighter()), Color(nodeColor.lighter()), Color(nodeColor)], - startPoint: .leading, endPoint: .trailing - ) - let dashed = StrokeStyle( - lineWidth: 3, - lineCap: .round, lineJoin: .round, dash: [10, 10] - ) - MapPolyline(coordinates: routeCoords) - .stroke(gradient, style: dashed) - } - /// Node History - ForEach(Array(position.nodePosition!.positions!) as! [PositionEntity], id: \.self) { (mappin: PositionEntity) in - if showNodeHistory { - if mappin.latest == false && mappin.nodePosition?.user?.vip ?? false { - let pf = PositionFlags(rawValue: Int(mappin.nodePosition?.metadata?.positionFlags ?? 771)) - let headingDegrees = Angle.degrees(Double(mappin.heading)) - Annotation("", coordinate: mappin.coordinate) { - LazyVStack { - if pf.contains(.Heading) { - Image(systemName: "location.north.circle") - .resizable() - .scaledToFit() - .foregroundStyle(Color(UIColor(hex: UInt32(mappin.nodePosition?.num ?? 0))).isLight() ? .black : .white) - .background(Color(UIColor(hex: UInt32(mappin.nodePosition?.num ?? 0)))) - .clipShape(Circle()) - .rotationEffect(headingDegrees) - .frame(width: 16, height: 16) - - } else { - Circle() - .fill(Color(UIColor(hex: UInt32(mappin.nodePosition?.num ?? 0)))) - .strokeBorder(Color(UIColor(hex: UInt32(mappin.nodePosition?.num ?? 0))).isLight() ? .black : .white ,lineWidth: 2) - .frame(width: 12, height: 12) - } - } - } - .annotationTitles(.hidden) - .annotationSubtitles(.hidden) - } - } - } } /// Waypoint Annotations @@ -216,8 +169,6 @@ struct MeshMap: View { .mapControls { MapScaleView(scope: mapScope) .mapControlVisibility(.automatic) - MapUserLocationButton(scope: mapScope) - .mapControlVisibility(showUserLocation ? .visible : .hidden) MapPitchToggle(scope: mapScope) .mapControlVisibility(.automatic) MapCompass(scope: mapScope) @@ -253,7 +204,7 @@ struct MeshMap: View { .padding() } .sheet(isPresented: $isEditingSettings) { - MapSettingsForm(nodeHistory: $showNodeHistory, routeLines: $showRouteLines, convexHull: $showConvexHull, traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer) + MapSettingsForm(nodeHistory: $showNodeHistory, routeLines: $showRouteLines, convexHull: $showConvexHull, traffic: $showTraffic, pointsOfInterest: $showPointsOfInterest, mapLayer: $selectedMapLayer, meshMap: $isMeshMap) } .onChange(of: (appState.navigationPath)) { newPath in