Merge pull request #1124 from meshtastic/confirmationDialogue

Confirmation dialogue
This commit is contained in:
Garth Vander Houwen 2025-03-19 08:27:50 -07:00 committed by GitHub
commit dfe87ecfcb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 2 deletions

View file

@ -5628,6 +5628,9 @@
}
}
}
},
"Confirm" : {
},
"Connect to a Node" : {
"localizations" : {
@ -30172,6 +30175,9 @@
}
}
}
},
"The Router roles are designed for high vantage locations like mountaintops and towers. This node needs to be able to have a good direct connection to most of the nodes on the network or else this will significantly hurt the network." : {
},
"The secondary public key authorized to send admin messages to this node." : {
"localizations" : {

View file

@ -53,6 +53,5 @@ struct ContentView: View {
}
.tag(NavigationState.Tab.settings)
}
.toolbarBackground(.visible, for: .tabBar)
}
}

View file

@ -21,6 +21,7 @@ struct DeviceConfig: View {
@State private var isPresentingFactoryResetConfirm = false
@State var hasChanges = false
@State var deviceRole = 0
@State private var pendingDeviceRole = 0
@State var buzzerGPIO = 0
@State var buttonGPIO = 0
@State var rebroadcastMode = 0
@ -29,6 +30,10 @@ struct DeviceConfig: View {
@State var ledHeartbeatEnabled = true
@State var tripleClickAsAdHocPing = true
@State var tzdef = ""
@State private var showRouterWarning = false
@State private var confirmWarning = false
var body: some View {
VStack {
@ -39,9 +44,37 @@ struct DeviceConfig: View {
VStack(alignment: .leading) {
Picker("Device Role", selection: $deviceRole ) {
ForEach(DeviceRoles.allCases) { dr in
Text(dr.name)
Text(dr.name).tag(dr.rawValue as Int)
}
}
.onChange(of: deviceRole) { oldValue, newValue in
if !confirmWarning {
if [2, 11].contains(newValue) {
pendingDeviceRole = newValue
deviceRole = oldValue // Reset selection until confirmed
showRouterWarning = true
}
} else {
confirmWarning = false
}
}
.confirmationDialog(
"Are you sure?",
isPresented: $showRouterWarning,
titleVisibility: .visible
) {
Button("Confirm") {
deviceRole = pendingDeviceRole
pendingDeviceRole = 0
confirmWarning = true
}
Button("Cancel", role: .cancel) {
pendingDeviceRole = 0
}
} message: {
Text("The Router roles are designed for high vantage locations like mountaintops and towers. This node needs to be able to have a good direct connection to most of the nodes on the network or else this will significantly hurt the network.")
}
Text(DeviceRoles(rawValue: deviceRole)?.description ?? "")
.foregroundColor(.gray)
.font(.callout)