diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index fa8fee4b..c37cac19 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -1314,7 +1314,7 @@ func textMessageAppPacket(packet: MeshPacket, connectedNode: Int64, context: NSM func waypointPacket (packet: MeshPacket, context: NSManagedObjectContext) { - let logString = String.localizedStringWithFormat(NSLocalizedString("mesh.log.waypoint.received %@", comment: "Waypoint Packet received from node: %@"), String(packet.from)) +let logString = String.localizedStringWithFormat(NSLocalizedString("mesh.log.waypoint.received %@", comment: "Waypoint Packet received from node: %@"), String(packet.from)) MeshLogger.log("📍 \(logString)") let fetchWaypointRequest: NSFetchRequest = NSFetchRequest.init(entityName: "WaypointEntity") @@ -1329,12 +1329,12 @@ func waypointPacket (packet: MeshPacket, context: NSManagedObjectContext) { if fetchedWaypoint.isEmpty { let waypoint = WaypointEntity(context: context) - waypoint.id = Int64(UInt32.random(in: UInt32(UInt8.max).. - + \ No newline at end of file diff --git a/Meshtastic/Persistence/WaypointEntityExtension.swift b/Meshtastic/Persistence/WaypointEntityExtension.swift index 1ee65fa4..2de1ae62 100644 --- a/Meshtastic/Persistence/WaypointEntityExtension.swift +++ b/Meshtastic/Persistence/WaypointEntityExtension.swift @@ -49,6 +49,6 @@ extension WaypointEntity { extension WaypointEntity: MKAnnotation { public var coordinate: CLLocationCoordinate2D { waypointCoordinate ?? LocationHelper.DefaultLocation } - public var title: String? { self.title ?? "" } - public var subtitle: String? { self.description } + public var title: String? { name ?? "Dropped Pin" } + public var subtitle: String? { longDescription } } diff --git a/Meshtastic/Views/Map/MapViewSwiftUI.swift b/Meshtastic/Views/Map/MapViewSwiftUI.swift index cfcbd5b3..113ed20b 100644 --- a/Meshtastic/Views/Map/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/MapViewSwiftUI.swift @@ -29,6 +29,7 @@ struct MapViewSwiftUI: UIViewRepresentable { func makeUIView(context: Context) -> MKMapView { // Parameters mapView.addAnnotations(positions) + mapView.addAnnotations(waypoints) mapView.mapType = mapViewType mapView.setRegion(region, animated: true) mapView.setUserTrackingMode(.none, animated: false) @@ -159,7 +160,11 @@ struct MapViewSwiftUI: UIViewRepresentable { case let waypointAnnotation as WaypointEntity: let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "waypoint") as? MKMarkerAnnotationView ?? MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: "Waypoint") annotationView.canShowCallout = true - annotationView.glyphText = "🪧" + if waypointAnnotation.icon == 0 { + annotationView.glyphText = "🪧" + } else { + + } annotationView.clusteringIdentifier = "waypointGroup" annotationView.markerTintColor = UIColor(.green) annotationView.titleVisibility = .visible diff --git a/Meshtastic/Views/Map/WaypointFormView.swift b/Meshtastic/Views/Map/WaypointFormView.swift index 1cbf10dd..aeef93a9 100644 --- a/Meshtastic/Views/Map/WaypointFormView.swift +++ b/Meshtastic/Views/Map/WaypointFormView.swift @@ -17,7 +17,7 @@ struct WaypointFormView: View { @State private var id: Int32? @State private var name: String = "" @State private var description: String = "" - @State private var icon: String = "📍" + @State private var icon: String = "🪧" @State private var expires: Bool = false @State private var expire: Date = Date()// = Date.now.addingTimeInterval(60 * 120) // 1 minute * 120 = 2 Hours @State private var locked: Bool = false @@ -125,6 +125,9 @@ struct WaypointFormView: View { newWaypoint.description_p = description newWaypoint.latitudeI = Int32(coordinate.latitude * 1e7) newWaypoint.longitudeI = Int32(coordinate.longitude * 1e7) + let uni = icon.unicodeScalars // Unicode scalar values of the string + let unicode = uni[uni.startIndex].value // First element as an UInt32 + newWaypoint.icon = unicode //newWaypoint.icon = icon newWaypoint.locked = locked //newWaypoint.expire = expire @@ -132,7 +135,7 @@ struct WaypointFormView: View { dismiss() } label: { - Label("save", systemImage: "square.and.arrow.down") + Label("Send", systemImage: "arrow.up") } .buttonStyle(.bordered) .buttonBorderShape(.capsule) @@ -151,7 +154,3 @@ struct WaypointFormView: View { } } } -//var smiley = "😊" -//var data: NSData = smiley.dataUsingEncoding(NSUTF32LittleEndianStringEncoding, allowLossyConversion: false)! -//var unicode:UInt32 = UInt32() -//data.getBytes(&unicode)