Skip to content
15 changes: 0 additions & 15 deletions app/src/main/java/com/example/tudee/data/dao/AppEntryDao.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ package com.example.tudee.data.database

import androidx.room.Database
import androidx.room.RoomDatabase
import com.example.tudee.data.dao.AppEntryDao
import com.example.tudee.data.dao.TaskCategoryDao
import com.example.tudee.data.dao.TaskDao
import com.example.tudee.data.model.AppEntryEntity
import com.example.tudee.data.model.TaskCategoryEntity
import com.example.tudee.data.model.TaskEntity

@Database(
entities = [TaskEntity::class, TaskCategoryEntity::class, AppEntryEntity::class],
entities = [TaskEntity::class, TaskCategoryEntity::class],
version = 1,
exportSchema = false
)
abstract class AppDatabase : RoomDatabase() {
abstract fun taskDao(): TaskDao
abstract fun taskCategoryDao(): TaskCategoryDao
abstract fun appEntryDao(): AppEntryDao
}
10 changes: 0 additions & 10 deletions app/src/main/java/com/example/tudee/data/model/AppEntryEntity.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.example.tudee.data.preferences


import android.content.Context
import androidx.core.content.edit

class PreferencesManager(context: Context) {
private val prefs = context.getSharedPreferences("tudee_preferences", Context.MODE_PRIVATE)

companion object {
private const val KEY_DARK_MODE = "dark_mode"
private const val KEY_ONBOARDING_COMPLETED = "onboarding_completed"
}

fun isDarkMode(): Boolean {
return prefs.getBoolean(KEY_DARK_MODE, false)
}

fun setDarkMode(isDark: Boolean) {
prefs.edit { putBoolean(KEY_DARK_MODE, isDark) }
}

fun isOnboardingCompleted(): Boolean {
return prefs.getBoolean(KEY_ONBOARDING_COMPLETED, false)
}

fun setOnboardingCompleted() {
prefs.edit { putBoolean(KEY_ONBOARDING_COMPLETED, true) }
}
}

This file was deleted.

10 changes: 2 additions & 8 deletions app/src/main/java/com/example/tudee/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ package com.example.tudee.di

import androidx.lifecycle.SavedStateHandle
import androidx.room.Room
import com.example.tudee.data.dao.AppEntryDao
import com.example.tudee.data.dao.TaskCategoryDao
import com.example.tudee.data.dao.TaskDao
import com.example.tudee.data.database.AppDatabase
import com.example.tudee.data.preferences.ThemePreferenceManager
import com.example.tudee.data.preferences.PreferencesManager
import com.example.tudee.data.service.TaskCategoryServiceImpl
import com.example.tudee.data.service.TaskServiceImpl
import com.example.tudee.domain.AppEntry
import com.example.tudee.domain.AppEntryImpl
import com.example.tudee.domain.TaskCategoryService
import com.example.tudee.domain.TaskService
import com.example.tudee.presentation.screen.category.tasks.CategoryTasksViewModel
Expand Down Expand Up @@ -52,10 +49,7 @@ val appModule = module {
}
single<OnBoardingViewModel> { OnBoardingViewModel(get(), get()) }

single<AppEntryDao> { get<AppDatabase>().appEntryDao() }
single<AppEntry> { AppEntryImpl(get()) }

single { ThemePreferenceManager(androidContext()) }
single { PreferencesManager(androidContext()) }


}
6 changes: 0 additions & 6 deletions app/src/main/java/com/example/tudee/domain/AppEntry.kt

This file was deleted.

16 changes: 0 additions & 16 deletions app/src/main/java/com/example/tudee/domain/AppEntryImpl.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.example.tudee.presentation.screen.category.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.tudee.data.preferences.ThemePreferenceManager
import com.example.tudee.domain.TaskCategoryService
import com.example.tudee.domain.TaskService
import com.example.tudee.domain.request.CategoryCreationRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.tudee.R
import com.example.tudee.data.mapper.toCategoryUiState
import com.example.tudee.data.preferences.ThemePreferenceManager
import com.example.tudee.domain.TaskCategoryService
import com.example.tudee.domain.TaskService
import com.example.tudee.domain.entity.Task
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.example.tudee.presentation.screen.onboarding

