From 48369fcc04a64fb212ca3a2959a0dd56049599d4 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 21 Oct 2023 15:33:00 -0700 Subject: [PATCH] Map Cleanup, show waypoints button --- Meshtastic/Views/Helpers/CircleText.swift | 53 ++++++++++++------- .../Views/Nodes/Helpers/NodeMapSwiftUI.swift | 52 ++++++++++++------ .../Views/Nodes/Helpers/PositionPopover.swift | 4 +- .../Views/Nodes/Helpers/WaypointPopover.swift | 3 +- 4 files changed, 75 insertions(+), 37 deletions(-) diff --git a/Meshtastic/Views/Helpers/CircleText.swift b/Meshtastic/Views/Helpers/CircleText.swift index da51cf8d..bb3fa07b 100644 --- a/Meshtastic/Views/Helpers/CircleText.swift +++ b/Meshtastic/Views/Helpers/CircleText.swift @@ -19,7 +19,7 @@ struct CircleText: View { Text(text) .textCase(.uppercase) .foregroundColor(color.isLight() ? .black : .white) - .font(.system(size: 500)) + .font(.system(size: 8000)) .minimumScaleFactor(0.001) .frame(width: circleSize * 0.95, height: circleSize * 0.95, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/) } @@ -29,23 +29,40 @@ struct CircleText: View { struct CircleText_Previews: PreviewProvider { static var previews: some View { - VStack { - CircleText(text: "MOMO", color: Color.secondary, circleSize: 80) - .previewLayout(.fixed(width: 300, height: 100)) - CircleText(text: "WWWW", color: Color.accentColor, circleSize: 80) - .previewLayout(.fixed(width: 300, height: 100)) - CircleText(text: "LCP", color: Color.primary, circleSize: 80) - .previewLayout(.fixed(width: 300, height: 100)) - CircleText(text: "69", color: Color.green, circleSize: 80) - .previewLayout(.fixed(width: 300, height: 100)) - CircleText(text: "N1", color: Color.yellow, circleSize: 80) - .previewLayout(.fixed(width: 300, height: 100)) - CircleText(text: "8", color: Color.purple, circleSize: 80) - .previewLayout(.fixed(width: 300, height: 100)) - CircleText(text: "😝", color: Color.red, circleSize: 80) - .previewLayout(.fixed(width: 300, height: 100)) - CircleText(text: "🍔", color: Color.brown, circleSize: 80) - .previewLayout(.fixed(width: 300, height: 100)) + + HStack { + VStack { + + CircleText(text: "N1", color: Color.yellow, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + CircleText(text: "8", color: Color.purple, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + CircleText(text: "😝", color: Color.red, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + CircleText(text: "🍔", color: Color.brown, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + CircleText(text: "👻", color: Color.orange, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + CircleText(text: "🤙", color: Color.orange, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + + } + VStack { + CircleText(text: "69", color: Color.green, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + CircleText(text: "WWWW", color: Color.cyan, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + CircleText(text: "CW-A", color: Color.secondary) + .previewLayout(.fixed(width: 300, height: 100)) + CircleText(text: "CW-A", color: Color.secondary, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + CircleText(text: "MOMO", color: Color.mint, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + CircleText(text: "IIII", color: Color.accentColor, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + CircleText(text: "LCP", color: Color.primary, circleSize: 80) + .previewLayout(.fixed(width: 300, height: 100)) + } } } } diff --git a/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift index 44812c90..7d1593d6 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift @@ -21,11 +21,11 @@ struct NodeMapSwiftUI: View { @State var showUserLocation: Bool = false @State var positions: [PositionEntity] = [] /// Map State User Defaults - @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false - @AppStorage("meshMapShowRouteLines") private var showRouteLines = false - @AppStorage("enableMapConvexHull") private var showConvexHull = true - @AppStorage("enableMapTraffic") private var showTraffic: Bool = true - @AppStorage("enableMapPointsOfInterest") private var showPointsOfInterest: Bool = true + @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = true + @AppStorage("meshMapShowRouteLines") private var showRouteLines = true + @AppStorage("enableMapConvexHull") private var showConvexHull = false + @AppStorage("enableMapTraffic") private var showTraffic: Bool = false + @AppStorage("enableMapPointsOfInterest") private var showPointsOfInterest: Bool = false @AppStorage("mapLayer") private var selectedMapLayer: MapLayer = .hybrid // Map Configuration @Namespace var mapScope @@ -35,6 +35,7 @@ struct NodeMapSwiftUI: View { @State var isLookingAround = false @State var isEditingSettings = false @State var selected: PositionEntity? + @State var showWaypoints = false @State var selectedWaypoint: WaypointEntity? @State var showingPositionPopover = false @@ -80,17 +81,20 @@ struct NodeMapSwiftUI: View { .stroke(Color(nodeColor.darker()), lineWidth: 3) .foregroundStyle(Color(nodeColor).opacity(0.4)) } + /// Waypoint Annotations - ForEach(Array(waypoints), id: \.id) { waypoint in - Annotation(waypoint.name ?? "?", coordinate: waypoint.coordinate) { - ZStack { - CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 35) + if showWaypoints { + ForEach(Array(waypoints), id: \.id) { waypoint in + Annotation(waypoint.name ?? "?", coordinate: waypoint.coordinate) { + ZStack { + CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 35) - .onTapGesture(coordinateSpace: .named("nodemap")) { location in - print("Tapped at \(location)") - let pinLocation = reader.convert(location, from: .local) - selectedWaypoint = (selectedWaypoint == waypoint ? nil : waypoint) - } + .onTapGesture(coordinateSpace: .named("nodemap")) { location in + print("Tapped at \(location)") + let pinLocation = reader.convert(location, from: .local) + selectedWaypoint = (selectedWaypoint == waypoint ? nil : waypoint) + } + } } } } @@ -195,9 +199,7 @@ struct NodeMapSwiftUI: View { } .sheet(item: $selectedWaypoint) { selection in WaypointPopover(waypoint: selection) - .presentationDetents([.fraction(0.3), .medium]) .padding() - .opacity(0.8) } .sheet(isPresented: $isEditingSettings) { VStack { @@ -283,6 +285,8 @@ struct NodeMapSwiftUI: View { #endif } .presentationDetents([.fraction(0.4), .medium]) + .presentationDragIndicator(.visible) + } .onChange(of: node) { let mostRecent = node.positions?.lastObject as? PositionEntity @@ -324,6 +328,22 @@ struct NodeMapSwiftUI: View { .tint(Color(UIColor.secondarySystemBackground)) .foregroundColor(.accentColor) .buttonStyle(.borderedProminent) + + Button(action: { + withAnimation { + showWaypoints = !showWaypoints + } + }) { + Image(systemName: showWaypoints ? "signpost.right.and.left.fill" : "signpost.right.and.left") + .padding(.vertical, 5) + } + .tint(Color(UIColor.secondarySystemBackground)) + .foregroundColor(.accentColor) + .buttonStyle(.borderedProminent) + + + + /// Look Around Button if self.scene != nil { Button(action: { diff --git a/Meshtastic/Views/Nodes/Helpers/PositionPopover.swift b/Meshtastic/Views/Nodes/Helpers/PositionPopover.swift index acac8ddf..93f5c35e 100644 --- a/Meshtastic/Views/Nodes/Helpers/PositionPopover.swift +++ b/Meshtastic/Views/Nodes/Helpers/PositionPopover.swift @@ -12,8 +12,8 @@ struct PositionPopover: View { var position: PositionEntity let distanceFormatter = MKDistanceFormatter() var body: some View { - VStack { - HStack { + VStack (alignment: .leading) { + HStack { CircleText(text: position.nodePosition?.user?.shortName ?? "?", color: Color(UIColor(hex: UInt32(position.nodePosition?.user?.num ?? 0)))) Text(position.nodePosition?.user?.longName ?? "Unknown") .font(.title3) diff --git a/Meshtastic/Views/Nodes/Helpers/WaypointPopover.swift b/Meshtastic/Views/Nodes/Helpers/WaypointPopover.swift index 3eae5eb8..9eb2e16e 100644 --- a/Meshtastic/Views/Nodes/Helpers/WaypointPopover.swift +++ b/Meshtastic/Views/Nodes/Helpers/WaypointPopover.swift @@ -13,7 +13,7 @@ struct WaypointPopover: View { var waypoint: WaypointEntity let distanceFormatter = MKDistanceFormatter() var body: some View { - VStack { + VStack (alignment: .leading) { HStack { CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange) Text(waypoint.name ?? "?") @@ -119,6 +119,7 @@ struct WaypointPopover: View { .padding() #endif } + .presentationDetents([.fraction(0.3), .medium]) .tag(waypoint.id) } }