Add multine line for add task alert dialog

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-03-13 09:25:56 +01:00
parent 631ddf5250
commit 6f777580e2
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
2 changed files with 23 additions and 13 deletions

View file

@ -148,10 +148,18 @@ fun AssistantScreen(viewModel: AssistantViewModel, activity: Activity) {
}
if (showAddTaskAlertDialog) {
selectedTaskType?.let {
AddTaskAlertDialog(viewModel, it) {
showAddTaskAlertDialog = false
}
selectedTaskType?.let { taskType ->
AddTaskAlertDialog(
title = taskType.name,
description = taskType.description,
addTask = { input ->
taskType.id?.let {
viewModel.createTask(input = input, type = it)
}
}, dismiss = {
showAddTaskAlertDialog = false
}
)
}
}
}

View file

@ -31,25 +31,22 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.KeyboardType
import com.nextcloud.client.assistant.AssistantViewModel
import androidx.compose.ui.tooling.preview.Preview
import com.nextcloud.ui.composeComponents.alertDialog.SimpleAlertDialog
import com.owncloud.android.R
import com.owncloud.android.lib.resources.assistant.model.TaskType
@Composable
fun AddTaskAlertDialog(viewModel: AssistantViewModel, taskType: TaskType, dismiss: () -> Unit) {
fun AddTaskAlertDialog(title: String?, description: String?, addTask: (String) -> Unit, dismiss: () -> Unit) {
var input by remember {
mutableStateOf("")
}
SimpleAlertDialog(
title = taskType.name ?: "",
description = taskType.description,
title = title ?: "",
description = description ?: "",
dismiss = { dismiss() },
onComplete = {
taskType.id?.let {
viewModel.createTask(input = input, type = it)
}
addTask(input)
},
content = {
TextField(
@ -65,8 +62,13 @@ fun AddTaskAlertDialog(viewModel: AssistantViewModel, taskType: TaskType, dismis
onValueChange = {
input = it
},
singleLine = true
)
}
)
}
@Composable
@Preview
private fun AddTaskAlertDialogPreview() {
AddTaskAlertDialog(title = "Title", description = "Description", addTask = { }, dismiss = {})
}