diff --git a/app/src/main/kotlin/com/wire/android/navigation/style/TransitionAnimations.kt b/app/src/main/kotlin/com/wire/android/navigation/style/TransitionAnimations.kt index fa4b24d37b2..e71e3c3e07c 100644 --- a/app/src/main/kotlin/com/wire/android/navigation/style/TransitionAnimations.kt +++ b/app/src/main/kotlin/com/wire/android/navigation/style/TransitionAnimations.kt @@ -20,7 +20,9 @@ package com.wire.android.navigation.style import androidx.compose.animation.EnterTransition import androidx.compose.animation.ExitTransition +import androidx.compose.animation.core.FiniteAnimationSpec import androidx.compose.animation.core.Spring +import androidx.compose.animation.core.VisibilityThreshold import androidx.compose.animation.core.spring import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut @@ -28,8 +30,18 @@ import androidx.compose.animation.slideInHorizontally import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutHorizontally import androidx.compose.animation.slideOutVertically +import androidx.compose.ui.unit.IntOffset import io.github.esentsov.PackagePrivate +private val fadeAnimationSpec: FiniteAnimationSpec = spring( + stiffness = Spring.StiffnessMediumLow, + visibilityThreshold = Spring.DefaultDisplacementThreshold, +) +private val slideAnimationSpec: FiniteAnimationSpec = spring( + stiffness = Spring.StiffnessMediumLow, + visibilityThreshold = IntOffset.Companion.VisibilityThreshold, +) + /** * Animation that allows a smooth transition from rtl, adding a fade in effect */ @@ -37,10 +49,10 @@ import io.github.esentsov.PackagePrivate @PackagePrivate internal fun smoothSlideInFromRight(): EnterTransition { return slideInHorizontally( - animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + animationSpec = slideAnimationSpec, initialOffsetX = { fullWidth -> fullWidth / 3 }, ) + fadeIn( - animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + animationSpec = fadeAnimationSpec, ) } @@ -51,10 +63,10 @@ internal fun smoothSlideInFromRight(): EnterTransition { @PackagePrivate internal fun smoothSlideOutFromLeft(): ExitTransition { return slideOutHorizontally( - animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + animationSpec = slideAnimationSpec, targetOffsetX = { fullWidth -> fullWidth / 3 }, ) + fadeOut( - animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + animationSpec = fadeAnimationSpec, ) } @@ -65,10 +77,10 @@ internal fun smoothSlideOutFromLeft(): ExitTransition { @PackagePrivate internal fun expandInToView(): EnterTransition { return slideInVertically( - animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + animationSpec = slideAnimationSpec, initialOffsetY = { fullHeight -> fullHeight / 4 }, ) + fadeIn( - animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + animationSpec = fadeAnimationSpec, ) } @@ -79,10 +91,10 @@ internal fun expandInToView(): EnterTransition { @PackagePrivate internal fun shrinkOutFromView(): ExitTransition { return slideOutVertically( - animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + animationSpec = slideAnimationSpec, targetOffsetY = { fullHeight -> fullHeight / 4 }, ) + fadeOut( - animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + animationSpec = fadeAnimationSpec, ) } @@ -92,7 +104,7 @@ internal fun shrinkOutFromView(): ExitTransition { @PackagePrivate internal fun fadeInToView(): EnterTransition { return fadeIn( - animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + animationSpec = fadeAnimationSpec, ) } @@ -102,6 +114,6 @@ internal fun fadeInToView(): EnterTransition { @PackagePrivate internal fun fadeOutFromView(): ExitTransition { return fadeOut( - animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + animationSpec = fadeAnimationSpec, ) }