diff --git a/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift b/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift index 4c889031..f60337cb 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift @@ -42,7 +42,7 @@ struct NodeDetail: View { Divider() NavigationLink { if #available (iOS 17, macOS 14, *) { - NodeMapSwiftUI(node: node) + NodeMapSwiftUI(node: node, showUserLocation: connectedNode?.num ?? 0 == node.num) } else { NodeMapControl(node: node) } diff --git a/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift index 0545e686..43f991f1 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift @@ -15,6 +15,9 @@ import WeatherKit struct NodeMapSwiftUI: View { @Environment(\.managedObjectContext) var context @EnvironmentObject var bleManager: BLEManager + /// Parameters + @ObservedObject var node: NodeInfoEntity + @State var showUserLocation: Bool = false /// Map State @Namespace var mapScope @AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false @@ -27,20 +30,16 @@ struct NodeMapSwiftUI: View { @State private var scene: MKLookAroundScene? @State private var isLookingAround = false @State private var isEditingSettings = false - @State private var showUserLocation: Bool = false - @State private var showConvexHull = true - @State var selected: PositionEntity? + @State private var selected: PositionEntity? + @State private var showingPopover = false /// Data - @ObservedObject var node: NodeInfoEntity @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: false)], predicate: NSPredicate( format: "expire == nil || expire >= %@", Date() as NSDate ), animation: .none) private var waypoints: FetchedResults - @State private var showingPopover = false - var body: some View { let nodeColor = UIColor(hex: UInt32(node.num)) let positionArray = node.positions?.array as? [PositionEntity] ?? [] diff --git a/Meshtastic/Views/Nodes/Helpers/PositionPopover.swift b/Meshtastic/Views/Nodes/Helpers/PositionPopover.swift index 58928cde..f1070518 100644 --- a/Meshtastic/Views/Nodes/Helpers/PositionPopover.swift +++ b/Meshtastic/Views/Nodes/Helpers/PositionPopover.swift @@ -17,6 +17,7 @@ struct PositionPopover: View { CircleText(text: position.nodePosition?.user?.shortName ?? "?", color: Color(UIColor(hex: UInt32(position.nodePosition?.user?.num ?? 0)))) Text(position.nodePosition?.user?.longName ?? "Unknown") .font(.title3) + let degrees = Angle.degrees(Double(position.heading)) } Divider() VStack (alignment: .leading) { @@ -45,7 +46,6 @@ struct PositionPopover: View { /// Altitude Label { Text("Altitude: \(distanceFormatter.string(fromDistance: Double(position.altitude)))") - // .font(.footnote) .foregroundColor(.primary) } icon: { Image(systemName: "mountain.2.fill") @@ -58,7 +58,6 @@ struct PositionPopover: View { if pf.contains(.Satsinview) { Label { Text("Sats in view: \(String(position.satsInView))") - // .font(.footnote) .foregroundColor(.primary) } icon: { Image(systemName: "sparkles") @@ -71,7 +70,6 @@ struct PositionPopover: View { if pf.contains(.SeqNo) { Label { Text("Sequence: \(String(position.seqNo))") - // .font(.footnote) .foregroundColor(.primary) } icon: { Image(systemName: "number") @@ -82,7 +80,18 @@ struct PositionPopover: View { } /// Heading // if pf.contains(.Heading) { -// Text("Heading: \(Int32(position.heading))") +// let degrees = Angle.degrees(Double(position.heading)) +// Label { +// let heading = Measurement(value: degrees.degrees, unit: UnitAngle.degrees) +// Text("Heading: \(heading.formatted())") +// .foregroundColor(.primary) +// } icon: { +// Image(systemName: "location.north") +// .symbolRenderingMode(.hierarchical) +// .frame(width: 35) +// .rotationEffect(degrees) +// } +// .padding(.bottom, 5) // } /// Speed if pf.contains(.Speed) {