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 @@ -35,6 +35,7 @@ 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.ui.tooling.TaskfolioThemedPreview

Expand All @@ -54,9 +55,8 @@ private fun TaskListMenuPreview() {
Icon(LucideIcons.EllipsisVertical, null)
TaskListMenu(
taskList = TaskListUIModel(
id = 0L,
id = TaskListId(0L),
title = "My task list",
lastUpdate = "TODO DATE",
),
expanded = true,
onAction = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ 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.ui.tooling.TaskfolioThemedPreview

Expand All @@ -40,9 +41,8 @@ private fun TaskListRowScaffold(
) {
TaskListRow(
TaskListUIModel(
id = 0L,
id = TaskListId(0L),
title = title,
"TODO DATE",
),
isSelected = isSelected,
onClick = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ 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.ui.tooling.TaskfolioThemedPreview

Expand All @@ -50,7 +51,7 @@ private fun TaskRowScaffold(
RemainingTaskRow(
emptyList(),
TaskUIModel(
id = 0L,
id = TaskId(0L),
title = title,
notes = notes,
dueDate = dueDate,
Expand Down
30 changes: 30 additions & 0 deletions tasks-app-shared/src/commonMain/kotlin/net/opatry/Logger.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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

interface Logger {
fun logInfo(message: String)
fun logError(message: String)
fun logError(message: String, e: Exception)
fun logError(e: Exception)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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

import kotlinx.datetime.Clock
import kotlinx.datetime.Instant

class PrintLogger(
private val clockNow: () -> Instant = Clock.System::now,
) : Logger {
private fun log(level: String, message: String) {
println("[${clockNow()}][$level] $message")
}

override fun logInfo(message: String) {
log("info", message)
}

override fun logError(message: String) {
log("error", message)
}

override fun logError(message: String, e: Exception) {
logError(message)
e.printStackTrace()
}

override fun logError(e: Exception) {
logError(e.message ?: "", e)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

package net.opatry.tasks.app.di

import net.opatry.Logger
import net.opatry.PrintLogger
import net.opatry.google.profile.HttpUserInfoApi
import net.opatry.google.profile.UserInfoApi
import net.opatry.tasks.app.ui.TaskListsViewModel
Expand All @@ -36,8 +38,15 @@ import org.koin.dsl.module
val tasksAppModule = module {
singleOf(::TaskRepository)

// TODO replace with a more sophisticated logger (standard & KMP compatible ideally)
// On Android, should also log in Firebase Crashlytics
// see #118
single<Logger> {
PrintLogger()
}

viewModel {
TaskListsViewModel(get())
TaskListsViewModel(get(), get())
}

single<UserInfoApi> {
Expand Down
Loading