import android.content.res.Configuration
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
Expand All @@ -12,8 +14,6 @@ import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -44,15 +44,6 @@ fun OnBoardingScreen(
navController: NavController = rememberNavController(),
viewModel: OnBoardingViewModel = getKoin().get()
) {

val isFirstEntry by viewModel.isFirstEntry.collectAsState()

if (!isFirstEntry) {
navController.navigate(Destination.HomeScreen.route) {
popUpTo(Destination.OnBoardingScreen.route) { inclusive = true }
}
}

val onboardingOnBoardingPageUiModels = listOf(
OnBoardingPageUiModel(
title = stringResource(R.string.on_boarding_title1),
Expand Down Expand Up @@ -147,7 +138,13 @@ private fun OnBoardingContent(
onClick = {
scope.launch {
if (pageState.currentPage != onBoardingPageUiModels.lastIndex) {
pageState.animateScrollToPage(pageState.currentPage + Pages.SecondPage.page)
pageState.animateScrollToPage(
page = pageState.currentPage + 1,
animationSpec = spring(
dampingRatio = Spring.DampingRatioLowBouncy,
stiffness = Spring.StiffnessLow
)
)
} else {
navigateToHome()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,16 @@ package com.example.tudee.presentation.screen.onboarding

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.tudee.domain.AppEntry
import com.example.tudee.data.preferences.PreferencesManager
import com.example.tudee.domain.TaskCategoryService
import com.example.tudee.presentation.utils.predefinedCategories
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch

class OnBoardingViewModel(
private val taskCategoryService: TaskCategoryService,
private val appEntry: AppEntry
private val prefs: PreferencesManager
) : ViewModel() {

private val _isFirstEntry = MutableStateFlow(true)
val isFirstEntry = _isFirstEntry.asStateFlow()

init {
viewModelScope.launch {
_isFirstEntry.value = appEntry.isFirstEntry()
}
}

fun saveFirstEntry() {
viewModelScope.launch {
appEntry.saveFirstEntry()
}
}

fun saveFirstEntry() = prefs.setOnboardingCompleted()
fun loadInitialData() {
viewModelScope.launch {
predefinedCategories.forEach { taskCategoryService.createCategory(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.example.tudee.R
import com.example.tudee.data.preferences.PreferencesManager
import com.example.tudee.designsystem.theme.TudeeTheme
import com.example.tudee.domain.AppEntry
import com.example.tudee.naviagtion.Destination
import com.example.tudee.presentation.themeViewModel.ThemeViewModel
import kotlinx.coroutines.delay
Expand All @@ -37,12 +37,12 @@ fun SplashScreen(
overlayColor: Color = TudeeTheme.color.statusColors.overlay,
backgroundPainter: Painter = painterResource(R.drawable.background_ellipse),
iconPainter: Painter = painterResource(R.drawable.tudee_logo),
appEntry: AppEntry = getKoin().get()
prefs: PreferencesManager = getKoin().get()
) {
val isDark by themeViewModel.isDarkMode.collectAsState()
LaunchedEffect(Unit) {
delay(3000)
if (appEntry.isFirstEntry()) {
if (prefs.isOnboardingCompleted().not()) {
navController.navigate(Destination.OnBoardingScreen.route) {
popUpTo(Destination.SplashScreen.route) { inclusive = true }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package com.example.tudee.presentation.screen.task_screen.viewmodel
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.tudee.data.preferences.ThemePreferenceManager
import com.example.tudee.data.preferences.PreferencesManager
import com.example.tudee.domain.TaskCategoryService
import com.example.tudee.domain.TaskService
import com.example.tudee.domain.entity.TaskPriority
import com.example.tudee.domain.entity.TaskStatus
import com.example.tudee.presentation.components.buttons.ButtonState
import com.example.tudee.presentation.screen.task_screen.interactors.TaskScreenInteractor
Expand All @@ -33,7 +32,7 @@ class TasksScreenViewModel(
private val taskService: TaskService,
private val categoryService: TaskCategoryService,
private val savedStateHandle: SavedStateHandle,
private val themePrefs: ThemePreferenceManager
private val themePrefs: PreferencesManager
) : ViewModel(), TaskScreenInteractor {
private val _taskScreenUiState = MutableStateFlow(TasksScreenUiState( isDarkMode = themePrefs.isDarkMode()))
val taskScreenUiState = _taskScreenUiState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.example.tudee.presentation.themeViewModel

import androidx.lifecycle.ViewModel
import com.example.tudee.data.preferences.ThemePreferenceManager
import com.example.tudee.data.preferences.PreferencesManager
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow

class ThemeViewModel(private val prefs: ThemePreferenceManager) : ViewModel() {
class ThemeViewModel(private val prefs: PreferencesManager) : ViewModel() {
private val _isDarkMode = MutableStateFlow(prefs.isDarkMode())
val isDarkMode: StateFlow<Boolean> = _isDarkMode

Expand Down
Loading