mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
More waypoint cleanup
This commit is contained in:
parent
4a3895daf2
commit
b11ae85104
4 changed files with 22 additions and 13 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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" : "") }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue