Meshtastic-Apple/Meshtastic/Views/Settings/Config/SaveConfigButton.swift

37 lines
943 B
Swift
Raw Normal View History

import SwiftUI
struct SaveConfigButton: View {
@EnvironmentObject var bleManager: BLEManager
@State private var isPresentingSaveConfirm = false
let node: NodeInfoEntity?
@Binding var hasChanges: Bool
let onConfirmation: () -> Void
var body: some View {
Button {
isPresentingSaveConfirm = true
} label: {
Label("Save", systemImage: "square.and.arrow.down")
}
.disabled(bleManager.connectedPeripheral == nil || !hasChanges)
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)
.padding()
.confirmationDialog(
2025-02-15 12:17:22 -08:00
"Are you sure?",
isPresented: $isPresentingSaveConfirm,
titleVisibility: .visible
) {
2025-04-27 16:19:10 -07:00
let nodeName = node?.user?.longName ?? "Unknown".localized
let buttonText = String.localizedStringWithFormat("save.config %@".localized, nodeName)
Button(buttonText) {
onConfirmation()
}
} message: {
2025-05-08 08:59:24 -07:00
Text("After config values save the node will reboot.")
}
}
}