From bc9a35fa47942f996b3c2b0310d25d176d1dcbf2 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Fri, 22 Nov 2024 11:23:22 +0700 Subject: [PATCH] Show user profile only if no user profile has been created yet. To get the create user profile page shown, one need to delete the data directory in simulator, or the rest api data directory if client mode is used. with that the created user identity is deleted. --- .../presentation/di/PresentationModule.kt | 1 + .../ui/uicases/startup/SplashPresenter.kt | 29 ++++++++----------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/di/PresentationModule.kt b/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/di/PresentationModule.kt index ea9a49c3..bfe5714d 100644 --- a/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/di/PresentationModule.kt +++ b/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/di/PresentationModule.kt @@ -25,6 +25,7 @@ val presentationModule = module { single { SplashPresenter( + get(), get(), get() ) diff --git a/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/ui/uicases/startup/SplashPresenter.kt b/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/ui/uicases/startup/SplashPresenter.kt index f79dd735..034bce6d 100644 --- a/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/ui/uicases/startup/SplashPresenter.kt +++ b/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/ui/uicases/startup/SplashPresenter.kt @@ -1,18 +1,19 @@ package network.bisq.mobile.presentation.ui.uicases.startup -import androidx.navigation.NavController import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade +import network.bisq.mobile.domain.user_profile.UserProfileServiceFacade import network.bisq.mobile.presentation.BasePresenter import network.bisq.mobile.presentation.MainPresenter import network.bisq.mobile.presentation.ui.navigation.Routes open class SplashPresenter( mainPresenter: MainPresenter, - applicationBootstrapFacade: ApplicationBootstrapFacade + applicationBootstrapFacade: ApplicationBootstrapFacade, + private val userProfileService: UserProfileServiceFacade ) : BasePresenter(mainPresenter) { private val coroutineScope = CoroutineScope(Dispatchers.Main) @@ -29,21 +30,15 @@ open class SplashPresenter( } } - private fun navigateToNextScreen() { - // TODO: Conditional nav - // If firstTimeApp launch, goto Onboarding[clientMode] (androidNode / xClient) - // If not, goto TabContainerScreen - /* rootNavigator.navigate(Routes.Onboarding.name) { - popUpTo(Routes.Splash.name) { inclusive = true } - }*/ - - //TODO - /* rootNavigator.navigate(Routes.TabContainer.name) { - popUpTo(Routes.TrustedNodeSetup.name) { inclusive = true } - }*/ - rootNavigator.navigate(Routes.CreateProfile.name) { - popUpTo(Routes.Splash.name) { inclusive = true } + private suspend fun navigateToNextScreen() { + if(userProfileService.hasUserProfile()){ + rootNavigator.navigate(Routes.TabContainer.name) { + popUpTo(Routes.Splash.name) { inclusive = true } + } + }else{ + rootNavigator.navigate(Routes.CreateProfile.name) { + popUpTo(Routes.Splash.name) { inclusive = true } + } } } - }