diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorNavigation.kt b/app/src/main/kotlin/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorNavigation.kt index a1ee6077de..6564a93633 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorNavigation.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorNavigation.kt @@ -5,8 +5,8 @@ import androidx.lifecycle.SavedStateHandle import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import androidx.navigation.NavOptions -import androidx.navigation.compose.composable import androidx.navigation.toRoute +import com.bitwarden.ui.platform.base.util.composableWithRootPushTransitions import com.bitwarden.ui.platform.base.util.composableWithSlideTransitions import com.bitwarden.ui.platform.util.ParcelableRouteSerializer import com.x8bit.bitwarden.ui.tools.feature.generator.model.GeneratorMode @@ -92,7 +92,7 @@ fun NavGraphBuilder.generatorDestination( onNavigateToPasswordHistory: () -> Unit, onDimNavBarRequest: (Boolean) -> Unit, ) { - composable { + composableWithRootPushTransitions { GeneratorScreen( onNavigateToPasswordHistory = onNavigateToPasswordHistory, onNavigateBack = {}, diff --git a/ui/src/main/kotlin/com/bitwarden/ui/platform/base/util/NavGraphBuilderExtensions.kt b/ui/src/main/kotlin/com/bitwarden/ui/platform/base/util/NavGraphBuilderExtensions.kt index 286a617cae..5fc9ae5f35 100644 --- a/ui/src/main/kotlin/com/bitwarden/ui/platform/base/util/NavGraphBuilderExtensions.kt +++ b/ui/src/main/kotlin/com/bitwarden/ui/platform/base/util/NavGraphBuilderExtensions.kt @@ -64,10 +64,10 @@ inline fun NavGraphBuilder.composableWithPushTransitions( this.composable( typeMap = typeMap, deepLinks = deepLinks, - enterTransition = TransitionProviders.Enter.pushLeft, + enterTransition = TransitionProviders.Enter.pushToStart, exitTransition = TransitionProviders.Exit.stay, popEnterTransition = TransitionProviders.Enter.stay, - popExitTransition = TransitionProviders.Exit.pushRight, + popExitTransition = TransitionProviders.Exit.pushToEnd, sizeTransform = null, content = content, ) @@ -86,8 +86,8 @@ inline fun NavGraphBuilder.composableWithRootPushTransitions( typeMap = typeMap, deepLinks = deepLinks, enterTransition = TransitionProviders.Enter.stay, - exitTransition = TransitionProviders.Exit.pushLeft, - popEnterTransition = TransitionProviders.Enter.pushRight, + exitTransition = TransitionProviders.Exit.pushToStart, + popEnterTransition = TransitionProviders.Enter.pushToEnd, popExitTransition = TransitionProviders.Exit.fadeOut, sizeTransform = null, content = content, diff --git a/ui/src/main/kotlin/com/bitwarden/ui/platform/theme/Transition.kt b/ui/src/main/kotlin/com/bitwarden/ui/platform/theme/Transition.kt index 4e472702d6..d74863e124 100644 --- a/ui/src/main/kotlin/com/bitwarden/ui/platform/theme/Transition.kt +++ b/ui/src/main/kotlin/com/bitwarden/ui/platform/theme/Transition.kt @@ -6,8 +6,6 @@ import androidx.compose.animation.ExitTransition import androidx.compose.animation.core.tween import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut -import androidx.compose.animation.slideInHorizontally -import androidx.compose.animation.slideOutHorizontally import androidx.navigation.NavBackStackEntry import androidx.navigation.compose.NavHost @@ -87,22 +85,22 @@ object TransitionProviders { } /** - * Slides the new screen in from the left of the screen. + * Slides the new screen in from the start (left) of the screen towards the end (right). */ - val pushLeft: EnterTransitionProvider = { + val pushToEnd: EnterTransitionProvider = { RootTransitionProviders .Enter - .pushLeft(this) + .pushToEnd(this) .takeIf { isSameGraphNavigation } } /** - * Slides the new screen in from the right of the screen. + * Slides the new screen in from the end (right) of the screen towards the start (left). */ - val pushRight: EnterTransitionProvider = { + val pushToStart: EnterTransitionProvider = { RootTransitionProviders .Enter - .pushRight(this) + .pushToStart(this) .takeIf { isSameGraphNavigation } } @@ -153,22 +151,22 @@ object TransitionProviders { } /** - * Slides the current screen out to the left of the screen. + * Slides the current screen out to the start (left) of the screen towards the end (right). */ - val pushLeft: ExitTransitionProvider = { + val pushToStart: ExitTransitionProvider = { RootTransitionProviders .Exit - .pushLeft(this) + .pushToStart(this) .takeIf { isSameGraphNavigation } } /** - * Slides the current screen out to the right of the screen. + * Slides the current screen out to the end (right) of the screen towards the start (left). */ - val pushRight: ExitTransitionProvider = { + val pushToEnd: ExitTransitionProvider = { RootTransitionProviders .Exit - .pushRight(this) + .pushToEnd(this) .takeIf { isSameGraphNavigation } } @@ -226,13 +224,14 @@ object RootTransitionProviders { } /** - * Slides the new screen in from the left of the screen. + * Slides the new screen in from the start (left) of the screen towards the end (right). */ - val pushLeft: NonNullEnterTransitionProvider = { + val pushToEnd: NonNullEnterTransitionProvider = { val totalTransitionDurationMs = DEFAULT_PUSH_TRANSITION_TIME_MS - slideInHorizontally( + slideIntoContainer( + towards = AnimatedContentTransitionScope.SlideDirection.End, animationSpec = tween(durationMillis = totalTransitionDurationMs), - initialOffsetX = { fullWidth -> fullWidth / 2 }, + initialOffset = { fullWidth -> fullWidth / 2 }, ) + fadeIn( animationSpec = tween( durationMillis = totalTransitionDurationMs / 2, @@ -242,13 +241,14 @@ object RootTransitionProviders { } /** - * Slides the new screen in from the right of the screen. + * Slides the new screen in from the end (right) of the screen towards the start (left). */ - val pushRight: NonNullEnterTransitionProvider = { + val pushToStart: NonNullEnterTransitionProvider = { val totalTransitionDurationMs = DEFAULT_PUSH_TRANSITION_TIME_MS - slideInHorizontally( + slideIntoContainer( + towards = AnimatedContentTransitionScope.SlideDirection.Start, animationSpec = tween(durationMillis = totalTransitionDurationMs), - initialOffsetX = { fullWidth -> -fullWidth / 2 }, + initialOffset = { fullWidth -> fullWidth / 2 }, ) + fadeIn( animationSpec = tween( durationMillis = totalTransitionDurationMs / 2, @@ -303,19 +303,20 @@ object RootTransitionProviders { } /** - * Slides the current screen out to the left of the screen. + * Slides the current screen out to the start (left) of the screen towards the end (right). */ @Suppress("MagicNumber") - val pushLeft: NonNullExitTransitionProvider = { + val pushToStart: NonNullExitTransitionProvider = { val totalTransitionDurationMs = DEFAULT_PUSH_TRANSITION_TIME_MS val delayMs = totalTransitionDurationMs / 7 val slideWithoutDelayMs = totalTransitionDurationMs - delayMs - slideOutHorizontally( + slideOutOfContainer( + towards = AnimatedContentTransitionScope.SlideDirection.Start, animationSpec = tween( durationMillis = slideWithoutDelayMs, delayMillis = delayMs, ), - targetOffsetX = { fullWidth -> -fullWidth / 2 }, + targetOffset = { fullWidth -> fullWidth / 2 }, ) + fadeOut( animationSpec = tween( durationMillis = totalTransitionDurationMs / 2, @@ -325,19 +326,20 @@ object RootTransitionProviders { } /** - * Slides the current screen out to the right of the screen. + * Slides the current screen out to the end (right) of the screen towards the start (left). */ @Suppress("MagicNumber") - val pushRight: NonNullExitTransitionProvider = { + val pushToEnd: NonNullExitTransitionProvider = { val totalTransitionDurationMs = DEFAULT_PUSH_TRANSITION_TIME_MS val delayMs = totalTransitionDurationMs / 7 val slideWithoutDelayMs = totalTransitionDurationMs - delayMs - slideOutHorizontally( + slideOutOfContainer( + towards = AnimatedContentTransitionScope.SlideDirection.End, animationSpec = tween( durationMillis = slideWithoutDelayMs, delayMillis = delayMs, ), - targetOffsetX = { fullWidth -> fullWidth / 2 }, + targetOffset = { fullWidth -> fullWidth / 2 }, ) + fadeOut( animationSpec = tween( durationMillis = totalTransitionDurationMs / 2,