Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: responding to clicks right after navigating [WPB-5468] #2652

Merged
merged 2 commits into from
Feb 2, 2024
Merged
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 @@ -20,27 +20,39 @@ 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
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<Float> = spring(
stiffness = Spring.StiffnessMediumLow,
visibilityThreshold = Spring.DefaultDisplacementThreshold,
)
private val slideAnimationSpec: FiniteAnimationSpec<IntOffset> = spring(
stiffness = Spring.StiffnessMediumLow,
visibilityThreshold = IntOffset.Companion.VisibilityThreshold,
)

/**
* Animation that allows a smooth transition from rtl, adding a fade in effect
*/
@Suppress("MagicNumber")
@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,
)
}

Expand All @@ -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,
)
}

Expand All @@ -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,
)
}

Expand All @@ -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,
)
}

Expand All @@ -92,7 +104,7 @@ internal fun shrinkOutFromView(): ExitTransition {
@PackagePrivate
internal fun fadeInToView(): EnterTransition {
return fadeIn(
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
animationSpec = fadeAnimationSpec,
)
}

Expand All @@ -102,6 +114,6 @@ internal fun fadeInToView(): EnterTransition {
@PackagePrivate
internal fun fadeOutFromView(): ExitTransition {
return fadeOut(
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
animationSpec = fadeAnimationSpec,
)
}
Loading