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.Icons
|
||||||
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
|
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
|
||||||
import androidx.compose.material.icons.outlined.Add
|
import androidx.compose.material.icons.outlined.Add
|
||||||
|
import androidx.compose.material.icons.outlined.Delete
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.mutableStateListOf
|
import androidx.compose.runtime.mutableStateListOf
|
||||||
@ -123,7 +124,28 @@ class Actions (dbActions: List<Action>) : Screen {
|
|||||||
Column (
|
Column (
|
||||||
verticalArrangement = Arrangement.spacedBy(itemPadding)
|
verticalArrangement = Arrangement.spacedBy(itemPadding)
|
||||||
) {
|
) {
|
||||||
Text(text = "Action ${item.step + 1}")
|
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(
|
Row(
|
||||||
Modifier.fillMaxWidth(),
|
Modifier.fillMaxWidth(),
|
||||||
@ -197,16 +219,25 @@ class Actions (dbActions: List<Action>) : Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createEmptyAction(procedureId: Int): Action {
|
private fun createEmptyAction(procedureId: Int): Action {
|
||||||
val index = inputs.size + 1
|
val index = inputs.size
|
||||||
|
|
||||||
val action = Action(
|
val action = Action(
|
||||||
id = index,
|
id = index + 1,
|
||||||
procedureId = procedureId,
|
procedureId = procedureId,
|
||||||
step = index - 1,
|
step = index,
|
||||||
type = "",
|
type = "",
|
||||||
goal = ""
|
goal = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
return action
|
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