From 090e414439dd1dff5cabcd4146cf8a91edd7f340 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 26 Jan 2023 16:19:51 -0800 Subject: [PATCH] Assorted updates --- .../Views/Map/Custom/MapViewSwiftUI.swift | 16 +++++---- Meshtastic/Views/Map/WaypointFormView.swift | 33 ++++++++++++------- Meshtastic/Views/Settings/Settings.swift | 3 +- de.lproj/Localizable.strings | 1 + en.lproj/Localizable.strings | 1 + zh-Hans.lproj/Localizable.strings | 1 + 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index caa9f52e..56a0d1cc 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -162,12 +162,16 @@ struct MapViewSwiftUI: UIViewRepresentable { } @objc func longPressHandler(_ gesture: UILongPressGestureRecognizer) { - // Screen Position - CGPoint - let location = longPressRecognizer.location(in: self.parent.mapView) - // Map Coordinate - CLLocationCoordinate2D - let coordinate = self.parent.mapView.convert(location, toCoordinateFrom: self.parent.mapView) - // Add annotation: - if coordinate.longitude != LocationHelper.DefaultLocation.longitude && coordinate.latitude != LocationHelper.DefaultLocation.latitude { + + if gesture.state != UIGestureRecognizer.State.ended { + return + } else if gesture.state != UIGestureRecognizer.State.began { + + // Screen Position - CGPoint + let location = longPressRecognizer.location(in: self.parent.mapView) + + // Map Coordinate - CLLocationCoordinate2D + let coordinate = self.parent.mapView.convert(location, toCoordinateFrom: self.parent.mapView) let annotation = MKPointAnnotation() annotation.title = "Dropped Pin" annotation.coordinate = coordinate diff --git a/Meshtastic/Views/Map/WaypointFormView.swift b/Meshtastic/Views/Map/WaypointFormView.swift index 201ba6d9..767a9614 100644 --- a/Meshtastic/Views/Map/WaypointFormView.swift +++ b/Meshtastic/Views/Map/WaypointFormView.swift @@ -25,6 +25,7 @@ struct WaypointFormView: View { @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 + @State private var lockedTo: Int64 = 0 var body: some View { @@ -108,15 +109,15 @@ struct WaypointFormView: View { } } - Toggle(isOn: $expires) { - Label("Expires", systemImage: "clock.badge.xmark") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - if expires { - DatePicker("Expire", selection: $expire, in: Date.now...) - .datePickerStyle(.compact) - .font(.callout) - } +// Toggle(isOn: $expires) { +// Label("Expires", systemImage: "clock.badge.xmark") +// } +// .toggleStyle(SwitchToggleStyle(tint: .accentColor)) +// if expires { +// DatePicker("Expire", selection: $expire, in: Date.now...) +// .datePickerStyle(.compact) +// .font(.callout) +// } Toggle(isOn: $locked) { Label("Locked", systemImage: "lock") } @@ -143,7 +144,12 @@ struct WaypointFormView: View { let unicode = unicodeScalers[unicodeScalers.startIndex].value newWaypoint.icon = unicode if locked { - newWaypoint.lockedTo = UInt32(bleManager.connectedPeripheral!.num) + + if lockedTo == 0 { + newWaypoint.lockedTo = UInt32(bleManager.connectedPeripheral!.num) + } else { + newWaypoint.lockedTo = UInt32(lockedTo) + } } if expire.timeIntervalSince1970 > 0 { newWaypoint.expire = UInt32(expire.timeIntervalSince1970) @@ -213,6 +219,10 @@ struct WaypointFormView: View { } else { expires = false } + if waypoint.locked > 0 { + locked = true + lockedTo = waypoint.locked + } } else { name = "" description = "" @@ -227,8 +237,7 @@ struct WaypointFormView: View { if coordinate.distance(from: LocationHelper.DefaultLocation) == 0.0 { // Too close to apple park, bail out waypointId = 0 - //dismiss() - //print(coordinate.distance(from: LocationHelper.DefaultLocation)) + dismiss() } } } diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index ea7d6d05..87cfd1a8 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -124,8 +124,7 @@ struct Settings: View { Text("lora") } .tag(SettingsSidebar.loraConfig) - .disabled(selectedNode == 0) - //.disabled(selectedNode > 0 && selectedNode != connectedNodeNum) + .disabled(selectedNode > 0 && selectedNode != connectedNodeNum) NavigationLink() { Channels(node: nodes.first(where: { $0.num == connectedNodeNum })) diff --git a/de.lproj/Localizable.strings b/de.lproj/Localizable.strings index 87117b20..7da486b3 100644 --- a/de.lproj/Localizable.strings +++ b/de.lproj/Localizable.strings @@ -169,6 +169,7 @@ "mesh.log.traceroute.received.route %@"="Traceroute Ergebnis: %@"; "mesh.log.wantconfig %@"="Issuing Want Config to %@"; "mesh.log.waypoint.sent %@"="Sent a Waypoint Packet from: %@"; +"mesh.log.waypoint.received %@"="Waypoint Packet received from node: %@"; "message"="Nachricht"; "message.details"="Nachrichtendetails"; "messages"="Nachrichten"; diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index 7f67069a..eb3f3caa 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -169,6 +169,7 @@ "mesh.log.traceroute.sent %@"="Sent a Trace Route Request to node: %@"; "mesh.log.wantconfig %@"="Issuing Want Config to %@"; "mesh.log.waypoint.sent %@"="Sent a Waypoint Packet from: %@"; +"mesh.log.waypoint.received %@"="Waypoint Packet received from node: %@"; "message"="Message"; "message.details"="Message Details"; "messages"="Messages"; diff --git a/zh-Hans.lproj/Localizable.strings b/zh-Hans.lproj/Localizable.strings index 946d2694..8a9f0699 100644 --- a/zh-Hans.lproj/Localizable.strings +++ b/zh-Hans.lproj/Localizable.strings @@ -169,6 +169,7 @@ "mesh.log.traceroute.sent %@"="Sent a Trace Route Request to node: %@"; "mesh.log.wantconfig %@"="Issuing Want Config to %@"; "mesh.log.waypoint.sent %@"="Sent a Waypoint Packet from: %@"; +"mesh.log.waypoint.received %@"="Waypoint Packet received from node: %@"; "message"="消息"; "message.details"="消息详情"; "messages"="消息";