mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
36 lines
963 B
Swift
36 lines
963 B
Swift
import SwiftUI
|
|
|
|
struct TraceRouteButton: View {
|
|
var bleManager: BLEManager
|
|
|
|
var node: NodeInfoEntity
|
|
|
|
@State
|
|
private var isPresentingTraceRouteSentAlert: Bool = false
|
|
|
|
var body: some View {
|
|
RateLimitedButton(key: "traceroute", rateLimit: 30.0) {
|
|
isPresentingTraceRouteSentAlert = bleManager.sendTraceRouteRequest(
|
|
destNum: node.user?.num ?? 0,
|
|
wantResponse: true
|
|
)
|
|
} label: { completion in
|
|
if let completion, completion.percentComplete > 0.0 {
|
|
Label {
|
|
Text("Trace Route (in \(completion.secondsRemaining.formatted(.number.precision(.fractionLength(0))))s)")
|
|
.foregroundStyle(.secondary)
|
|
} icon: {
|
|
Image("progress.ring.dashed", variableValue: completion.percentComplete)
|
|
.foregroundStyle(.secondary)
|
|
}.disabled(true)
|
|
} else {
|
|
Label {
|
|
Text("Trace Route")
|
|
} icon: {
|
|
Image(systemName: "signpost.right.and.left")
|
|
.symbolRenderingMode(.hierarchical)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|