Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright (c) 2025 Olivier Patry
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package net.opatry.tasks.app.ui.component

import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import kotlinx.datetime.LocalDate
import net.opatry.tasks.app.presentation.model.DateRange
import net.opatry.tasks.app.presentation.model.TaskId
import net.opatry.tasks.app.presentation.model.TaskListId
import net.opatry.tasks.app.presentation.model.TaskListUIModel
import net.opatry.tasks.app.presentation.model.TaskUIModel
import net.opatry.tasks.data.TaskListSorting


class TaskListPreviewParameterProvider : PreviewParameterProvider<TaskListUIModel> {
override val values = sequenceOf(
// fully empty state
TaskListUIModel(
id = TaskListId(0L),
title = "Whole new list",
remainingTasks = emptyMap(),
completedTasks = emptyList()
),
// broken indentation
TaskListUIModel(
id = TaskListId(0L),
title = "Broken indentation",
remainingTasks = mapOf(
null to listOf(
TaskUIModel(
id = TaskId(1L),
title = "Task 1",
isCompleted = false,
indent = 42,
),
)
),
completedTasks = emptyList()
),
// all done empty state
TaskListUIModel(
id = TaskListId(0L),
title = "All done",
remainingTasks = emptyMap(),
completedTasks = listOf(
TaskUIModel(
id = TaskId(1L),
title = "Task 1",
isCompleted = true,
),
)
),
// remaining tasks sorted manually
TaskListUIModel(
id = TaskListId(0L),
title = "All remains manually ordered",
sorting = TaskListSorting.Manual,
remainingTasks = mapOf(
DateRange.None to listOf(
TaskUIModel(
id = TaskId(1L),
title = "Task 1",
isCompleted = false,
),
),
DateRange.Overdue(LocalDate.parse("2023-01-01"), 40) to listOf(
TaskUIModel(
id = TaskId(2L),
title = "Task 2",
isCompleted = false,
),
TaskUIModel(
id = TaskId(3L),
title = "Task 3",
isCompleted = false,
indent = 1,
),
),
),
completedTasks = emptyList()
),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2025 Olivier Patry
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package net.opatry.tasks.app.ui.component

import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.tooling.preview.PreviewParameter
import net.opatry.tasks.app.presentation.model.TaskListUIModel
import net.opatry.tasks.app.ui.tooling.TaskfolioThemedPreview

@PreviewLightDark
@Composable
private fun TaskListScaffoldPreview(
@PreviewParameter(TaskListPreviewParameterProvider::class)
taskList: TaskListUIModel,
) {
TaskfolioThemedPreview {
TaskListScaffold(
taskLists = emptyList(),
taskList = taskList,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,69 +25,8 @@ package net.opatry.tasks.app.ui.component
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import kotlinx.datetime.LocalDate
import net.opatry.tasks.app.presentation.model.DateRange
import net.opatry.tasks.app.presentation.model.TaskId
import net.opatry.tasks.app.presentation.model.TaskListId
import net.opatry.tasks.app.presentation.model.TaskListUIModel
import net.opatry.tasks.app.presentation.model.TaskUIModel
import net.opatry.tasks.app.ui.tooling.TaskfolioThemedPreview
import net.opatry.tasks.data.TaskListSorting

private class TaskListPreviewParameterProvider : PreviewParameterProvider<TaskListUIModel> {
override val values = sequenceOf(
// fully empty state
TaskListUIModel(
id = TaskListId(0L),
title = "Whole new list",
remainingTasks = emptyMap(),
completedTasks = emptyList()
),
// all done empty state
TaskListUIModel(
id = TaskListId(0L),
title = "All done",
remainingTasks = emptyMap(),
completedTasks = listOf(
TaskUIModel(
id = TaskId(1L),
title = "Task 1",
isCompleted = true,
),
)
),
// remaining tasks sorted manually
TaskListUIModel(
id = TaskListId(0L),
title = "All remains manually ordered",
sorting = TaskListSorting.Manual,
remainingTasks = mapOf(
DateRange.None to listOf(
TaskUIModel(
id = TaskId(1L),
title = "Task 1",
isCompleted = false,
),
),
DateRange.Overdue(LocalDate.parse("2023-01-01"), 40) to listOf(
TaskUIModel(
id = TaskId(2L),
title = "Task 2",
isCompleted = false,
),
TaskUIModel(
id = TaskId(3L),
title = "Task 3",
isCompleted = false,
indent = 1,
),
),
),
completedTasks = emptyList()
),
)
}

@PreviewLightDark
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,19 @@ private fun NoTaskListSelectedEmptyStatePreview() {
}
}

@PreviewLightDark
@Composable
private fun NoTasksEmptyStatePreview() {
TaskfolioThemedPreview {
NoTasksEmptyState()
}
}

@PreviewLightDark
@Composable
private fun NoTaskListEmptyStatePreview() {
TaskfolioThemedPreview {
NoTaskListEmptyState {}
NoTaskListsEmptyState {}
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ fun CompletedTaskRow(
Row(
Modifier
.testTag(COMPLETED_TASK_ROW)
.clickable(onClick = { onAction(TaskAction.Edit) })
.clickable(onClick = { onAction(TaskAction.Edit(task)) })
) {
IconButton(onClick = { onAction(TaskAction.ToggleCompletion) }, Modifier.testTag(COMPLETED_TASK_ICON)) {
IconButton(onClick = { onAction(TaskAction.ToggleCompletion(task)) }, Modifier.testTag(COMPLETED_TASK_ICON)) {
Icon(LucideIcons.CircleCheckBig, null, tint = MaterialTheme.colorScheme.primary)
}
Column(
Expand Down Expand Up @@ -140,7 +140,7 @@ fun CompletedTaskRow(
}
}

IconButton(onClick = { onAction(TaskAction.Delete) }, Modifier.testTag(COMPLETED_TASK_DELETE_ICON)) {
IconButton(onClick = { onAction(TaskAction.Delete(task)) }, Modifier.testTag(COMPLETED_TASK_DELETE_ICON)) {
Icon(LucideIcons.Trash, stringResource(Res.string.task_list_pane_delete_task_icon_content_desc))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ fun RemainingTaskRow(
Row(
Modifier
.testTag(REMAINING_TASK_ROW)
.clickable(onClick = { onAction(TaskAction.Edit) })
.clickable(onClick = { onAction(TaskAction.Edit(task)) })
) {
IconButton(
onClick = { onAction(TaskAction.ToggleCompletion) },
onClick = { onAction(TaskAction.ToggleCompletion(task)) },
modifier = Modifier
.testTag(REMAINING_TASK_ICON)
.padding(start = 36.dp * task.indent)
Expand Down Expand Up @@ -185,7 +185,7 @@ fun RemainingTaskRow(
}
if (showDate && task.dueDate != null) {
AssistChip(
onClick = { onAction(TaskAction.UpdateDueDate) },
onClick = { onAction(TaskAction.UpdateDueDate(task)) },
label = {
Text(
task.dateRange.toLabel(),
Expand Down
Loading