mirror of
https://github.com/bitwarden/android.git
synced 2025-03-16 19:28:44 +03:00
Add basic push transitions (#182)
This commit is contained in:
parent
b1457bc499
commit
4a3e88f939
8 changed files with 136 additions and 7 deletions
|
@ -17,6 +17,7 @@ import com.x8bit.bitwarden.ui.platform.feature.settings.other.navigateToOther
|
|||
import com.x8bit.bitwarden.ui.platform.feature.settings.other.otherDestination
|
||||
import com.x8bit.bitwarden.ui.platform.feature.settings.vault.navigateToVault
|
||||
import com.x8bit.bitwarden.ui.platform.feature.settings.vault.vaultDestination
|
||||
import com.x8bit.bitwarden.ui.platform.theme.TransitionProviders
|
||||
|
||||
const val SETTINGS_GRAPH_ROUTE: String = "settings_graph"
|
||||
private const val SETTINGS_ROUTE: String = "settings"
|
||||
|
@ -31,7 +32,13 @@ fun NavGraphBuilder.settingsGraph(
|
|||
startDestination = SETTINGS_ROUTE,
|
||||
route = SETTINGS_GRAPH_ROUTE,
|
||||
) {
|
||||
composable(SETTINGS_ROUTE) {
|
||||
composable(
|
||||
route = SETTINGS_ROUTE,
|
||||
enterTransition = TransitionProviders.Enter.stay,
|
||||
exitTransition = TransitionProviders.Exit.pushLeft,
|
||||
popEnterTransition = TransitionProviders.Enter.pushRight,
|
||||
popExitTransition = TransitionProviders.Exit.fadeOut,
|
||||
) {
|
||||
SettingsScreen(
|
||||
onNavigateToAbout = { navController.navigateToAbout() },
|
||||
onNavigateToAccountSecurity = { navController.navigateToAccountSecurity() },
|
||||
|
|
|
@ -4,6 +4,7 @@ import androidx.navigation.NavController
|
|||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.NavOptions
|
||||
import androidx.navigation.compose.composable
|
||||
import com.x8bit.bitwarden.ui.platform.theme.TransitionProviders
|
||||
|
||||
private const val ABOUT_ROUTE = "settings_about"
|
||||
|
||||
|
@ -13,7 +14,13 @@ private const val ABOUT_ROUTE = "settings_about"
|
|||
fun NavGraphBuilder.aboutDestination(
|
||||
onNavigateBack: () -> Unit,
|
||||
) {
|
||||
composable(ABOUT_ROUTE) {
|
||||
composable(
|
||||
route = ABOUT_ROUTE,
|
||||
enterTransition = TransitionProviders.Enter.pushLeft,
|
||||
exitTransition = TransitionProviders.Exit.pushLeft,
|
||||
popEnterTransition = TransitionProviders.Enter.pushLeft,
|
||||
popExitTransition = TransitionProviders.Exit.pushRight,
|
||||
) {
|
||||
AboutScreen(onNavigateBack = onNavigateBack)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import androidx.navigation.NavController
|
|||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.NavOptions
|
||||
import androidx.navigation.compose.composable
|
||||
import com.x8bit.bitwarden.ui.platform.theme.TransitionProviders
|
||||
|
||||
private const val ACCOUNT_SECURITY_ROUTE = "settings_account_security"
|
||||
|
||||
|
@ -13,7 +14,13 @@ private const val ACCOUNT_SECURITY_ROUTE = "settings_account_security"
|
|||
fun NavGraphBuilder.accountSecurityDestination(
|
||||
onNavigateBack: () -> Unit,
|
||||
) {
|
||||
composable(ACCOUNT_SECURITY_ROUTE) {
|
||||
composable(
|
||||
route = ACCOUNT_SECURITY_ROUTE,
|
||||
enterTransition = TransitionProviders.Enter.pushLeft,
|
||||
exitTransition = TransitionProviders.Exit.pushLeft,
|
||||
popEnterTransition = TransitionProviders.Enter.pushLeft,
|
||||
popExitTransition = TransitionProviders.Exit.pushRight,
|
||||
) {
|
||||
AccountSecurityScreen(onNavigateBack = onNavigateBack)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import androidx.navigation.NavController
|
|||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.NavOptions
|
||||
import androidx.navigation.compose.composable
|
||||
import com.x8bit.bitwarden.ui.platform.theme.TransitionProviders
|
||||
|
||||
private const val APPEARANCE_ROUTE = "settings_appearance"
|
||||
|
||||
|
@ -13,7 +14,13 @@ private const val APPEARANCE_ROUTE = "settings_appearance"
|
|||
fun NavGraphBuilder.appearanceDestination(
|
||||
onNavigateBack: () -> Unit,
|
||||
) {
|
||||
composable(APPEARANCE_ROUTE) {
|
||||
composable(
|
||||
route = APPEARANCE_ROUTE,
|
||||
enterTransition = TransitionProviders.Enter.pushLeft,
|
||||
exitTransition = TransitionProviders.Exit.pushLeft,
|
||||
popEnterTransition = TransitionProviders.Enter.pushLeft,
|
||||
popExitTransition = TransitionProviders.Exit.pushRight,
|
||||
) {
|
||||
AppearanceScreen(onNavigateBack = onNavigateBack)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import androidx.navigation.NavController
|
|||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.NavOptions
|
||||
import androidx.navigation.compose.composable
|
||||
import com.x8bit.bitwarden.ui.platform.theme.TransitionProviders
|
||||
|
||||
private const val AUTO_FILL_ROUTE = "settings_auto_fill"
|
||||
|
||||
|
@ -13,7 +14,13 @@ private const val AUTO_FILL_ROUTE = "settings_auto_fill"
|
|||
fun NavGraphBuilder.autoFillDestination(
|
||||
onNavigateBack: () -> Unit,
|
||||
) {
|
||||
composable(AUTO_FILL_ROUTE) {
|
||||
composable(
|
||||
route = AUTO_FILL_ROUTE,
|
||||
enterTransition = TransitionProviders.Enter.pushLeft,
|
||||
exitTransition = TransitionProviders.Exit.pushLeft,
|
||||
popEnterTransition = TransitionProviders.Enter.pushLeft,
|
||||
popExitTransition = TransitionProviders.Exit.pushRight,
|
||||
) {
|
||||
AutoFillScreen(onNavigateBack = onNavigateBack)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import androidx.navigation.NavController
|
|||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.NavOptions
|
||||
import androidx.navigation.compose.composable
|
||||
import com.x8bit.bitwarden.ui.platform.theme.TransitionProviders
|
||||
|
||||
private const val OTHER_ROUTE = "settings_other"
|
||||
|
||||
|
@ -13,7 +14,13 @@ private const val OTHER_ROUTE = "settings_other"
|
|||
fun NavGraphBuilder.otherDestination(
|
||||
onNavigateBack: () -> Unit,
|
||||
) {
|
||||
composable(OTHER_ROUTE) {
|
||||
composable(
|
||||
route = OTHER_ROUTE,
|
||||
enterTransition = TransitionProviders.Enter.pushLeft,
|
||||
exitTransition = TransitionProviders.Exit.pushLeft,
|
||||
popEnterTransition = TransitionProviders.Enter.pushLeft,
|
||||
popExitTransition = TransitionProviders.Exit.pushRight,
|
||||
) {
|
||||
OtherScreen(onNavigateBack = onNavigateBack)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import androidx.navigation.NavController
|
|||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.NavOptions
|
||||
import androidx.navigation.compose.composable
|
||||
import com.x8bit.bitwarden.ui.platform.theme.TransitionProviders
|
||||
|
||||
private const val VAULT_ROUTE = "settings_vault"
|
||||
|
||||
|
@ -13,7 +14,13 @@ private const val VAULT_ROUTE = "settings_vault"
|
|||
fun NavGraphBuilder.vaultDestination(
|
||||
onNavigateBack: () -> Unit,
|
||||
) {
|
||||
composable(VAULT_ROUTE) {
|
||||
composable(
|
||||
route = VAULT_ROUTE,
|
||||
enterTransition = TransitionProviders.Enter.pushLeft,
|
||||
exitTransition = TransitionProviders.Exit.pushLeft,
|
||||
popEnterTransition = TransitionProviders.Enter.pushLeft,
|
||||
popExitTransition = TransitionProviders.Exit.pushRight,
|
||||
) {
|
||||
VaultScreen(onNavigateBack = onNavigateBack)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,26 @@ object TransitionProviders {
|
|||
.takeIf { isSameGraphNavigation }
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the new screen in from the left of the screen.
|
||||
*/
|
||||
val pushLeft: EnterTransitionProvider = {
|
||||
RootTransitionProviders
|
||||
.Enter
|
||||
.pushLeft(this)
|
||||
.takeIf { isSameGraphNavigation }
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the new screen in from the right of the screen.
|
||||
*/
|
||||
val pushRight: EnterTransitionProvider = {
|
||||
RootTransitionProviders
|
||||
.Enter
|
||||
.pushRight(this)
|
||||
.takeIf { isSameGraphNavigation }
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the new screen in from the bottom of the screen.
|
||||
*
|
||||
|
@ -103,6 +123,26 @@ object TransitionProviders {
|
|||
.takeIf { isSameGraphNavigation }
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the current screen out to the left of the screen.
|
||||
*/
|
||||
val pushLeft: ExitTransitionProvider = {
|
||||
RootTransitionProviders
|
||||
.Exit
|
||||
.pushLeft(this)
|
||||
.takeIf { isSameGraphNavigation }
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the current screen out to the right of the screen.
|
||||
*/
|
||||
val pushRight: ExitTransitionProvider = {
|
||||
RootTransitionProviders
|
||||
.Exit
|
||||
.pushRight(this)
|
||||
.takeIf { isSameGraphNavigation }
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the current screen down to the bottom of the screen.
|
||||
*
|
||||
|
@ -149,6 +189,26 @@ object RootTransitionProviders {
|
|||
fadeIn(tween(DEFAULT_TRANSITION_TIME_MS))
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the new screen in from the left of the screen.
|
||||
*/
|
||||
val pushLeft: NonNullEnterTransitionProvider = {
|
||||
slideIntoContainer(
|
||||
towards = AnimatedContentTransitionScope.SlideDirection.Left,
|
||||
animationSpec = tween(DEFAULT_TRANSITION_TIME_MS),
|
||||
) + fadeIn(tween(DEFAULT_TRANSITION_TIME_MS))
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the new screen in from the right of the screen.
|
||||
*/
|
||||
val pushRight: NonNullEnterTransitionProvider = {
|
||||
slideIntoContainer(
|
||||
towards = AnimatedContentTransitionScope.SlideDirection.Right,
|
||||
animationSpec = tween(DEFAULT_TRANSITION_TIME_MS),
|
||||
) + fadeIn(tween(DEFAULT_TRANSITION_TIME_MS))
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the new screen in from the bottom of the screen.
|
||||
*/
|
||||
|
@ -183,6 +243,26 @@ object RootTransitionProviders {
|
|||
fadeOut(tween(DEFAULT_TRANSITION_TIME_MS))
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the current screen out to the left of the screen.
|
||||
*/
|
||||
val pushLeft: NonNullExitTransitionProvider = {
|
||||
slideOutOfContainer(
|
||||
towards = AnimatedContentTransitionScope.SlideDirection.Left,
|
||||
animationSpec = tween(DEFAULT_TRANSITION_TIME_MS),
|
||||
) + fadeOut(tween(DEFAULT_TRANSITION_TIME_MS))
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the current screen out to the right of the screen.
|
||||
*/
|
||||
val pushRight: NonNullExitTransitionProvider = {
|
||||
slideOutOfContainer(
|
||||
towards = AnimatedContentTransitionScope.SlideDirection.Right,
|
||||
animationSpec = tween(DEFAULT_TRANSITION_TIME_MS),
|
||||
) + fadeOut(tween(DEFAULT_TRANSITION_TIME_MS))
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides the current screen down to the bottom of the screen.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue