mirror of
https://github.com/smyalygames/checklist-tester.git
synced 2025-05-18 14:34:12 +02:00
feat(connector): delete an action in action screen
This commit is contained in:
parent
f498c8c0c0
commit
1f53de5af5
@ -10,6 +10,7 @@ import androidx.compose.foundation.rememberScrollbarAdapter
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
|
||||
import androidx.compose.material.icons.outlined.Add
|
||||
import androidx.compose.material.icons.outlined.Delete
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
@ -122,9 +123,30 @@ class Actions (dbActions: List<Action>) : Screen {
|
||||
private fun actionItem(item: Action) {
|
||||
Column (
|
||||
verticalArrangement = Arrangement.spacedBy(itemPadding)
|
||||
) {
|
||||
Row(
|
||||
Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(text = "Action ${item.step + 1}")
|
||||
|
||||
IconButton(
|
||||
modifier = Modifier.size(24.dp),
|
||||
onClick = {
|
||||
inputs.removeAt(item.step)
|
||||
updateStepOrder()
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
Icons.Outlined.Delete,
|
||||
contentDescription = "Delete Action ${item.step + 1}",
|
||||
modifier = Modifier.size(20.dp),
|
||||
tint = MaterialTheme.colorScheme.secondary
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(itemPadding)
|
||||
@ -197,16 +219,25 @@ class Actions (dbActions: List<Action>) : Screen {
|
||||
}
|
||||
|
||||
private fun createEmptyAction(procedureId: Int): Action {
|
||||
val index = inputs.size + 1
|
||||
val index = inputs.size
|
||||
|
||||
val action = Action(
|
||||
id = index,
|
||||
id = index + 1,
|
||||
procedureId = procedureId,
|
||||
step = index - 1,
|
||||
step = index,
|
||||
type = "",
|
||||
goal = ""
|
||||
)
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates Action.step in the input list to be the same as the index in the list
|
||||
*/
|
||||
private fun updateStepOrder() {
|
||||
for ((index, action) in inputs.withIndex()) {
|
||||
inputs[index] = action.copy(step = index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user