From 656494ea39ced5bc85022d60b170f0fe88751301 Mon Sep 17 00:00:00 2001 From: rhunk <101876869+rhunk@users.noreply.github.com> Date: Sat, 25 Nov 2023 12:01:55 +0100 Subject: [PATCH] feat(app/tasks): cancel task button --- .../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 index 398008c8..0070875f 100644 --- 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)