mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Add actions logic to node details
This commit is contained in:
parent
75b6b4e6af
commit
7ea68d8e22
2 changed files with 34 additions and 20 deletions
|
|
@ -6,16 +6,28 @@ struct ExchangePositionsButton: View {
|
|||
|
||||
var node: NodeInfoEntity
|
||||
|
||||
@State
|
||||
private var isPresentingPositionSentAlert: Bool = false
|
||||
@State private var isPresentingPositionSentAlert: Bool = false
|
||||
@State private var isPresentingPositionFailedAlert: Bool = false
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
isPresentingPositionSentAlert = bleManager.sendPosition(
|
||||
let positionSent = bleManager.sendPosition(
|
||||
channel: node.channel,
|
||||
destNum: node.num,
|
||||
wantResponse: true
|
||||
)
|
||||
if positionSent {
|
||||
isPresentingPositionSentAlert = true
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
|
||||
isPresentingPositionSentAlert = false
|
||||
}
|
||||
} else {
|
||||
isPresentingPositionFailedAlert = true
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
|
||||
isPresentingPositionFailedAlert = false
|
||||
}
|
||||
}
|
||||
|
||||
} label: {
|
||||
Label {
|
||||
Text("Exchange Positions")
|
||||
|
|
@ -30,6 +42,13 @@ struct ExchangePositionsButton: View {
|
|||
Button("OK") { }.keyboardShortcut(.defaultAction)
|
||||
} message: {
|
||||
Text("Your position has been sent with a request for a response with their position.")
|
||||
}.alert(
|
||||
"Position Exchange Failed",
|
||||
isPresented: $isPresentingPositionFailedAlert
|
||||
) {
|
||||
Button("OK") { }.keyboardShortcut(.defaultAction)
|
||||
} message: {
|
||||
Text("Failed to get a valid position to exchange.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,12 +281,6 @@ struct NodeDetail: View {
|
|||
}
|
||||
|
||||
Section("Actions") {
|
||||
FavoriteNodeButton(
|
||||
bleManager: bleManager,
|
||||
context: context,
|
||||
node: node
|
||||
)
|
||||
|
||||
if let user = node.user {
|
||||
NodeAlertsButton(
|
||||
context: context,
|
||||
|
|
@ -295,19 +289,21 @@ struct NodeDetail: View {
|
|||
)
|
||||
}
|
||||
|
||||
if let connectedPeripheral = bleManager.connectedPeripheral,
|
||||
node.num != connectedPeripheral.num {
|
||||
ExchangePositionsButton(
|
||||
if let connectedNode {
|
||||
FavoriteNodeButton(
|
||||
bleManager: bleManager,
|
||||
context: context,
|
||||
node: node
|
||||
)
|
||||
|
||||
TraceRouteButton(
|
||||
bleManager: bleManager,
|
||||
node: node
|
||||
)
|
||||
|
||||
if let connectedNode {
|
||||
if connectedNode.num != node.num {
|
||||
ExchangePositionsButton(
|
||||
bleManager: bleManager,
|
||||
node: node
|
||||
)
|
||||
TraceRouteButton(
|
||||
bleManager: bleManager,
|
||||
node: node
|
||||
)
|
||||
if node.isStoreForwardRouter {
|
||||
ClientHistoryButton(
|
||||
bleManager: bleManager,
|
||||
|
|
@ -315,7 +311,6 @@ struct NodeDetail: View {
|
|||
node: node
|
||||
)
|
||||
}
|
||||
|
||||
DeleteNodeButton(
|
||||
bleManager: bleManager,
|
||||
context: context,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue