Light cleanup and refactoring

This commit is contained in:
Geoffroy Bonneville
2025-10-10 16:11:39 -04:00
parent 6c9e5efe38
commit 53e716a690
3 changed files with 24 additions and 29 deletions

View File

@@ -227,10 +227,7 @@ fun AppContent(
}
composable(AppDestination.ManageLists.route) {
ManageListsScreen(
modifier = Modifier,
showAddListSheet = {viewModel.showAddListSheet = true}
)
ManageListsScreen(modifier = Modifier)
}
composable(AppDestination.DueTodayList.route) {
DueTodayTasksScreen (modifier = Modifier)

View File

@@ -60,8 +60,7 @@ import sh.calvin.reorderable.rememberReorderableLazyListState
@Composable
fun ManageListsScreen(
modifier: Modifier,
viewModel: ManageListsViewModel = hiltViewModel(),
showAddListSheet: () -> Unit
viewModel: ManageListsViewModel = hiltViewModel()
) {
var lists = viewModel.taskLists.toMutableList()

View File

@@ -56,28 +56,6 @@ class TaskViewModel @Inject constructor(
fun screenTitle(): String = if (isDeleted) "Task details" else if (isEditing()) "Edit Task" else "New Task"
fun isEditing(): Boolean = editingTaskId != null
private fun startNewTask(selectedListId: Long) {
editingTaskId = null
taskListId = selectedListId
title = ""
description = ""
priority = Priority.NORMAL
dueDate = null
isDeleted = false
}
private fun startEditTask(task: Task) {
editingTaskId = task.id
taskListId = task.taskListId
title = task.name
description = task.description ?: ""
priority = task.priority
dueDate = task.dueDate
isDone = task.isDone
isDeleted = task.isDeleted
}
fun onTitleChanged(value: String) { title = value }
fun onDescriptionChanged(value: String) { description = value }
fun onPriorityChanged(value: Priority) { priority = value }
@@ -104,7 +82,28 @@ class TaskViewModel @Inject constructor(
}
}
fun reset() {
private fun startNewTask(selectedListId: Long) {
editingTaskId = null
taskListId = selectedListId
title = ""
description = ""
priority = Priority.NORMAL
dueDate = null
isDeleted = false
}
private fun startEditTask(task: Task) {
editingTaskId = task.id
taskListId = task.taskListId
title = task.name
description = task.description ?: ""
priority = task.priority
dueDate = task.dueDate
isDone = task.isDone
isDeleted = task.isDeleted
}
private fun reset() {
editingTaskId = null
taskListId = null
title = ""