Add all section to task types

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-02-29 10:49:18 +01:00 committed by Alper Öztürk
parent a52ec924ab
commit cbc9466d29
3 changed files with 15 additions and 4 deletions

View file

@ -84,14 +84,16 @@ class AssistantViewModel(client: NextcloudClient) : ViewModel() {
private fun getTaskTypes() {
viewModelScope.launch(Dispatchers.IO) {
val result = repository.getTaskTypes().resultData.types
val result = arrayListOf(TaskType(null, "All", null))
val taskTypes = repository.getTaskTypes().resultData.types ?: listOf()
result.addAll(taskTypes)
_taskTypes.update {
result
result.toList()
}
_selectedTaskType.update {
result?.first()
result.first()
}
}
}

View file

@ -89,7 +89,14 @@ fun AssistantScreen(viewModel: AssistantViewModel, floatingActionButton: Floatin
}
floatingActionButton.setOnClickListener {
showAddTaskAlertDialog = true
if (selectedTaskType?.id != null) {
showAddTaskAlertDialog = true
} else {
DisplayUtils.showSnackMessage(
activity,
activity.getString(R.string.assistant_screen_select_different_task_type_to_add)
)
}
}
Box(Modifier.nestedScroll(pullRefreshState.nestedScrollConnection)) {

View file

@ -23,6 +23,8 @@
<string name="assistant_screen_delete_task_alert_dialog_title">Delete Task</string>
<string name="assistant_screen_delete_task_alert_dialog_description">Are you sure you want to delete this task?</string>
<string name="assistant_screen_select_different_task_type_to_add">Please select different task type to create a new task</string>
<string name="assistant_screen_task_more_actions_bottom_sheet_delete_action">Delete Task</string>
<string name="assistant_screen_task_create_success_message">Task successfully created</string>