PM-27703: Update Authenticator navigation (#6109)

This commit is contained in:
David Perez
2025-11-03 10:28:23 -06:00
committed by GitHub
parent b1195b5f46
commit 845a5dec22
27 changed files with 244 additions and 294 deletions

View File

@@ -0,0 +1,42 @@
package com.bitwarden.ui.platform.base.util
import androidx.navigation.NavController
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.NavOptions
import androidx.navigation.navOptions
import com.bitwarden.ui.platform.components.navigation.model.NavigationItem
import com.bitwarden.ui.platform.util.toObjectNavigationRoute
/**
* A helper function to determine how to navigate to a specified [NavigationItem].
*
* This function intelligently handles navigation based on the current destination:
* - If already at the target start destination, no action is taken.
* - If in the correct graph but not at start, pops back to start destination of the graph.
* - Otherwise, navigates to the target graph with appropriate [NavOptions].
*
* @param target The [NavigationItem] representing the desired navigation target
*/
fun NavController.navigateToTabOrRoot(target: NavigationItem) {
if (target.startDestinationRoute.toObjectNavigationRoute() == currentDestination?.route) {
// We are at the start destination already, so nothing to do.
return
} else if (target.graphRoute.toObjectNavigationRoute() == currentDestination?.parent?.route) {
// We are not at the start destination but we are in the correct graph,
// so lets pop up to the start destination.
popBackStack(route = target.startDestinationRoute, inclusive = false)
return
} else {
// We are not in correct graph at all, so navigate there.
navigate(
route = target.graphRoute,
navOptions = navOptions {
popUpTo(id = graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
},
)
}
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="dialogDimBackgroundAmount">0.75</dimen>
</resources>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="dialogDimBackgroundAmount">0.55</dimen>
</resources>