Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -92,7 +92,7 @@ fun NavGraphBuilder.generatorDestination(
onNavigateToPasswordHistory: () -> Unit,
onDimNavBarRequest: (Boolean) -> Unit,
) {
composable<GeneratorRoute.Standard> {
composableWithRootPushTransitions<GeneratorRoute.Standard> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed that this screen did not have the right transitions applied.

GeneratorScreen(
onNavigateToPasswordHistory = onNavigateToPasswordHistory,
onNavigateBack = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ inline fun <reified T : Any> NavGraphBuilder.composableWithPushTransitions(
this.composable<T>(
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,
)
Expand All @@ -86,8 +86,8 @@ inline fun <reified T : Any> 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,
Expand Down
62 changes: 32 additions & 30 deletions ui/src/main/kotlin/com/bitwarden/ui/platform/theme/Transition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 }
}

Expand Down Expand Up @@ -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 }
}

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Loading