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
Expand Up @@ -32,10 +32,10 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import net.opatry.tasks.app.ui.TaskListsViewModel
import net.opatry.tasks.app.presentation.TaskListsViewModel
import net.opatry.tasks.app.presentation.UserState
import net.opatry.tasks.app.presentation.UserViewModel
import net.opatry.tasks.app.ui.TasksApp
import net.opatry.tasks.app.ui.UserState
import net.opatry.tasks.app.ui.UserViewModel
import net.opatry.tasks.app.ui.component.AuthorizeGoogleTasksButton
import net.opatry.tasks.app.ui.component.LoadingPane
import net.opatry.tasks.app.ui.screen.AboutApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import net.opatry.google.profile.UserInfoApi
import net.opatry.google.tasks.TaskListsApi
import net.opatry.google.tasks.TasksApi
import net.opatry.tasks.CredentialsStorage
import net.opatry.tasks.app.ui.TaskListsViewModel
import net.opatry.tasks.app.ui.UserViewModel
import net.opatry.tasks.app.presentation.TaskListsViewModel
import net.opatry.tasks.app.presentation.UserViewModel
import net.opatry.tasks.data.TaskDao
import net.opatry.tasks.data.TaskListDao
import net.opatry.tasks.data.TaskRepository
Expand Down
6 changes: 3 additions & 3 deletions tasks-app-desktop/src/main/kotlin/mainApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ import net.opatry.tasks.app.di.loggingModule
import net.opatry.tasks.app.di.networkModule
import net.opatry.tasks.app.di.platformModule
import net.opatry.tasks.app.di.tasksAppModule
import net.opatry.tasks.app.ui.TaskListsViewModel
import net.opatry.tasks.app.presentation.TaskListsViewModel
import net.opatry.tasks.app.presentation.UserState
import net.opatry.tasks.app.presentation.UserViewModel
import net.opatry.tasks.app.ui.TasksApp
import net.opatry.tasks.app.ui.UserState
import net.opatry.tasks.app.ui.UserViewModel
import net.opatry.tasks.app.ui.component.AuthorizeGoogleTasksButton
import net.opatry.tasks.app.ui.component.LoadingPane
import net.opatry.tasks.app.ui.screen.AboutApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import net.opatry.google.profile.UserInfoApi
import net.opatry.google.tasks.TaskListsApi
import net.opatry.google.tasks.TasksApi
import net.opatry.tasks.CredentialsStorage
import net.opatry.tasks.app.ui.TaskListsViewModel
import net.opatry.tasks.app.ui.UserViewModel
import net.opatry.tasks.app.presentation.TaskListsViewModel
import net.opatry.tasks.app.presentation.UserViewModel
import net.opatry.tasks.data.TaskDao
import net.opatry.tasks.data.TaskListDao
import net.opatry.tasks.data.TaskRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import kotlinx.datetime.Clock
import kotlinx.datetime.LocalDate
import kotlinx.datetime.TimeZone
import kotlinx.datetime.todayIn
import net.opatry.tasks.app.ui.model.TaskId
import net.opatry.tasks.app.ui.model.TaskUIModel
import net.opatry.tasks.app.presentation.model.TaskId
import net.opatry.tasks.app.presentation.model.TaskUIModel
import net.opatry.tasks.app.ui.tooling.TaskfolioThemedPreview

private class CompletedTaskRowPreviewDataProvider :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import kotlinx.datetime.TimeZone
import kotlinx.datetime.minus
import kotlinx.datetime.plus
import kotlinx.datetime.todayIn
import net.opatry.tasks.app.ui.model.TaskId
import net.opatry.tasks.app.ui.model.TaskUIModel
import net.opatry.tasks.app.presentation.model.TaskId
import net.opatry.tasks.app.presentation.model.TaskUIModel
import net.opatry.tasks.app.ui.tooling.TaskfolioThemedPreview


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import net.opatry.tasks.app.ui.model.TaskListId
import net.opatry.tasks.app.ui.model.TaskListUIModel
import net.opatry.tasks.app.presentation.model.TaskListId
import net.opatry.tasks.app.presentation.model.TaskListUIModel
import net.opatry.tasks.app.ui.tooling.TaskfolioThemedPreview

