From 417ee4c1a99570a8c851be39f51881332b24f6e3 Mon Sep 17 00:00:00 2001 From: Frank1234 Date: Mon, 12 Aug 2024 11:33:09 +0200 Subject: [PATCH] CHANGE folder structure change for easier usage --- .../kotlin/nl/q42/template/navigation/NavGraphs.kt | 10 +++++----- .../home => home/main/presentation}/HomeViewModel.kt | 4 ++-- .../home => home/main/presentation}/HomeViewState.kt | 2 +- .../template/{ui/home => home/main/ui}/HomeContent.kt | 4 ++-- .../template/{ui/home => home/main/ui}/HomeScreen.kt | 5 ++--- .../second/presentation}/HomeSecondViewModel.kt | 3 +-- .../home/second/presentation/HomeSecondViewState.kt | 3 +++ .../home/second => home/second/ui}/HomeSecondScreen.kt | 4 ++-- .../presentation/home/second/HomeSecondViewState.kt | 3 --- .../main/presentation}/HomeViewModelTest.kt | 7 ++++++- .../presentation}/start/OnboardingStartViewModel.kt | 2 +- .../presentation/start/OnboardingStartViewState.kt | 3 +++ .../ui}/start/OnboardingStartScreen.kt | 5 ++--- .../onboarding/start/OnboardingStartViewState.kt | 3 --- 14 files changed, 30 insertions(+), 28 deletions(-) rename feature/home/src/main/kotlin/nl/q42/template/{presentation/home => home/main/presentation}/HomeViewModel.kt (95%) rename feature/home/src/main/kotlin/nl/q42/template/{presentation/home => home/main/presentation}/HomeViewState.kt (81%) rename feature/home/src/main/kotlin/nl/q42/template/{ui/home => home/main/ui}/HomeContent.kt (95%) rename feature/home/src/main/kotlin/nl/q42/template/{ui/home => home/main/ui}/HomeScreen.kt (86%) rename feature/home/src/main/kotlin/nl/q42/template/{presentation/home/second => home/second/presentation}/HomeSecondViewModel.kt (91%) create mode 100644 feature/home/src/main/kotlin/nl/q42/template/home/second/presentation/HomeSecondViewState.kt rename feature/home/src/main/kotlin/nl/q42/template/{ui/home/second => home/second/ui}/HomeSecondScreen.kt (94%) delete mode 100644 feature/home/src/main/kotlin/nl/q42/template/presentation/home/second/HomeSecondViewState.kt rename feature/home/src/test/kotlin/nl/q42/template/{presentation/home => home/main/presentation}/HomeViewModelTest.kt (87%) rename feature/onboarding/src/main/kotlin/nl/q42/template/{presentation/onboarding => onboarding/presentation}/start/OnboardingStartViewModel.kt (93%) create mode 100644 feature/onboarding/src/main/kotlin/nl/q42/template/onboarding/presentation/start/OnboardingStartViewState.kt rename feature/onboarding/src/main/kotlin/nl/q42/template/{ui/onboarding => onboarding/ui}/start/OnboardingStartScreen.kt (88%) delete mode 100644 feature/onboarding/src/main/kotlin/nl/q42/template/presentation/onboarding/start/OnboardingStartViewState.kt diff --git a/app/src/main/kotlin/nl/q42/template/navigation/NavGraphs.kt b/app/src/main/kotlin/nl/q42/template/navigation/NavGraphs.kt index ef65f07..4a50c8c 100644 --- a/app/src/main/kotlin/nl/q42/template/navigation/NavGraphs.kt +++ b/app/src/main/kotlin/nl/q42/template/navigation/NavGraphs.kt @@ -2,9 +2,9 @@ package nl.q42.template.navigation import com.ramcosta.composedestinations.spec.DestinationSpec import com.ramcosta.composedestinations.spec.NavGraphSpec -import nl.q42.template.ui.home.destinations.HomeScreenDestination -import nl.q42.template.ui.home.destinations.HomeSecondScreenDestination -import nl.q42.template.ui.onboarding.start.destinations.OnboardingStartScreenDestination +import nl.q42.template.home.destinations.HomeScreenDestination +import nl.q42.template.home.destinations.HomeSecondScreenDestination +import nl.q42.template.onboarding.ui.start.destinations.OnboardingStartScreenDestination /** * @@ -16,7 +16,7 @@ object NavGraphs { val home = object : NavGraphSpec { override val route = AppGraphRoutes.home - + override val startRoute = HomeScreenDestination override val destinationsByRoute = listOf>( @@ -45,4 +45,4 @@ object NavGraphs { home, onboarding ) } -} \ No newline at end of file +} diff --git a/feature/home/src/main/kotlin/nl/q42/template/presentation/home/HomeViewModel.kt b/feature/home/src/main/kotlin/nl/q42/template/home/main/presentation/HomeViewModel.kt similarity index 95% rename from feature/home/src/main/kotlin/nl/q42/template/presentation/home/HomeViewModel.kt rename to feature/home/src/main/kotlin/nl/q42/template/home/main/presentation/HomeViewModel.kt index e3124cc..06e083b 100644 --- a/feature/home/src/main/kotlin/nl/q42/template/presentation/home/HomeViewModel.kt +++ b/feature/home/src/main/kotlin/nl/q42/template/home/main/presentation/HomeViewModel.kt @@ -1,4 +1,4 @@ -package nl.q42.template.presentation.home +package nl.q42.template.home.main.presentation import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope @@ -16,9 +16,9 @@ import nl.q42.template.actionresult.data.handleAction import nl.q42.template.domain.user.usecase.FetchUserUseCase import nl.q42.template.domain.user.usecase.GetUserFlowUseCase import nl.q42.template.feature.home.R +import nl.q42.template.home.destinations.HomeSecondScreenDestination import nl.q42.template.navigation.AppGraphRoutes import nl.q42.template.navigation.viewmodel.RouteNavigator -import nl.q42.template.ui.home.destinations.HomeSecondScreenDestination import nl.q42.template.ui.presentation.ViewStateString import javax.inject.Inject diff --git a/feature/home/src/main/kotlin/nl/q42/template/presentation/home/HomeViewState.kt b/feature/home/src/main/kotlin/nl/q42/template/home/main/presentation/HomeViewState.kt similarity index 81% rename from feature/home/src/main/kotlin/nl/q42/template/presentation/home/HomeViewState.kt rename to feature/home/src/main/kotlin/nl/q42/template/home/main/presentation/HomeViewState.kt index 51da46f..ff319a8 100644 --- a/feature/home/src/main/kotlin/nl/q42/template/presentation/home/HomeViewState.kt +++ b/feature/home/src/main/kotlin/nl/q42/template/home/main/presentation/HomeViewState.kt @@ -1,4 +1,4 @@ -package nl.q42.template.presentation.home +package nl.q42.template.home.main.presentation import nl.q42.template.ui.presentation.ViewStateString diff --git a/feature/home/src/main/kotlin/nl/q42/template/ui/home/HomeContent.kt b/feature/home/src/main/kotlin/nl/q42/template/home/main/ui/HomeContent.kt similarity index 95% rename from feature/home/src/main/kotlin/nl/q42/template/ui/home/HomeContent.kt rename to feature/home/src/main/kotlin/nl/q42/template/home/main/ui/HomeContent.kt index 2bdddb7..b113920 100644 --- a/feature/home/src/main/kotlin/nl/q42/template/ui/home/HomeContent.kt +++ b/feature/home/src/main/kotlin/nl/q42/template/home/main/ui/HomeContent.kt @@ -1,4 +1,4 @@ -package nl.q42.template.ui.home +package nl.q42.template.home.main.ui import androidx.compose.foundation.layout.Arrangement.Center import androidx.compose.foundation.layout.Column @@ -9,7 +9,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment.Companion.CenterHorizontally import androidx.compose.ui.Modifier -import nl.q42.template.presentation.home.HomeViewState +import nl.q42.template.home.main.presentation.HomeViewState import nl.q42.template.ui.compose.get import nl.q42.template.ui.presentation.toViewStateString import nl.q42.template.ui.theme.PreviewAppTheme diff --git a/feature/home/src/main/kotlin/nl/q42/template/ui/home/HomeScreen.kt b/feature/home/src/main/kotlin/nl/q42/template/home/main/ui/HomeScreen.kt similarity index 86% rename from feature/home/src/main/kotlin/nl/q42/template/ui/home/HomeScreen.kt rename to feature/home/src/main/kotlin/nl/q42/template/home/main/ui/HomeScreen.kt index e38e228..ad2d588 100644 --- a/feature/home/src/main/kotlin/nl/q42/template/ui/home/HomeScreen.kt +++ b/feature/home/src/main/kotlin/nl/q42/template/home/main/ui/HomeScreen.kt @@ -1,4 +1,4 @@ -package nl.q42.template.ui.home +package nl.q42.template.home.main.ui import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -6,9 +6,8 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator +import nl.q42.template.home.main.presentation.HomeViewModel import nl.q42.template.navigation.viewmodel.InitNavigator -import nl.q42.template.presentation.home.HomeViewModel -import nl.q42.template.presentation.home.HomeViewState import nl.q42.template.ui.compose.OnLifecycleResume @Destination diff --git a/feature/home/src/main/kotlin/nl/q42/template/presentation/home/second/HomeSecondViewModel.kt b/feature/home/src/main/kotlin/nl/q42/template/home/second/presentation/HomeSecondViewModel.kt similarity index 91% rename from feature/home/src/main/kotlin/nl/q42/template/presentation/home/second/HomeSecondViewModel.kt rename to feature/home/src/main/kotlin/nl/q42/template/home/second/presentation/HomeSecondViewModel.kt index b52e824..cbb5c30 100644 --- a/feature/home/src/main/kotlin/nl/q42/template/presentation/home/second/HomeSecondViewModel.kt +++ b/feature/home/src/main/kotlin/nl/q42/template/home/second/presentation/HomeSecondViewModel.kt @@ -1,9 +1,8 @@ -package nl.q42.template.presentation.home.second +package nl.q42.template.home.second.presentation import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow diff --git a/feature/home/src/main/kotlin/nl/q42/template/home/second/presentation/HomeSecondViewState.kt b/feature/home/src/main/kotlin/nl/q42/template/home/second/presentation/HomeSecondViewState.kt new file mode 100644 index 0000000..a6194c4 --- /dev/null +++ b/feature/home/src/main/kotlin/nl/q42/template/home/second/presentation/HomeSecondViewState.kt @@ -0,0 +1,3 @@ +package nl.q42.template.home.second.presentation + +class HomeSecondViewState(val title: String) diff --git a/feature/home/src/main/kotlin/nl/q42/template/ui/home/second/HomeSecondScreen.kt b/feature/home/src/main/kotlin/nl/q42/template/home/second/ui/HomeSecondScreen.kt similarity index 94% rename from feature/home/src/main/kotlin/nl/q42/template/ui/home/second/HomeSecondScreen.kt rename to feature/home/src/main/kotlin/nl/q42/template/home/second/ui/HomeSecondScreen.kt index b08c841..d114769 100644 --- a/feature/home/src/main/kotlin/nl/q42/template/ui/home/second/HomeSecondScreen.kt +++ b/feature/home/src/main/kotlin/nl/q42/template/home/second/ui/HomeSecondScreen.kt @@ -1,4 +1,4 @@ -package nl.q42.template.ui.home.second +package nl.q42.template.home.second.ui import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -14,8 +14,8 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator +import nl.q42.template.home.second.presentation.HomeSecondViewModel import nl.q42.template.navigation.viewmodel.InitNavigator -import nl.q42.template.presentation.home.second.HomeSecondViewModel @Destination @Composable diff --git a/feature/home/src/main/kotlin/nl/q42/template/presentation/home/second/HomeSecondViewState.kt b/feature/home/src/main/kotlin/nl/q42/template/presentation/home/second/HomeSecondViewState.kt deleted file mode 100644 index 1156c83..0000000 --- a/feature/home/src/main/kotlin/nl/q42/template/presentation/home/second/HomeSecondViewState.kt +++ /dev/null @@ -1,3 +0,0 @@ -package nl.q42.template.presentation.home.second - -class HomeSecondViewState(val title: String) \ No newline at end of file diff --git a/feature/home/src/test/kotlin/nl/q42/template/presentation/home/HomeViewModelTest.kt b/feature/home/src/test/kotlin/nl/q42/template/home/main/presentation/HomeViewModelTest.kt similarity index 87% rename from feature/home/src/test/kotlin/nl/q42/template/presentation/home/HomeViewModelTest.kt rename to feature/home/src/test/kotlin/nl/q42/template/home/main/presentation/HomeViewModelTest.kt index 34773db..8c282f4 100644 --- a/feature/home/src/test/kotlin/nl/q42/template/presentation/home/HomeViewModelTest.kt +++ b/feature/home/src/test/kotlin/nl/q42/template/home/main/presentation/HomeViewModelTest.kt @@ -1,4 +1,4 @@ -package nl.q42.template.presentation.home +package nl.q42.template.home.main.presentation import app.cash.turbine.test import io.mockk.coEvery @@ -10,10 +10,15 @@ import kotlinx.coroutines.test.runTest import nl.q42.template.actionresult.domain.ActionResult import nl.q42.template.domain.user.usecase.FetchUserUseCase import nl.q42.template.domain.user.usecase.GetUserFlowUseCase +import nl.q42.template.presentation.home.MainDispatcherRule import org.junit.Rule import org.junit.Test import kotlin.time.Duration.Companion.seconds +/** + * An example ViewModel test. Weather you want to test ViewModels is up to you. On most projects, + * you probably want to focus on unit testing the Domain layer first. + */ class HomeViewModelTest { @get:Rule diff --git a/feature/onboarding/src/main/kotlin/nl/q42/template/presentation/onboarding/start/OnboardingStartViewModel.kt b/feature/onboarding/src/main/kotlin/nl/q42/template/onboarding/presentation/start/OnboardingStartViewModel.kt similarity index 93% rename from feature/onboarding/src/main/kotlin/nl/q42/template/presentation/onboarding/start/OnboardingStartViewModel.kt rename to feature/onboarding/src/main/kotlin/nl/q42/template/onboarding/presentation/start/OnboardingStartViewModel.kt index 4062168..37c5acc 100644 --- a/feature/onboarding/src/main/kotlin/nl/q42/template/presentation/onboarding/start/OnboardingStartViewModel.kt +++ b/feature/onboarding/src/main/kotlin/nl/q42/template/onboarding/presentation/start/OnboardingStartViewModel.kt @@ -1,4 +1,4 @@ -package nl.q42.template.presentation.onboarding.start +package nl.q42.template.onboarding.presentation.start import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel diff --git a/feature/onboarding/src/main/kotlin/nl/q42/template/onboarding/presentation/start/OnboardingStartViewState.kt b/feature/onboarding/src/main/kotlin/nl/q42/template/onboarding/presentation/start/OnboardingStartViewState.kt new file mode 100644 index 0000000..3d90fbc --- /dev/null +++ b/feature/onboarding/src/main/kotlin/nl/q42/template/onboarding/presentation/start/OnboardingStartViewState.kt @@ -0,0 +1,3 @@ +package nl.q42.template.onboarding.presentation.start + +class OnboardingStartViewState(val title: String) diff --git a/feature/onboarding/src/main/kotlin/nl/q42/template/ui/onboarding/start/OnboardingStartScreen.kt b/feature/onboarding/src/main/kotlin/nl/q42/template/onboarding/ui/start/OnboardingStartScreen.kt similarity index 88% rename from feature/onboarding/src/main/kotlin/nl/q42/template/ui/onboarding/start/OnboardingStartScreen.kt rename to feature/onboarding/src/main/kotlin/nl/q42/template/onboarding/ui/start/OnboardingStartScreen.kt index 4051662..6d6b3e5 100644 --- a/feature/onboarding/src/main/kotlin/nl/q42/template/ui/onboarding/start/OnboardingStartScreen.kt +++ b/feature/onboarding/src/main/kotlin/nl/q42/template/onboarding/ui/start/OnboardingStartScreen.kt @@ -1,4 +1,4 @@ -package nl.q42.template.ui.onboarding.start +package nl.q42.template.onboarding.ui.start import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -15,8 +15,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import nl.q42.template.navigation.viewmodel.InitNavigator -import nl.q42.template.presentation.onboarding.start.OnboardingStartViewModel -import nl.q42.template.presentation.onboarding.start.OnboardingStartViewState +import nl.q42.template.onboarding.presentation.start.OnboardingStartViewModel @Destination @Composable diff --git a/feature/onboarding/src/main/kotlin/nl/q42/template/presentation/onboarding/start/OnboardingStartViewState.kt b/feature/onboarding/src/main/kotlin/nl/q42/template/presentation/onboarding/start/OnboardingStartViewState.kt deleted file mode 100644 index f2b682f..0000000 --- a/feature/onboarding/src/main/kotlin/nl/q42/template/presentation/onboarding/start/OnboardingStartViewState.kt +++ /dev/null @@ -1,3 +0,0 @@ -package nl.q42.template.presentation.onboarding.start - -class OnboardingStartViewState(val title: String) \ No newline at end of file