mirror of
https://github.com/bitwarden/android.git
synced 2025-12-10 09:56:45 -06:00
Update RTL transitions to go the correct direction (#6166)
This commit is contained in:
parent
7a40bfe522
commit
55c7ab4cee
@ -5,8 +5,8 @@ import androidx.lifecycle.SavedStateHandle
|
|||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.NavGraphBuilder
|
import androidx.navigation.NavGraphBuilder
|
||||||
import androidx.navigation.NavOptions
|
import androidx.navigation.NavOptions
|
||||||
import androidx.navigation.compose.composable
|
|
||||||
import androidx.navigation.toRoute
|
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.base.util.composableWithSlideTransitions
|
||||||
import com.bitwarden.ui.platform.util.ParcelableRouteSerializer
|
import com.bitwarden.ui.platform.util.ParcelableRouteSerializer
|
||||||
import com.x8bit.bitwarden.ui.tools.feature.generator.model.GeneratorMode
|
import com.x8bit.bitwarden.ui.tools.feature.generator.model.GeneratorMode
|
||||||
@ -92,7 +92,7 @@ fun NavGraphBuilder.generatorDestination(
|
|||||||
onNavigateToPasswordHistory: () -> Unit,
|
onNavigateToPasswordHistory: () -> Unit,
|
||||||
onDimNavBarRequest: (Boolean) -> Unit,
|
onDimNavBarRequest: (Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
composable<GeneratorRoute.Standard> {
|
composableWithRootPushTransitions<GeneratorRoute.Standard> {
|
||||||
GeneratorScreen(
|
GeneratorScreen(
|
||||||
onNavigateToPasswordHistory = onNavigateToPasswordHistory,
|
onNavigateToPasswordHistory = onNavigateToPasswordHistory,
|
||||||
onNavigateBack = {},
|
onNavigateBack = {},
|
||||||
|
|||||||
@ -64,10 +64,10 @@ inline fun <reified T : Any> NavGraphBuilder.composableWithPushTransitions(
|
|||||||
this.composable<T>(
|
this.composable<T>(
|
||||||
typeMap = typeMap,
|
typeMap = typeMap,
|
||||||
deepLinks = deepLinks,
|
deepLinks = deepLinks,
|
||||||
enterTransition = TransitionProviders.Enter.pushLeft,
|
enterTransition = TransitionProviders.Enter.pushToStart,
|
||||||
exitTransition = TransitionProviders.Exit.stay,
|
exitTransition = TransitionProviders.Exit.stay,
|
||||||
popEnterTransition = TransitionProviders.Enter.stay,
|
popEnterTransition = TransitionProviders.Enter.stay,
|
||||||
popExitTransition = TransitionProviders.Exit.pushRight,
|
popExitTransition = TransitionProviders.Exit.pushToEnd,
|
||||||
sizeTransform = null,
|
sizeTransform = null,
|
||||||
content = content,
|
content = content,
|
||||||
)
|
)
|
||||||
@ -86,8 +86,8 @@ inline fun <reified T : Any> NavGraphBuilder.composableWithRootPushTransitions(
|
|||||||
typeMap = typeMap,
|
typeMap = typeMap,
|
||||||
deepLinks = deepLinks,
|
deepLinks = deepLinks,
|
||||||
enterTransition = TransitionProviders.Enter.stay,
|
enterTransition = TransitionProviders.Enter.stay,
|
||||||
exitTransition = TransitionProviders.Exit.pushLeft,
|
exitTransition = TransitionProviders.Exit.pushToStart,
|
||||||
popEnterTransition = TransitionProviders.Enter.pushRight,
|
popEnterTransition = TransitionProviders.Enter.pushToEnd,
|
||||||
popExitTransition = TransitionProviders.Exit.fadeOut,
|
popExitTransition = TransitionProviders.Exit.fadeOut,
|
||||||
sizeTransform = null,
|
sizeTransform = null,
|
||||||
content = content,
|
content = content,
|
||||||
|
|||||||
@ -6,8 +6,6 @@ import androidx.compose.animation.ExitTransition
|
|||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.animation.slideInHorizontally
|
|
||||||
import androidx.compose.animation.slideOutHorizontally
|
|
||||||
import androidx.navigation.NavBackStackEntry
|
import androidx.navigation.NavBackStackEntry
|
||||||
import androidx.navigation.compose.NavHost
|
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
|
RootTransitionProviders
|
||||||
.Enter
|
.Enter
|
||||||
.pushLeft(this)
|
.pushToEnd(this)
|
||||||
.takeIf { isSameGraphNavigation }
|
.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
|
RootTransitionProviders
|
||||||
.Enter
|
.Enter
|
||||||
.pushRight(this)
|
.pushToStart(this)
|
||||||
.takeIf { isSameGraphNavigation }
|
.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
|
RootTransitionProviders
|
||||||
.Exit
|
.Exit
|
||||||
.pushLeft(this)
|
.pushToStart(this)
|
||||||
.takeIf { isSameGraphNavigation }
|
.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
|
RootTransitionProviders
|
||||||
.Exit
|
.Exit
|
||||||
.pushRight(this)
|
.pushToEnd(this)
|
||||||
.takeIf { isSameGraphNavigation }
|
.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
|
val totalTransitionDurationMs = DEFAULT_PUSH_TRANSITION_TIME_MS
|
||||||
slideInHorizontally(
|
slideIntoContainer(
|
||||||
|
towards = AnimatedContentTransitionScope.SlideDirection.End,
|
||||||
animationSpec = tween(durationMillis = totalTransitionDurationMs),
|
animationSpec = tween(durationMillis = totalTransitionDurationMs),
|
||||||
initialOffsetX = { fullWidth -> fullWidth / 2 },
|
initialOffset = { fullWidth -> fullWidth / 2 },
|
||||||
) + fadeIn(
|
) + fadeIn(
|
||||||
animationSpec = tween(
|
animationSpec = tween(
|
||||||
durationMillis = totalTransitionDurationMs / 2,
|
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
|
val totalTransitionDurationMs = DEFAULT_PUSH_TRANSITION_TIME_MS
|
||||||
slideInHorizontally(
|
slideIntoContainer(
|
||||||
|
towards = AnimatedContentTransitionScope.SlideDirection.Start,
|
||||||
animationSpec = tween(durationMillis = totalTransitionDurationMs),
|
animationSpec = tween(durationMillis = totalTransitionDurationMs),
|
||||||
initialOffsetX = { fullWidth -> -fullWidth / 2 },
|
initialOffset = { fullWidth -> fullWidth / 2 },
|
||||||
) + fadeIn(
|
) + fadeIn(
|
||||||
animationSpec = tween(
|
animationSpec = tween(
|
||||||
durationMillis = totalTransitionDurationMs / 2,
|
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")
|
@Suppress("MagicNumber")
|
||||||
val pushLeft: NonNullExitTransitionProvider = {
|
val pushToStart: NonNullExitTransitionProvider = {
|
||||||
val totalTransitionDurationMs = DEFAULT_PUSH_TRANSITION_TIME_MS
|
val totalTransitionDurationMs = DEFAULT_PUSH_TRANSITION_TIME_MS
|
||||||
val delayMs = totalTransitionDurationMs / 7
|
val delayMs = totalTransitionDurationMs / 7
|
||||||
val slideWithoutDelayMs = totalTransitionDurationMs - delayMs
|
val slideWithoutDelayMs = totalTransitionDurationMs - delayMs
|
||||||
slideOutHorizontally(
|
slideOutOfContainer(
|
||||||
|
towards = AnimatedContentTransitionScope.SlideDirection.Start,
|
||||||
animationSpec = tween(
|
animationSpec = tween(
|
||||||
durationMillis = slideWithoutDelayMs,
|
durationMillis = slideWithoutDelayMs,
|
||||||
delayMillis = delayMs,
|
delayMillis = delayMs,
|
||||||
),
|
),
|
||||||
targetOffsetX = { fullWidth -> -fullWidth / 2 },
|
targetOffset = { fullWidth -> fullWidth / 2 },
|
||||||
) + fadeOut(
|
) + fadeOut(
|
||||||
animationSpec = tween(
|
animationSpec = tween(
|
||||||
durationMillis = totalTransitionDurationMs / 2,
|
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")
|
@Suppress("MagicNumber")
|
||||||
val pushRight: NonNullExitTransitionProvider = {
|
val pushToEnd: NonNullExitTransitionProvider = {
|
||||||
val totalTransitionDurationMs = DEFAULT_PUSH_TRANSITION_TIME_MS
|
val totalTransitionDurationMs = DEFAULT_PUSH_TRANSITION_TIME_MS
|
||||||
val delayMs = totalTransitionDurationMs / 7
|
val delayMs = totalTransitionDurationMs / 7
|
||||||
val slideWithoutDelayMs = totalTransitionDurationMs - delayMs
|
val slideWithoutDelayMs = totalTransitionDurationMs - delayMs
|
||||||
slideOutHorizontally(
|
slideOutOfContainer(
|
||||||
|
towards = AnimatedContentTransitionScope.SlideDirection.End,
|
||||||
animationSpec = tween(
|
animationSpec = tween(
|
||||||
durationMillis = slideWithoutDelayMs,
|
durationMillis = slideWithoutDelayMs,
|
||||||
delayMillis = delayMs,
|
delayMillis = delayMs,
|
||||||
),
|
),
|
||||||
targetOffsetX = { fullWidth -> fullWidth / 2 },
|
targetOffset = { fullWidth -> fullWidth / 2 },
|
||||||
) + fadeOut(
|
) + fadeOut(
|
||||||
animationSpec = tween(
|
animationSpec = tween(
|
||||||
durationMillis = totalTransitionDurationMs / 2,
|
durationMillis = totalTransitionDurationMs / 2,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user