commit 656494ea39ced5bc85022d60b170f0fe88751301 parent 9d93f3086aaf4cc36cf3ae3168410eb0d75cd98e Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Sat, 25 Nov 2023 12:01:55 +0100 feat(app/tasks): cancel task button Diffstat:
M | app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/sections/TasksSection.kt | | | 10 | +++++++++- |
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/sections/TasksSection.kt b/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/sections/TasksSection.kt @@ -148,7 +148,15 @@ class TasksSection : Section() { Column { if (pendingTask != null && !taskStatus.isFinalStage()) { - CircularProgressIndicator(modifier = Modifier.size(30.dp)) + FilledIconButton(onClick = { + runCatching { + pendingTask.cancel() + }.onFailure { throwable -> + context.log.error("Failed to cancel task $pendingTask", throwable) + } + }) { + Icon(Icons.Filled.Close, contentDescription = "Cancel") + } } else { when (taskStatus) { TaskStatus.SUCCESS -> Icon(Icons.Filled.Check, contentDescription = "Success", tint = MaterialTheme.colorScheme.primary)