diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index df86d362..fc23f06e 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -1335,7 +1335,7 @@ func waypointPacket (packet: MeshPacket, context: NSManagedObjectContext) { waypoint.longitudeI = waypointMessage.longitudeI waypoint.icon = Int64(waypointMessage.icon) waypoint.locked = waypointMessage.locked - if waypointMessage.expire != 0 { + if waypointMessage.expire > 0 { waypoint.expire = Date(timeIntervalSince1970: TimeInterval(Int64(waypointMessage.expire))) } do { @@ -1354,7 +1354,7 @@ func waypointPacket (packet: MeshPacket, context: NSManagedObjectContext) { fetchedWaypoint[0].longitudeI = waypointMessage.longitudeI fetchedWaypoint[0].icon = Int64(waypointMessage.icon) fetchedWaypoint[0].locked = waypointMessage.locked - if waypointMessage.expire != 0 { + if waypointMessage.expire > 0 { fetchedWaypoint[0].expire = Date(timeIntervalSince1970: TimeInterval(Int64(waypointMessage.expire))) } do { diff --git a/Meshtastic/Persistence/WaypointEntityExtension.swift b/Meshtastic/Persistence/WaypointEntityExtension.swift index 2de1ae62..4edd9566 100644 --- a/Meshtastic/Persistence/WaypointEntityExtension.swift +++ b/Meshtastic/Persistence/WaypointEntityExtension.swift @@ -50,5 +50,8 @@ extension WaypointEntity { extension WaypointEntity: MKAnnotation { public var coordinate: CLLocationCoordinate2D { waypointCoordinate ?? LocationHelper.DefaultLocation } public var title: String? { name ?? "Dropped Pin" } - public var subtitle: String? { longDescription } + public var subtitle: String? { + (longDescription ?? "") + + String(expire != nil ? "\nāŒ› Expires \(String(describing: expire?.formatted()))" : "") + + String(locked ? "\nšŸ”’ Locked" : "") } } diff --git a/Meshtastic/Views/Map/MapViewSwiftUI.swift b/Meshtastic/Views/Map/MapViewSwiftUI.swift index 2e3570cc..4bdd7001 100644 --- a/Meshtastic/Views/Map/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/MapViewSwiftUI.swift @@ -164,9 +164,9 @@ struct MapViewSwiftUI: UIViewRepresentable { annotationView.canShowCallout = true if waypointAnnotation.icon == 0 { print(waypointAnnotation.icon) - annotationView.glyphText = "🪧" + annotationView.glyphText = "šŸ“" } else { - annotationView.glyphText = String(UnicodeScalar(Int(waypointAnnotation.icon)) ?? "🪧") + annotationView.glyphText = String(UnicodeScalar(Int(waypointAnnotation.icon)) ?? "šŸ“") } annotationView.clusteringIdentifier = "waypointGroup" annotationView.markerTintColor = UIColor(.indigo) diff --git a/Meshtastic/Views/Map/WaypointFormView.swift b/Meshtastic/Views/Map/WaypointFormView.swift index aeef93a9..5d9bf432 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,21 +125,27 @@ 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 + // Unicode scalar value for the icon emoji string + let unicodeScalers = icon.unicodeScalars + // First element as an UInt32 + let unicode = unicodeScalers[unicodeScalers.startIndex].value newWaypoint.icon = unicode - //newWaypoint.icon = icon newWaypoint.locked = locked - //newWaypoint.expire = expire - bleManager.sendWaypoint(waypoint: newWaypoint) - dismiss() - + if expire.timeIntervalSince1970 > 0 { + newWaypoint.expire = UInt32(expire.timeIntervalSince1970) + } + if bleManager.sendWaypoint(waypoint: newWaypoint) { + dismiss() + } else { + + } } label: { Label("Send", systemImage: "arrow.up") } .buttonStyle(.bordered) .buttonBorderShape(.capsule) .controlSize(.large) + .disabled(bleManager.connectedPeripheral == nil) .padding() Button {