remove combined click

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-12-03 14:58:13 +01:00 committed by Alper Öztürk
parent 312e793fb2
commit 4796b67943
3 changed files with 15 additions and 41 deletions

View file

@ -226,7 +226,15 @@ private fun ShowOverlayState(
val newState =
ScreenOverlayState.AddTask(taskType, state.task.input?.input ?: "")
viewModel.updateScreenState(newState)
}
},
Triple(
R.drawable.ic_delete,
R.string.assistant_screen_task_more_actions_bottom_sheet_delete_action
) {
val newState =
ScreenOverlayState.DeleteTask(state.task.id)
viewModel.updateScreenState(newState)
},
)
MoreActionsBottomSheet(
@ -263,10 +271,6 @@ private fun AssistantContent(
items(taskList) { task ->
TaskView(task,
showDeleteTaskAlertDialog = {
val newState = ScreenOverlayState.DeleteTask(task.id)
viewModel.updateScreenState(newState)
},
showTaskActions = {
val newState = ScreenOverlayState.TaskActions(task)
viewModel.updateScreenState(newState)

View file

@ -9,9 +9,8 @@ package com.nextcloud.client.assistant.task
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
@ -42,16 +41,13 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.nextcloud.client.assistant.task.model.TaskViewBottomSheetType
import com.nextcloud.client.assistant.taskDetail.TaskDetailBottomSheet
import com.nextcloud.ui.composeComponents.bottomSheet.MoreActionsBottomSheet
import com.owncloud.android.R
import com.owncloud.android.lib.resources.assistant.model.Task
import com.owncloud.android.lib.resources.assistant.model.TaskInput
import com.owncloud.android.lib.resources.assistant.model.TaskOutput
@OptIn(ExperimentalFoundationApi::class)
@Suppress("LongMethod", "MagicNumber")
@Composable
fun TaskView(task: Task, showDeleteTaskAlertDialog: (Long) -> Unit, showTaskActions: () -> Unit) {
fun TaskView(task: Task, showTaskActions: () -> Unit) {
var bottomSheetType by remember { mutableStateOf<TaskViewBottomSheetType?>(null) }
Box {
@ -60,11 +56,9 @@ fun TaskView(task: Task, showDeleteTaskAlertDialog: (Long) -> Unit, showTaskActi
.fillMaxWidth()
.clip(RoundedCornerShape(8.dp))
.background(MaterialTheme.colorScheme.primary)
.combinedClickable(onClick = {
.clickable {
bottomSheetType = TaskViewBottomSheetType.Detail
}, onLongClick = {
bottomSheetType = TaskViewBottomSheetType.MoreAction
})
}
.padding(16.dp)
) {
Spacer(modifier = Modifier.height(8.dp))
@ -107,9 +101,7 @@ fun TaskView(task: Task, showDeleteTaskAlertDialog: (Long) -> Unit, showTaskActi
TaskStatusView(task, foregroundColor = Color.White)
bottomSheetType?.let {
TaskViewBottomSheet(it, task, showDeleteTaskAlertDialog = {
showDeleteTaskAlertDialog(task.id)
}, dismiss = {
TaskViewBottomSheet(it, task, dismiss = {
bottomSheetType = null
}, showTaskActions = {
showTaskActions()
@ -136,7 +128,6 @@ private fun TaskViewBottomSheet(
bottomSheetType: TaskViewBottomSheetType,
task: Task,
showTaskActions: () -> Unit,
showDeleteTaskAlertDialog: () -> Unit,
dismiss: () -> Unit
) {
when (bottomSheetType) {
@ -148,25 +139,6 @@ private fun TaskViewBottomSheet(
dismiss()
}
}
TaskViewBottomSheetType.MoreAction -> {
val bottomSheetAction = listOf(
Triple(
R.drawable.ic_delete,
R.string.assistant_screen_task_more_actions_bottom_sheet_delete_action
) {
showDeleteTaskAlertDialog()
}
)
MoreActionsBottomSheet(
title = task.input?.input,
actions = bottomSheetAction,
dismiss = {
dismiss()
}
)
}
}
}
@ -191,8 +163,6 @@ private fun TaskViewPreview() {
1707692337,
), showTaskActions = {
}, showDeleteTaskAlertDialog = {
}
)
}

View file

@ -8,5 +8,5 @@
package com.nextcloud.client.assistant.task.model
enum class TaskViewBottomSheetType {
Detail, MoreAction
Detail
}