// FIXME When displayed with dark, the menu labels are invisible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import net.opatry.tasks.app.ui.model.TaskListId
import net.opatry.tasks.app.ui.model.TaskListUIModel
import net.opatry.tasks.app.presentation.model.TaskListId
import net.opatry.tasks.app.presentation.model.TaskListUIModel
import net.opatry.tasks.app.ui.tooling.TaskfolioThemedPreview
import net.opatry.tasks.data.TaskListSorting

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ 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 net.opatry.tasks.app.ui.model.TaskListId
import net.opatry.tasks.app.ui.model.TaskListUIModel
import net.opatry.tasks.app.presentation.model.TaskListId
import net.opatry.tasks.app.presentation.model.TaskListUIModel
import net.opatry.tasks.app.ui.tooling.TaskfolioThemedPreview
import net.opatry.tasks.data.TaskListSorting

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* 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 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
private fun TasksColumnPreview(
@PreviewParameter(TaskListPreviewParameterProvider::class)
taskList: TaskListUIModel,
) {
TaskfolioThemedPreview {
TasksColumn(
taskLists = listOf(taskList),
taskList = taskList,
showCompletedDefaultValue = true
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ package net.opatry.tasks.app.ui.component
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.PreviewLightDark
import net.opatry.tasks.app.ui.UserState
import net.opatry.tasks.app.presentation.UserState
import net.opatry.tasks.app.ui.tooling.TaskfolioThemedPreview

@PreviewLightDark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.unit.dp
import net.opatry.tasks.app.ui.model.TaskListId
import net.opatry.tasks.app.ui.model.TaskListUIModel
import net.opatry.tasks.app.presentation.model.TaskListId
import net.opatry.tasks.app.presentation.model.TaskListUIModel
import net.opatry.tasks.app.ui.tooling.TaskfolioThemedPreview


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import kotlinx.datetime.plus
import kotlinx.datetime.todayIn
import net.opatry.tasks.app.ui.component.CompletedTaskRow
import net.opatry.tasks.app.ui.component.RemainingTaskRow
import net.opatry.tasks.app.ui.model.TaskId
import net.opatry.tasks.app.ui.model.TaskUIModel
import net.opatry.tasks.app.presentation.model.TaskId
import net.opatry.tasks.app.presentation.model.TaskUIModel
import net.opatry.tasks.app.ui.tooling.TaskfolioThemedPreview


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ package net.opatry.tasks.app.di

import net.opatry.google.profile.HttpUserInfoApi
import net.opatry.google.profile.UserInfoApi
import net.opatry.tasks.app.ui.TaskListsViewModel
import net.opatry.tasks.app.ui.UserViewModel
import net.opatry.tasks.app.presentation.TaskListsViewModel
import net.opatry.tasks.app.presentation.UserViewModel
import net.opatry.tasks.data.TaskRepository
import org.koin.core.module.dsl.viewModel
import org.koin.core.qualifier.named
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package net.opatry.tasks.app.ui
package net.opatry.tasks.app.presentation

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
Expand All @@ -40,12 +40,13 @@ import kotlinx.datetime.TimeZone
import kotlinx.datetime.atStartOfDayIn
import kotlinx.datetime.toLocalDateTime
import net.opatry.Logger
import net.opatry.tasks.app.ui.model.DateRange
import net.opatry.tasks.app.ui.model.TaskId
import net.opatry.tasks.app.ui.model.TaskListId
import net.opatry.tasks.app.ui.model.TaskListUIModel
import net.opatry.tasks.app.ui.model.TaskUIModel
import net.opatry.tasks.app.ui.model.compareTo
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.presentation.model.compareTo
import net.opatry.tasks.app.ui.TaskEvent
import net.opatry.tasks.data.TaskListSorting
import net.opatry.tasks.data.TaskRepository
import net.opatry.tasks.data.model.TaskDataModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package net.opatry.tasks.app.ui
package net.opatry.tasks.app.presentation

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package net.opatry.tasks.app.ui.model
package net.opatry.tasks.app.presentation.model

import net.opatry.tasks.data.TaskListSorting

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package net.opatry.tasks.app.ui.model
package net.opatry.tasks.app.presentation.model

import kotlinx.datetime.Clock
import kotlinx.datetime.LocalDate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import net.opatry.tasks.app.presentation.TaskListsViewModel
import net.opatry.tasks.app.presentation.UserState
import net.opatry.tasks.app.presentation.UserViewModel
import net.opatry.tasks.app.ui.component.EditTextDialog
import net.opatry.tasks.app.ui.component.MissingScreen
import net.opatry.tasks.app.ui.component.ProfileIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,27 @@ import kotlinx.datetime.format.MonthNames
import kotlinx.datetime.format.Padding
import kotlinx.datetime.format.char
import kotlinx.datetime.todayIn
import net.opatry.tasks.app.ui.model.TaskUIModel
import net.opatry.tasks.app.ui.screen.TaskListPaneTestTag.COMPLETED_TASK_COMPLETION_DATE
import net.opatry.tasks.app.ui.screen.TaskListPaneTestTag.COMPLETED_TASK_DELETE_ICON
import net.opatry.tasks.app.ui.screen.TaskListPaneTestTag.COMPLETED_TASK_ICON
import net.opatry.tasks.app.ui.screen.TaskListPaneTestTag.COMPLETED_TASK_NOTES
import net.opatry.tasks.app.ui.screen.TaskListPaneTestTag.COMPLETED_TASK_ROW
import net.opatry.tasks.app.presentation.model.TaskUIModel
import net.opatry.tasks.app.ui.component.CompletedTaskRowTestTag.COMPLETED_TASK_COMPLETION_DATE
import net.opatry.tasks.app.ui.component.CompletedTaskRowTestTag.COMPLETED_TASK_DELETE_ICON
import net.opatry.tasks.app.ui.component.CompletedTaskRowTestTag.COMPLETED_TASK_ICON
import net.opatry.tasks.app.ui.component.CompletedTaskRowTestTag.COMPLETED_TASK_NOTES
import net.opatry.tasks.app.ui.component.CompletedTaskRowTestTag.COMPLETED_TASK_ROW
import net.opatry.tasks.resources.Res
import net.opatry.tasks.resources.task_list_pane_completed_date_label
import net.opatry.tasks.resources.task_list_pane_delete_task_icon_content_desc
import org.jetbrains.annotations.VisibleForTesting
import org.jetbrains.compose.resources.stringResource

@VisibleForTesting
internal object CompletedTaskRowTestTag {
const val COMPLETED_TASK_ROW = "COMPLETED_TASK_ROW"
const val COMPLETED_TASK_ICON = "COMPLETED_TASK_ICON"
const val COMPLETED_TASK_NOTES = "COMPLETED_TASK_NOTES"
const val COMPLETED_TASK_COMPLETION_DATE = "COMPLETED_TASK_COMPLETION_DATE"
const val COMPLETED_TASK_DELETE_ICON = "COMPLETED_TASK_DELETE_ICON"
}

private fun LocalDate.toLabel(): String {
// TODO localize names & format
return if (year == Clock.System.todayIn(TimeZone.currentSystemDefault()).year) {
Expand All @@ -85,9 +94,8 @@ private fun LocalDate.toLabel(): String {
}
}

@VisibleForTesting
@Composable
internal fun CompletedTaskRow(
fun CompletedTaskRow(
task: TaskUIModel,
onAction: (TaskAction) -> Unit,
) {
Expand Down
Loading