Skip to content

Commit

Permalink
PM-10242 PM-10243 PM-10244 PM-10245 PM-10246: Welcome carousel (#3657)
Browse files Browse the repository at this point in the history
  • Loading branch information
shannon-livefront authored Aug 7, 2024
1 parent e598fe5 commit f17289a
Show file tree
Hide file tree
Showing 19 changed files with 1,026 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ interface AuthRepository : AuthenticatorProvider, AuthRequestManager {
*/
val organizations: List<SyncResponseJson.Profile.Organization>

/**
* Whether or not the welcome carousel should be displayed, based on the feature flag and
* whether the user has ever logged in or created an account before.
*/
val showWelcomeCarousel: Boolean

/**
* Clears the pending deletion state that occurs when the an account is successfully deleted.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ import com.x8bit.bitwarden.data.auth.repository.util.userSwitchingChangesFlow
import com.x8bit.bitwarden.data.auth.util.KdfParamsConstants.DEFAULT_PBKDF2_ITERATIONS
import com.x8bit.bitwarden.data.auth.util.YubiKeyResult
import com.x8bit.bitwarden.data.auth.util.toSdkParams
import com.x8bit.bitwarden.data.platform.manager.FeatureFlagManager
import com.x8bit.bitwarden.data.platform.manager.PolicyManager
import com.x8bit.bitwarden.data.platform.manager.PushManager
import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager
import com.x8bit.bitwarden.data.platform.manager.model.FlagKey
import com.x8bit.bitwarden.data.platform.manager.util.getActivePolicies
import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository
import com.x8bit.bitwarden.data.platform.repository.SettingsRepository
Expand Down Expand Up @@ -140,6 +142,7 @@ class AuthRepositoryImpl(
private val trustedDeviceManager: TrustedDeviceManager,
private val userLogoutManager: UserLogoutManager,
private val policyManager: PolicyManager,
private val featureFlagManager: FeatureFlagManager,
pushManager: PushManager,
dispatcherManager: DispatcherManager,
) : AuthRepository,
Expand Down Expand Up @@ -318,6 +321,10 @@ class AuthRepositoryImpl(
override val organizations: List<SyncResponseJson.Profile.Organization>
get() = activeUserId?.let { authDiskSource.getOrganizations(it) }.orEmpty()

override val showWelcomeCarousel: Boolean
get() = !settingsRepository.hasUserLoggedInOrCreatedAccount &&
featureFlagManager.getFeatureFlag(FlagKey.OnboardingCarousel)

init {
pushManager
.syncOrgKeysFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.x8bit.bitwarden.data.auth.manager.TrustedDeviceManager
import com.x8bit.bitwarden.data.auth.manager.UserLogoutManager
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
import com.x8bit.bitwarden.data.auth.repository.AuthRepositoryImpl
import com.x8bit.bitwarden.data.platform.manager.FeatureFlagManager
import com.x8bit.bitwarden.data.platform.manager.PolicyManager
import com.x8bit.bitwarden.data.platform.manager.PushManager
import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager
Expand Down Expand Up @@ -52,6 +53,7 @@ object AuthRepositoryModule {
userLogoutManager: UserLogoutManager,
pushManager: PushManager,
policyManager: PolicyManager,
featureFlagManager: FeatureFlagManager,
): AuthRepository = AuthRepositoryImpl(
accountsService = accountsService,
devicesService = devicesService,
Expand All @@ -70,5 +72,6 @@ object AuthRepositoryModule {
userLogoutManager = userLogoutManager,
pushManager = pushManager,
policyManager = policyManager,
featureFlagManager = featureFlagManager,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.x8bit.bitwarden.ui.auth.feature.environment.environmentDestination
import com.x8bit.bitwarden.ui.auth.feature.environment.navigateToEnvironment
import com.x8bit.bitwarden.ui.auth.feature.landing.LANDING_ROUTE
import com.x8bit.bitwarden.ui.auth.feature.landing.landingDestination
import com.x8bit.bitwarden.ui.auth.feature.landing.navigateToLanding
import com.x8bit.bitwarden.ui.auth.feature.login.loginDestination
import com.x8bit.bitwarden.ui.auth.feature.login.navigateToLogin
import com.x8bit.bitwarden.ui.auth.feature.loginwithdevice.loginWithDeviceDestination
Expand All @@ -25,14 +26,17 @@ import com.x8bit.bitwarden.ui.auth.feature.setpassword.navigateToSetPassword
import com.x8bit.bitwarden.ui.auth.feature.setpassword.setPasswordDestination
import com.x8bit.bitwarden.ui.auth.feature.twofactorlogin.navigateToTwoFactorLogin
import com.x8bit.bitwarden.ui.auth.feature.twofactorlogin.twoFactorLoginDestination
import com.x8bit.bitwarden.ui.auth.feature.welcome.welcomeDestination

const val AUTH_GRAPH_ROUTE: String = "auth_graph"

/**
* Add auth destinations to the nav graph.
*/
@Suppress("LongMethod")
fun NavGraphBuilder.authGraph(navController: NavHostController) {
fun NavGraphBuilder.authGraph(
navController: NavHostController,
) {
navigation(
startDestination = LANDING_ROUTE,
route = AUTH_GRAPH_ROUTE,
Expand Down Expand Up @@ -72,6 +76,10 @@ fun NavGraphBuilder.authGraph(navController: NavHostController) {
navController.navigateToEnvironment()
},
)
welcomeDestination(
onNavigateToCreateAccount = { navController.navigateToCreateAccount() },
onNavigateToLogin = { navController.navigateToLanding() },
)
loginDestination(
onNavigateBack = { navController.popBackStack() },
onNavigateToMasterPasswordHint = { emailAddress ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.x8bit.bitwarden.ui.auth.feature.welcome

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import com.x8bit.bitwarden.ui.platform.base.util.composableWithStayTransitions

private const val WELCOME_ROUTE: String = "welcome"

/**
* Navigate to the welcome screen.
*/
fun NavController.navigateToWelcome(navOptions: NavOptions? = null) {
this.navigate(WELCOME_ROUTE, navOptions)
}

/**
* Add the Welcome screen to the nav graph.
*/
fun NavGraphBuilder.welcomeDestination(
onNavigateToCreateAccount: () -> Unit,
onNavigateToLogin: () -> Unit,
) {
composableWithStayTransitions(
route = WELCOME_ROUTE,
) {
WelcomeScreen(
onNavigateToCreateAccount = onNavigateToCreateAccount,
onNavigateToLogin = onNavigateToLogin,
)
}
}
Loading

0 comments on commit f17289a

Please sign in to comment.