Assorted changes

This commit is contained in:
Garth Vander Houwen 2024-05-24 18:15:53 -07:00
parent dbc05605d6
commit 3046361dd0
8 changed files with 38 additions and 24 deletions

View file

@ -871,8 +871,8 @@ func textMessageAppPacket(packet: MeshPacket, wantRangeTestPackets: Bool, connec
title: "\(newMessage.fromUser?.longName ?? "unknown".localized)",
subtitle: "AKA \(newMessage.fromUser?.shortName ?? "?")",
content: messageText!,
target: "message",
path: "meshtastic://open-dm?userid=\(newMessage.fromUser?.num ?? 0)&id=\(newMessage.messageId)"
target: "messages",
path: "meshtastic://messages?userNum=\(newMessage.fromUser?.num ?? 0)&messageId=\(newMessage.messageId)"
)
]
manager.schedule()
@ -904,7 +904,7 @@ func textMessageAppPacket(packet: MeshPacket, wantRangeTestPackets: Bool, connec
title: "\(newMessage.fromUser?.longName ?? "unknown".localized)",
subtitle: "AKA \(newMessage.fromUser?.shortName ?? "?")",
content: messageText!,
target: "message",
target: "messages",
path: "meshtastic://messages?channel=\(newMessage.channel)&messageId=\(newMessage.messageId)")
]
manager.schedule()

View file

@ -11,7 +11,6 @@ class MeshtasticAppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificat
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
print("🚀 Meshtstic Apple App launched!")
// Default User Default Values
UserDefaults.standard.register(defaults: ["blockRangeTest" : true])
UserDefaults.standard.register(defaults: ["meshMapRecentering" : true])
UserDefaults.standard.register(defaults: ["meshMapShowNodeHistory" : true])
UserDefaults.standard.register(defaults: ["meshMapShowRouteLines" : true])
@ -27,10 +26,11 @@ class MeshtasticAppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificat
}
return true
}
// Lets us show the notification in the app in the foreground
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.banner)
completionHandler([.list, .banner, .sound])
}
// This method is called when user clicked on the notification
// This method is called when a user clicks on the notification
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
let targetValue = userInfo["target"] as? String

View file

