kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
feat: expand role confirmation to include REPEATER (#1657)
* Clarify role change behavior The role change logic was modified to show a confirmation dialog when the role is set to `ROUTER`, `ROUTER_CLIENT`, or `REPEATER`. Previously, the dialog was only displayed when setting the role to `ROUTER`. * Implement router role confirmation dialog - Added a confirmation dialog when changing the device role to ROUTER, ROUTER_CLIENT, or REPEATER. - The confirmation dialog ensures users are aware of the implications of selecting a role used for infrastructure. - Updated the logic to set the selected role only after confirmation. - Only show dialog when changing to infrastructure roles. * remove deprecated ROUTER_CLIENT to avoid confusionpull/1653/head^2
rodzic
d40672df40
commit
6dfb6a56d6
|
@ -17,9 +17,11 @@
|
|||
|
||||
package com.geeksville.mesh.ui.radioconfig.components
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
|
@ -131,6 +133,11 @@ fun RouterRoleConfirmationDialog(
|
|||
Column {
|
||||
Text(text = annotatedDialogText)
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(true) {
|
||||
confirmed = !confirmed
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Checkbox(
|
||||
|
@ -168,16 +175,22 @@ fun DeviceConfigItemList(
|
|||
) {
|
||||
val focusManager = LocalFocusManager.current
|
||||
var deviceInput by rememberSaveable { mutableStateOf(deviceConfig) }
|
||||
|
||||
var showRouterRoleConfirmationDialog by rememberSaveable { mutableStateOf(false) }
|
||||
if (showRouterRoleConfirmationDialog) {
|
||||
RouterRoleConfirmationDialog(
|
||||
onDismiss = { showRouterRoleConfirmationDialog = false },
|
||||
onConfirm = {
|
||||
showRouterRoleConfirmationDialog = false
|
||||
deviceInput = deviceInput.copy { role = DeviceConfig.Role.ROUTER }
|
||||
}
|
||||
)
|
||||
var selectedRole by rememberSaveable { mutableStateOf(deviceInput.role) }
|
||||
val infrastructureRoles = listOf(
|
||||
DeviceConfig.Role.ROUTER,
|
||||
DeviceConfig.Role.REPEATER,
|
||||
)
|
||||
if (selectedRole != deviceInput.role) {
|
||||
if (selectedRole in infrastructureRoles) {
|
||||
RouterRoleConfirmationDialog(
|
||||
onDismiss = { selectedRole = deviceInput.role },
|
||||
onConfirm = {
|
||||
deviceInput = deviceInput.copy { role = selectedRole }
|
||||
}
|
||||
)
|
||||
} else {
|
||||
deviceInput = deviceInput.copy { role = selectedRole }
|
||||
}
|
||||
}
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
|
@ -190,11 +203,7 @@ fun DeviceConfigItemList(
|
|||
enabled = enabled,
|
||||
selectedItem = deviceInput.role,
|
||||
onItemSelected = {
|
||||
if (it == DeviceConfig.Role.ROUTER && deviceInput.role != DeviceConfig.Role.ROUTER) {
|
||||
showRouterRoleConfirmationDialog = true
|
||||
} else {
|
||||
deviceInput = deviceInput.copy { role = it }
|
||||
}
|
||||
selectedRole = it
|
||||
},
|
||||
summary = stringResource(id = deviceInput.role.stringRes),
|
||||
)
|
||||
|
|
Ładowanie…
Reference in New Issue