Skip to content

Commit

Permalink
[FEAT]#134: SlideIn Animation 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
flash159483 committed Aug 24, 2024
1 parent 9818575 commit 399211a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/src/main/kotlin/com/bff/wespot/AppNavGraphs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.bff.wespot
import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -159,6 +161,7 @@ internal fun NavDestination.checkDestination(position: NavigationBarPosition): B
}
if (result) BarType.DEFAULT else BarType.NONE
}

NavigationBarPosition.TOP -> {
hierarchy.forEach { destination ->
when (destination.route) {
Expand Down Expand Up @@ -224,6 +227,19 @@ private fun AnimatedContentTransitionScope<*>.defaultEnterTransition(
if (initialNavGraph.id != targetNavGraph.id) {
return fadeIn()
}

if (target.destination.hierarchy.any { it.route == "vote/voting_screen" } &&
initial.destination.hierarchy.any { it.route == "vote/voting_screen" }) {
return slideIntoContainer(
AnimatedContentTransitionScope.SlideDirection.Start,
animationSpec = spring(
stiffness = Spring.StiffnessMediumLow,
),
initialOffset = {
it / 3
},
)
}
return fadeIn()
}

Expand All @@ -236,6 +252,15 @@ private fun AnimatedContentTransitionScope<*>.defaultExitTransition(
if (initialNavGraph.id != targetNavGraph.id) {
return fadeOut()
}
if (target.destination.hierarchy.any { it.route == "vote/voting_screen" }) {
return slideOutOfContainer(
AnimatedContentTransitionScope.SlideDirection.End,
animationSpec = spring(
stiffness = Spring.StiffnessMediumLow,
),
)
}

return fadeOut()
}

Expand Down

0 comments on commit 399211a

Please sign in to comment.