Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
983549b
[TASK] [DESKTOP] Update according to new changes
VetoForest Nov 6, 2024
7bedb4b
Merge branch 'master' into stolen_destkop_ui
VetoForest Nov 6, 2024
493a14c
Window size
VetoForest Nov 6, 2024
ec8b0ac
icons
VetoForest Nov 6, 2024
6341ef7
icons
VetoForest Nov 6, 2024
31c5741
xz
VetoForest Nov 6, 2024
d8a4c86
xz
VetoForest Nov 8, 2024
23935bf
Changed home screen ui
VetoForest Nov 8, 2024
ab1cce6
``
VetoForest Nov 11, 2024
f7f0946
Merge branch 'master' into stolen_destkop_ui
VetoForest Nov 11, 2024
50f7836
Profile screen
VetoForest Nov 11, 2024
eea1010
Profile screen
VetoForest Nov 13, 2024
e550e15
Profile screen
VetoForest Nov 13, 2024
8c81c29
.!.
VetoForest Nov 13, 2024
756883a
language
VetoForest Nov 15, 2024
4da9acd
language
VetoForest Nov 20, 2024
f5c8004
я
VetoForest Nov 20, 2024
4835a5a
Merge branch 'master' into stolen_destkop_ui
VetoForest Nov 20, 2024
fefdae8
я
VetoForest Nov 20, 2024
b36b4be
[TASK] GoalScreen base design
RossSihovsk Nov 20, 2024
04f9693
[TASK] No Goals design and start view model
RossSihovsk Nov 20, 2024
1170bb1
[TASK] Goal structure
RossSihovsk Nov 24, 2024
fc22c2c
[TASK] Separate buttons for save and add new task
RossSihovsk Nov 24, 2024
df1b8c3
[TASK] Finished with Goals
RossSihovsk Nov 24, 2024
f128b19
Minor
RossSihovsk Nov 25, 2024
0b1abdf
я
VetoForest Nov 25, 2024
15f87bd
Merge remote-tracking branch 'origin/GoalScreen' into stolen_destkop_ui
VetoForest Nov 25, 2024
39267af
я
VetoForest Nov 28, 2024
f2f9773
Merge branch 'master' into stolen_destkop_ui
VetoForest Nov 28, 2024
5070848
God bless this code
VetoForest Nov 28, 2024
27b5716
Background
VetoForest Nov 29, 2024
d2e2c6d
dates and notifications
VetoForest Nov 29, 2024
f1a84b6
Merge branch 'master' into stolen_destkop_ui
VetoForest Dec 1, 2024
d75600f
xz
VetoForest Dec 1, 2024
e702bf1
zxczx
VetoForest Dec 1, 2024
6348bef
zxczx
VetoForest Dec 3, 2024
11dd3fd
zxczx
VetoForest Dec 3, 2024
99c2d41
zxczx
VetoForest Dec 16, 2024
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
9 changes: 7 additions & 2 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,17 @@ kotlin {

// Ktor serialization with JSON support
implementation(libs.ktor.serialization.kotlinx.json)
implementation(compose.materialIconsExtended)

}
desktopMain.dependencies {
implementation(compose.desktop.currentOs)
implementation(libs.notify)

implementation(compose.desktop.currentOs)
//SQLDelight Desktop
implementation(libs.sqldelight.jvm)

implementation(libs.java.jwt)
implementation (libs.json)
//Auth Desktop
implementation(libs.google.auth.desktop)
implementation(libs.ktor.client.core)
Expand Down Expand Up @@ -153,3 +157,4 @@ compose.desktop {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import cafe.adriel.voyager.navigator.Navigator
import co.touchlab.kermit.Logger
import com.project.lifeos.R
import com.project.lifeos.data.Priority
import com.project.lifeos.data.Reminder
import com.project.lifeos.data.Task
import com.project.lifeos.viewmodel.AddTaskViewModel
import java.text.SimpleDateFormat
import java.time.Instant
Expand All @@ -62,7 +66,16 @@ import java.util.Locale

@OptIn(ExperimentalMaterial3Api::class)
@Composable
actual fun AddTaskScreenContent(viewModel: AddTaskViewModel, logger: Logger) {
actual fun AddTaskScreenContent(navigator: Navigator?,
viewModel: AddTaskViewModel?, task: Task?, logger: Logger?, onDone: (
title: String,
description: String?,
time: Long?,
dates: List<String>,
checkItems: List<String>,
reminder: Reminder,
priority: Priority,
) -> Unit){
ModalBottomSheet(
onDismissRequest = {},

Expand Down Expand Up @@ -148,10 +161,10 @@ actual fun AddTaskScreenContent(viewModel: AddTaskViewModel, logger: Logger) {
Spacer(modifier = Modifier.height(60.dp))

EnableSaveButton(taskDate, taskDescription, taskTime, taskTitle) {
logger.i(
logger?.i(
"Save task with title: ${taskTitle.value}, description: ${taskDescription.value}, time: ${taskTime.value}, date: ${taskDate.value}"
)
viewModel.saveTask(
viewModel?.saveTask(
title = taskTitle.value,
description = taskDescription.value,
time = taskTime.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
Expand Down Expand Up @@ -216,7 +217,6 @@ fun TaskExpandedSection(
}
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun TasksContent(
tasks: List<Task>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ actual fun ProfileScreenContent(
)
val credential = result.credential
val userCred = GoogleIdTokenCredential.createFrom(credential.data)

println(userCred)
User(
name = userCred.displayName ?: "Unknown name",
mail = if (userCred.id.contains("@")) userCred.id else "Unknown email",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,7 @@ import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
Expand Down
Binary file added composeApp/src/androidMain/res/drawable/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ abstract class NotificationScheduler {
}

schedulePlatformNotification(task, user, validatedTimeForNotification)

}

private fun isReminderStillValid(dateTime: Long, reminder: Reminder): Pair<Boolean, Long> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
package com.project.lifeos.ui.bottomNavigation

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.filled.Star
import androidx.compose.material.icons.outlined.Add
import androidx.compose.material.icons.outlined.Favorite
import androidx.compose.material.icons.outlined.Home
import androidx.compose.material.icons.outlined.Person
import androidx.compose.material.icons.outlined.Star
import androidx.compose.material.icons.filled.*
import androidx.compose.material.icons.outlined.*
import androidx.compose.ui.graphics.vector.ImageVector

enum class BottomBarItems(
Expand All @@ -25,8 +17,8 @@ enum class BottomBarItems(
),
GOALS(
title = "Goals",
selectedIcon = Icons.Filled.Favorite,
unSelectedIcon = Icons.Outlined.Favorite
selectedIcon = Icons.Filled.Assistant,
unSelectedIcon = Icons.Outlined.Assistant
),
ADD_TASK(
title = "Add Task",
Expand All @@ -35,8 +27,8 @@ enum class BottomBarItems(
),
STATS(
title = "Stats",
selectedIcon = Icons.Filled.Star,
unSelectedIcon = Icons.Outlined.Star
selectedIcon = Icons.Filled.AlignVerticalBottom,
unSelectedIcon = Icons.Outlined.AlignVerticalBottom
),
PROFILE(
title = "Profile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,45 @@ package com.project.lifeos.ui.screen
import androidx.compose.runtime.Composable
import cafe.adriel.voyager.core.model.rememberScreenModel
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.currentOrThrow
import co.touchlab.kermit.Logger
import com.project.lifeos.data.Priority
import com.project.lifeos.data.Reminder
import com.project.lifeos.data.Task
import com.project.lifeos.di.AppModuleProvider
import com.project.lifeos.viewmodel.AddTaskViewModel

@Composable
expect fun AddTaskScreenContent(viewModel: AddTaskViewModel, logger: Logger)
expect fun AddTaskScreenContent(navigator: Navigator?=null,
viewModel: AddTaskViewModel?, task: Task?, logger: Logger?, onDone: (
title: String,
description: String?,
time: Long?,
dates: List<String>,
checkItems: List<String>,
reminder: Reminder,
priority: Priority,
) -> Unit)

private const val TAG = "AddTaskScreen"
private val logger = Logger.withTag(TAG)

class AddTaskScreen : Screen {
data class AddTaskScreen(private val task:Task? = null, val onDone: (
title: String,
description: String?,
time: Long?,
dates: List<String>,
checkItems: List<String>,
reminder: Reminder,
priority: Priority,
) -> Unit ={ _, _, _, _, _, _, _, -> }) : Screen {
@Composable
override fun Content() {
val navigator = LocalNavigator.currentOrThrow

val taskViewModel = rememberScreenModel { AppModuleProvider.getAppModule().addTaskViewModel }
AddTaskScreenContent(taskViewModel, logger)
AddTaskScreenContent(navigator,taskViewModel,task, logger,onDone)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import com.project.lifeos.viewmodel.HomeScreenViewModel
expect fun HomeScreenContent(viewModel: HomeScreenViewModel, navigator: Navigator? = null)


/**
not serializable objects should be outside of class
otherwise there would be an exception after onPause()
*/

private val logger = Logger.withTag("HomeScreen")

class HomeScreen : Screen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ fun Navigator.safePush(screen: Screen) {
if (items.isNotEmpty()) logger.d("last: ${items.last().key}")
if (items.isNotEmpty() && items.last().key == screen.key) {
logger.d("return")
// if (items.isNotEmpty() && items.firstOrNull { it.key == screen.key } != null) {
return
}
logger.d("push")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class HomeScreenViewModel(
val newStatus = task.dateStatuses.first { it.date.contains(currentDate) }.copy(status = !status)

logger.d("newStatus: $newStatus")
val updateJob = screenModelScope.async {
val updateJob = screenModelScope.async(Dispatchers.IO) {
taskRepository.onTaskStatusChanged(newStatus, task)
}

Expand All @@ -75,7 +75,7 @@ class HomeScreenViewModel(
return Pair(completedTasks, uncompletedTasks)
}

private fun updateTasksState(changeJob: Deferred<Unit>? = null) = screenModelScope.launch {
private fun updateTasksState(changeJob: Deferred<Unit>? = null) = screenModelScope.launch(context = Dispatchers.IO){
changeJob?.onAwait
val updatedList = taskRepository.getTasksForDay(
day = currentDate, userMail = userRepository.getLastUser()?.mail
Expand Down Expand Up @@ -130,7 +130,7 @@ class HomeScreenViewModel(
logger.i("deleteForToday $task")
screenModelScope.launch(Dispatchers.IO) {
task?.let { taskToDelete ->
val updateJob = screenModelScope.async {
val updateJob = screenModelScope.async(Dispatchers.IO) {
val updatedDates = task.dateStatuses.toMutableList().apply {
removeIf { it.date.contains(currentDate) }
}
Expand All @@ -146,7 +146,7 @@ class HomeScreenViewModel(
logger.i("deleteCompletely $task")
screenModelScope.launch(Dispatchers.IO) {
task?.let { taskToDelete ->
val updateJob = screenModelScope.async {
val updateJob = screenModelScope.async(Dispatchers.IO) {
taskRepository.deleteCompletely(taskToDelete.id!!)
}

Expand All @@ -173,7 +173,7 @@ class HomeScreenViewModel(
)

screenModelScope.launch(Dispatchers.IO) {
val updateJob = screenModelScope.async {
val updateJob = screenModelScope.async(Dispatchers.IO) {
taskRepository.updateTask(taskId, title, description, time, dates, checkItems, reminder, priority)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UserViewModel(
val user = _user.asStateFlow()
fun signIn(
signInPerform: suspend () -> User?
) = screenModelScope.launch {
) = screenModelScope.launch(Dispatchers.IO) {
logger.d("Init")
signInPerform()?.let { user ->
logger.d("User founded: $user")
Expand All @@ -40,14 +40,14 @@ class UserViewModel(
_uiState.emit(ProfileUiState.NoUsers)
}

fun signOut() = screenModelScope.launch {
fun signOut() = screenModelScope.launch(Dispatchers.IO) {
_uiState.emit(ProfileUiState.NoUsers)
userRepository.signOut()
_user.emit(null)
}

fun deleteAllDataForUser(userMail: String) {
screenModelScope.launch {
screenModelScope.launch(Dispatchers.IO) {
logger.d("deleteAllDataForUser: $userMail")
taskRepository.deleteAllForUser(userMail)
goalRepository.deleteAllForUser(userMail)
Expand Down
Binary file added composeApp/src/commonMain/resources/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/goals.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/month.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/no_data.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/no_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/on_time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/personal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/six_month.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/sports.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/study.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/two_weeks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/work.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/commonMain/resources/year.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions composeApp/src/desktopMain/kotlin/com/project/lifeos/main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.project.lifeos

import androidx.compose.ui.window.Window
import androidx.compose.ui.Alignment
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import androidx.compose.ui.window.WindowPosition


fun main() = application {
val state = rememberWindowState(position = WindowPosition(Alignment.Center), size = DpSize(1120.dp, 900.dp))
Window(onCloseRequest = ::exitApplication, title = "Should", state = state)
{
App()
}
}

Original file line number Diff line number Diff line change
@@ -1,10 +1,58 @@
package com.project.lifeos.notification

import com.project.lifeos.data.Task
import com.project.lifeos.data.User
import java.awt.*
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit

class DesktopNotificationScheduler : NotificationScheduler() {
override fun schedulePlatformNotification(task: Task, user: User?, validatedTimeForNotification: List<Long>) {
task.description?.let { scheduleNotificationWithExecutor(task.title, it, validatedTimeForNotification) }
}

private fun showDesktopNotification(title: String, message: String) {
if (!SystemTray.isSupported()) {
println("SystemTray is not supported")
return
}

val tray = SystemTray.getSystemTray()
val image = Toolkit.getDefaultToolkit().createImage("on_time.png") // Provide a small icon here

val trayIcon = TrayIcon(image, "Notification Example")
trayIcon.isImageAutoSize = true
trayIcon.toolTip = "Notification Example"

try {
tray.add(trayIcon)
trayIcon.displayMessage(title, message, TrayIcon.MessageType.INFO)
} catch (e: Exception) {
e.printStackTrace()
}
}

private fun scheduleNotificationWithExecutor(
title: String,
message: String,
targetDateTime: List<Long>
) {
val scheduler = Executors.newSingleThreadScheduledExecutor()
targetDateTime.forEach {
val delay = it - System.currentTimeMillis()
if (delay <= 0) {
return
}
scheduler.schedule({
showDesktopNotification(title, message)
scheduler.shutdown()
}, delay, TimeUnit.MILLISECONDS)
}

}






}
Loading