@ -35,6 +35,7 @@ struct UserList: View {
private var users: FetchedResults<UserEntity>
@State var node: NodeInfoEntity?
@State var selectedUserNum: Int64?
@State private var userSelection: UserEntity? // Nothing selected by default.
@State private var isPresentingDeleteUserMessagesConfirm: Bool = false
@ -203,6 +204,10 @@ struct UserList: View {
.onChange(of: distanceFilter) { _ in
searchUserList()
}
.onChange(of: selectedUserNum) { newUserNum in
userSelection = users.first(where: { $0.num == newUserNum })
print(userSelection)
}
.onAppear {
if self.bleManager.context == nil {
self.bleManager.context = context

View file

@ -40,13 +40,14 @@ struct MeshMapContent: MapContent {
@MapContentBuilder
var meshMap: some MapContent {
let lineCoords = Array(positions).compactMap({(position) -> CLLocationCoordinate2D in
return position.nodeCoordinate ?? LocationsHandler.DefaultLocation
let loraNodes = positions.filter { $0.nodePosition?.viaMqtt ?? true == false }
let loraCoords = Array(loraNodes).compactMap({(position) -> CLLocationCoordinate2D in
return position.nodeCoordinate ?? LocationsHandler.DefaultLocation
})
/// Convex Hull
if showConvexHull {
if lineCoords.count > 0 {
let hull = lineCoords.getConvexHull()
if loraCoords.count > 0 {
let hull = loraCoords.getConvexHull()
MapPolygon(coordinates: hull)
.stroke(.blue, lineWidth: 3)
.foregroundStyle(.indigo.opacity(0.4))

View file

@ -40,6 +40,7 @@ struct NodeMapContent: MapContent {
let lineCoords = positionArray.compactMap({(position) -> CLLocationCoordinate2D in
return position.nodeCoordinate ?? LocationsHandler.DefaultLocation
})
/// Node Color from node.num
let nodeColor = UIColor(hex: UInt32(node.num))
@ -58,13 +59,17 @@ struct NodeMapContent: MapContent {
.stroke(.white, lineWidth: 2)
}
}
let loraNodes = positions.filter { $0.nodePosition?.viaMqtt ?? true == false }
let loraCoords = Array(loraNodes).compactMap({(position) -> CLLocationCoordinate2D in
return position.nodeCoordinate ?? LocationsHandler.DefaultLocation
})
/// Convex Hull
if showConvexHull {
if lineCoords.count > 0 {
let hull = lineCoords.getConvexHull()
if loraCoords.count > 0 {
let hull = loraCoords.getConvexHull()
MapPolygon(coordinates: hull)
.stroke(Color(nodeColor.darker()), lineWidth: 3)
.foregroundStyle(Color(nodeColor).opacity(0.4))
.stroke(.blue, lineWidth: 3)
.foregroundStyle(.indigo.opacity(0.4))
}
}
/// Route Lines

View file

@ -87,13 +87,13 @@ struct NodeMapSwiftUI: View {
switch selectedMapLayer {
case .standard:
UserDefaults.mapLayer = newMapLayer
mapStyle = MapStyle.standard(elevation: .realistic, pointsOfInterest: showPointsOfInterest ? .all : .excludingAll, showsTraffic: showTraffic)
mapStyle = MapStyle.standard(elevation: .flat, pointsOfInterest: showPointsOfInterest ? .all : .excludingAll, showsTraffic: showTraffic)
case .hybrid:
UserDefaults.mapLayer = newMapLayer
mapStyle = MapStyle.hybrid(elevation: .realistic, pointsOfInterest: showPointsOfInterest ? .all : .excludingAll, showsTraffic: showTraffic)
mapStyle = MapStyle.hybrid(elevation: .flat, pointsOfInterest: showPointsOfInterest ? .all : .excludingAll, showsTraffic: showTraffic)
case .satellite:
UserDefaults.mapLayer = newMapLayer
mapStyle = MapStyle.imagery(elevation: .realistic)
mapStyle = MapStyle.imagery(elevation: .flat)
case .offline:
return
}
@ -118,13 +118,13 @@ struct NodeMapSwiftUI: View {
UIApplication.shared.isIdleTimerDisabled = true
switch selectedMapLayer {
case .standard:
mapStyle = MapStyle.standard(elevation: .realistic, pointsOfInterest: showPointsOfInterest ? .all : .excludingAll, showsTraffic: showTraffic)
mapStyle = MapStyle.standard(elevation: .flat, pointsOfInterest: showPointsOfInterest ? .all : .excludingAll, showsTraffic: showTraffic)
case .hybrid:
mapStyle = MapStyle.hybrid(elevation: .realistic, pointsOfInterest: showPointsOfInterest ? .all : .excludingAll, showsTraffic: showTraffic)
mapStyle = MapStyle.hybrid(elevation: .flat, pointsOfInterest: showPointsOfInterest ? .all : .excludingAll, showsTraffic: showTraffic)
case .satellite:
mapStyle = MapStyle.imagery(elevation: .realistic)
mapStyle = MapStyle.imagery(elevation: .flat)
case .offline:
mapStyle = MapStyle.hybrid(elevation: .realistic, pointsOfInterest: showPointsOfInterest ? .all : .excludingAll, showsTraffic: showTraffic)
mapStyle = MapStyle.hybrid(elevation: .flat, pointsOfInterest: showPointsOfInterest ? .all : .excludingAll, showsTraffic: showTraffic)
}
mostRecent = node.positions?.lastObject as? PositionEntity
if node.positions?.count ?? 0 > 1 {

View file

@ -35,7 +35,7 @@ struct NodeDetail: View {
Label(
title: {
Text("\("uptime".localized)")
.font(.title2)+Text(": \(components)")
.font(.title3)+Text(": \(components)")
.font(.title3)
.foregroundColor(Color.gray)
},

View file

@ -316,9 +316,12 @@ struct NodeList: View {
}
.onChange(of: (appState.navigationPath)) { newPath in
if ((newPath?.hasPrefix("meshtastic://nodes")) != nil) {
guard let deepLink = newPath else {
return
}
if deepLink.hasPrefix("meshtastic://nodes") {
if let urlComponent = URLComponents(string: newPath ?? "") {
if let urlComponent = URLComponents(string: deepLink) {
let queryItems = urlComponent.queryItems
let nodeNum = queryItems?.first(where: { $0.name == "nodenum" })?.value
if nodeNum == nil {