-
Notifications
You must be signed in to change notification settings - Fork 849
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PM-13067 Navigate to setup unlock screen from action card in security…
… settings (#4023)
- Loading branch information
1 parent
83652c9
commit 8ae6433
Showing
14 changed files
with
299 additions
and
76 deletions.
There are no files selected for viewing
73 changes: 66 additions & 7 deletions
73
app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/accountsetup/SetupUnlockNavigation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,88 @@ | ||
package com.x8bit.bitwarden.ui.auth.feature.accountsetup | ||
|
||
import androidx.lifecycle.SavedStateHandle | ||
import androidx.navigation.NavController | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.NavOptions | ||
import androidx.navigation.NavType | ||
import androidx.navigation.navArgument | ||
import com.x8bit.bitwarden.data.platform.annotation.OmitFromCoverage | ||
import com.x8bit.bitwarden.ui.platform.base.util.composableWithPushTransitions | ||
import com.x8bit.bitwarden.ui.platform.base.util.composableWithSlideTransitions | ||
|
||
/** | ||
* Route for [SetupUnlockScreen] | ||
* Route constants for [SetupUnlockScreen] | ||
*/ | ||
const val SETUP_UNLOCK_ROUTE = "setup_unlock" | ||
private const val SETUP_UNLOCK_PREFIX = "setup_unlock" | ||
private const val SETUP_UNLOCK_AS_ROOT_PREFIX = "${SETUP_UNLOCK_PREFIX}_as_root" | ||
private const val SETUP_UNLOCK_INITIAL_SETUP_ARG = "isInitialSetup" | ||
const val SETUP_UNLOCK_AS_ROOT_ROUTE = "$SETUP_UNLOCK_AS_ROOT_PREFIX/" + | ||
"{$SETUP_UNLOCK_INITIAL_SETUP_ARG}" | ||
private const val SETUP_UNLOCK_ROUTE = "$SETUP_UNLOCK_PREFIX/{$SETUP_UNLOCK_INITIAL_SETUP_ARG}" | ||
|
||
/** | ||
* Class to retrieve setup unlock arguments from the [SavedStateHandle]. | ||
*/ | ||
@OmitFromCoverage | ||
data class SetupUnlockArgs( | ||
val isInitialSetup: Boolean, | ||
) { | ||
constructor(savedStateHandle: SavedStateHandle) : this( | ||
isInitialSetup = requireNotNull(savedStateHandle[SETUP_UNLOCK_INITIAL_SETUP_ARG]), | ||
) | ||
} | ||
|
||
/** | ||
* Navigate to the setup unlock screen. | ||
*/ | ||
fun NavController.navigateToSetupUnlockScreen(navOptions: NavOptions? = null) { | ||
this.navigate(SETUP_UNLOCK_ROUTE, navOptions) | ||
this.navigate("$SETUP_UNLOCK_PREFIX/false", navOptions) | ||
} | ||
|
||
/** | ||
* Add the setup unlock screen to the nav graph. | ||
* Navigate to the setup unlock screen as root. | ||
*/ | ||
fun NavGraphBuilder.setupUnlockDestination() { | ||
composableWithPushTransitions( | ||
fun NavController.navigateToSetupUnlockScreenAsRoot(navOptions: NavOptions? = null) { | ||
this.navigate("$SETUP_UNLOCK_AS_ROOT_PREFIX/true", navOptions) | ||
} | ||
|
||
/** | ||
* Add the setup unlock screen to a nav graph. | ||
*/ | ||
fun NavGraphBuilder.setupUnlockDestination( | ||
onNavigateBack: () -> Unit, | ||
) { | ||
composableWithSlideTransitions( | ||
route = SETUP_UNLOCK_ROUTE, | ||
arguments = setupUnlockArguments, | ||
) { | ||
SetupUnlockScreen() | ||
SetupUnlockScreen( | ||
onNavigateBack = onNavigateBack, | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* Add the setup unlock screen to the root nav graph. | ||
*/ | ||
fun NavGraphBuilder.setupUnlockDestinationAsRoot() { | ||
composableWithPushTransitions( | ||
route = SETUP_UNLOCK_AS_ROOT_ROUTE, | ||
arguments = setupUnlockArguments, | ||
) { | ||
SetupUnlockScreen( | ||
onNavigateBack = { | ||
// No-Op | ||
}, | ||
) | ||
} | ||
} | ||
|
||
private val setupUnlockArguments = listOf( | ||
navArgument( | ||
name = SETUP_UNLOCK_INITIAL_SETUP_ARG, | ||
builder = { | ||
type = NavType.BoolType | ||
}, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.