From 6cf2e9e28b5f90827c9aa51e1de1167831afeaa0 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Wed, 16 Nov 2022 08:07:00 -0800 Subject: [PATCH] Share position feature for catalyst --- .../Views/Messages/ChannelMessageList.swift | 29 ++++++++++++ .../Views/Messages/UserMessageList.swift | 45 ++++++++++++++----- 2 files changed, 62 insertions(+), 12 deletions(-) diff --git a/Meshtastic/Views/Messages/ChannelMessageList.swift b/Meshtastic/Views/Messages/ChannelMessageList.swift index 01860ea5..3daf7324 100644 --- a/Meshtastic/Views/Messages/ChannelMessageList.swift +++ b/Meshtastic/Views/Messages/ChannelMessageList.swift @@ -230,6 +230,35 @@ struct ChannelMessageList: View { } }) } + #if targetEnvironment(macCatalyst) + HStack { + Spacer() + Button { + let userLongName = bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.longName : "Unknown" + sendPositionWithMessage = true + if userSettings.meshtasticUsername.count > 0 { + + typingMessage = "📍 " + userSettings.meshtasticUsername + " has shared their position with you from node " + userLongName + + } else { + + typingMessage = "📍 " + userLongName + " has shared their position with you." + } + + } label: { + Text("Share Position") + Image(systemName: "mappin.and.ellipse") + .symbolRenderingMode(.hierarchical) + .imageScale(.large).foregroundColor(.accentColor) + } + ProgressView("Bytes: \(totalBytes) / \(maxbytes)", value: Double(totalBytes), total: Double(maxbytes)) + .frame(width: 130) + .padding(5) + .font(.subheadline) + .accentColor(.accentColor) + .padding(.trailing) + } + #endif HStack(alignment: .top) { ZStack { diff --git a/Meshtastic/Views/Messages/UserMessageList.swift b/Meshtastic/Views/Messages/UserMessageList.swift index 6ebea97b..a60b195d 100644 --- a/Meshtastic/Views/Messages/UserMessageList.swift +++ b/Meshtastic/Views/Messages/UserMessageList.swift @@ -232,8 +232,35 @@ struct UserMessageList: View { } }) } - HStack(alignment: .top) { + #if targetEnvironment(macCatalyst) + HStack { + Spacer() + Button { + let userLongName = bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.longName : "Unknown" + sendPositionWithMessage = true + + if userSettings.meshtasticUsername.count > 0 { + typingMessage = "📍 " + userSettings.meshtasticUsername + " has shared their position with you from node " + userLongName + " and requested a response with your position." + } else { + typingMessage = "📍 " + userLongName + " has shared their position and requested a response with your position." + } + + } label: { + Text("Share Position") + Image(systemName: "mappin.and.ellipse") + .symbolRenderingMode(.hierarchical) + .imageScale(.large).foregroundColor(.accentColor) + } + ProgressView("Bytes: \(totalBytes) / \(maxbytes)", value: Double(totalBytes), total: Double(maxbytes)) + .frame(width: 130) + .padding(5) + .font(.subheadline) + .accentColor(.accentColor) + .padding(.trailing) + } + #endif + HStack(alignment: .top) { ZStack { let kbType = UIKeyboardType(rawValue: UserDefaults.standard.object(forKey: "keyboardType") as? Int ?? 0) TextField("Message", text: $typingMessage, axis: .vertical) @@ -261,19 +288,13 @@ struct UserMessageList: View { Button { let userLongName = bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.longName : "Unknown" sendPositionWithMessage = true - if user.num == bleManager.broadcastNodeNum { - if userSettings.meshtasticUsername.count > 0 { - typingMessage = "📍 " + userSettings.meshtasticUsername + " has shared their position with the mesh from node " + userLongName - } else { - typingMessage = "📍 " + userLongName + " has shared their position with the mesh." - } + + if userSettings.meshtasticUsername.count > 0 { + typingMessage = "📍 " + userSettings.meshtasticUsername + " has shared their position with you from node " + userLongName + " and requested a response with your position." } else { - if userSettings.meshtasticUsername.count > 0 { - typingMessage = "📍 " + userSettings.meshtasticUsername + " has shared their position with you from node " + userLongName - } else { - typingMessage = "📍 " + userLongName + " has shared their position with you." - } + typingMessage = "📍 " + userLongName + " has shared their position and requested a response with your position." } + } label: { Image(systemName: "mappin.and.ellipse") .symbolRenderingMode(.hierarchical)