Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contrib on onboarding navigation #118

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 @@ -54,6 +54,7 @@ val androidNodeModule = module {
get(),
get(),
get(),
get(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package network.bisq.mobile.android.node.presentation

import network.bisq.mobile.domain.data.model.Settings
import network.bisq.mobile.domain.data.repository.SettingsRepository
import network.bisq.mobile.domain.data.repository.UserRepository
import network.bisq.mobile.domain.service.bootstrap.ApplicationBootstrapFacade
import network.bisq.mobile.domain.service.user_profile.UserProfileServiceFacade
import network.bisq.mobile.presentation.MainPresenter
Expand All @@ -11,8 +12,9 @@ class NodeSplashPresenter(
mainPresenter: MainPresenter,
applicationBootstrapFacade: ApplicationBootstrapFacade,
private val userProfileService: UserProfileServiceFacade,
private val userRepository: UserRepository,
private val settingsRepository: SettingsRepository
) : SplashPresenter(mainPresenter, applicationBootstrapFacade, userProfileService, settingsRepository) {
) : SplashPresenter(mainPresenter, applicationBootstrapFacade, userProfileService, userRepository, settingsRepository) {

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ val presentationModule = module {
get(),
get(),
get(),
get()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import network.bisq.mobile.domain.data.model.Settings
import network.bisq.mobile.domain.data.model.User
import network.bisq.mobile.domain.data.repository.SettingsRepository
import network.bisq.mobile.domain.data.repository.UserRepository
import network.bisq.mobile.domain.service.bootstrap.ApplicationBootstrapFacade
import network.bisq.mobile.domain.service.user_profile.UserProfileServiceFacade
import network.bisq.mobile.presentation.BasePresenter
Expand All @@ -17,7 +19,8 @@ open class SplashPresenter(
mainPresenter: MainPresenter,
applicationBootstrapFacade: ApplicationBootstrapFacade,
private val userProfileService: UserProfileServiceFacade,
private val settingsRepository: SettingsRepository
private val userRepository: UserRepository,
private val settingsRepository: SettingsRepository,
) : BasePresenter(mainPresenter) {

val state: StateFlow<String> = applicationBootstrapFacade.state
Expand All @@ -41,14 +44,11 @@ open class SplashPresenter(

private fun navigateToNextScreen() {
CoroutineScope(Dispatchers.Main).launch {
val settings: Settings = settingsRepository.fetch() ?: Settings()
val user: User? = userRepository.fetch()

settingsRepository.fetch()
val settings: Settings? = settingsRepository.data.value

if (settings == null) {
if (!doCustomNavigationLogic(Settings())) {
navigateToHome()
}
if (user == null) {
navigateToCreateProfile()
} else {
if (userProfileService.hasUserProfile()) {
if (!doCustomNavigationLogic(settings)) {
Expand All @@ -58,6 +58,7 @@ open class SplashPresenter(
// If firstTimeApp launch, goto Onboarding[clientMode] (androidNode / xClient)
// If not, goto CreateProfile
if (settings.firstLaunch) {
// TODO after onboarding need to make sure the rest is configured?
rootNavigator.navigate(Routes.Onboarding.name) {
popUpTo(Routes.Splash.name) { inclusive = true }
}
Expand All @@ -71,22 +72,31 @@ open class SplashPresenter(
}
}

private fun navigateToCreateProfile() {
rootNavigator.navigate(Routes.CreateProfile.name) {
popUpTo(Routes.Splash.name) { inclusive = true }
}
}

private fun navigateToHome() {
rootNavigator.navigate(Routes.TabContainer.name) {
popUpTo(Routes.Splash.name) { inclusive = true }
}
}

/**
* Default implementation in shared is for xClients. Override on node to avoid this.
* @return true if handled, false otherwise
*/
open fun doCustomNavigationLogic(settings: Settings): Boolean {
if (settings.bisqApiUrl.isNotEmpty()) {
navigateToHome()
} else {
rootNavigator.navigate(Routes.TrustedNodeSetup.name) {
popUpTo(Routes.Splash.name) { inclusive = true }
when {
settings.bisqApiUrl.isEmpty() -> {
rootNavigator.navigate(Routes.TrustedNodeSetup.name) {
popUpTo(Routes.Splash.name) { inclusive = true }
}
}
// settings.firstLaunch -> navigateToCreateProfile()
else -> navigateToHome()
}
return true
}
Expand Down
Loading