From 53e716a690a39972c35ba70f5f76994c86f33d37 Mon Sep 17 00:00:00 2001 From: Geoffroy Bonneville <24917789+wismna@users.noreply.github.com> Date: Fri, 10 Oct 2025 16:11:39 -0400 Subject: [PATCH] Light cleanup and refactoring --- .../donext/presentation/screen/MainScreen.kt | 5 +-- .../presentation/screen/ManageListsScreen.kt | 3 +- .../presentation/viewmodel/TaskViewModel.kt | 45 +++++++++---------- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/screen/MainScreen.kt b/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/screen/MainScreen.kt index f3da355..2f4c528 100644 --- a/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/screen/MainScreen.kt +++ b/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/screen/MainScreen.kt @@ -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) diff --git a/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/screen/ManageListsScreen.kt b/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/screen/ManageListsScreen.kt index 7b56072..ea1cb64 100644 --- a/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/screen/ManageListsScreen.kt +++ b/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/screen/ManageListsScreen.kt @@ -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() diff --git a/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/viewmodel/TaskViewModel.kt b/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/viewmodel/TaskViewModel.kt index 1f8a903..bd67fe9 100644 --- a/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/viewmodel/TaskViewModel.kt +++ b/donextv2/src/main/java/com/wismna/geoffroy/donext/presentation/viewmodel/TaskViewModel.kt @@ -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 = ""