Skip to content

Commit dcc8cc3

Browse files
Update navigation animation to match design
1 parent 4b361db commit dcc8cc3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/bookings/filter/BookingFilterListScreen.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package com.woocommerce.android.ui.bookings.filter
22

33
import androidx.activity.compose.BackHandler
4+
import androidx.compose.animation.EnterTransition
5+
import androidx.compose.animation.ExitTransition
6+
import androidx.compose.animation.core.tween
7+
import androidx.compose.animation.fadeIn
8+
import androidx.compose.animation.fadeOut
9+
import androidx.compose.animation.slideInHorizontally
10+
import androidx.compose.animation.slideOutHorizontally
411
import androidx.compose.foundation.background
512
import androidx.compose.foundation.layout.Column
613
import androidx.compose.foundation.layout.fillMaxSize
@@ -92,6 +99,10 @@ private fun FiltersNavHost(
9299
NavHost(
93100
navController = navController,
94101
startDestination = BookingFilterPage.List.route,
102+
enterTransition = { slideIn(popNavigation = true) },
103+
exitTransition = { slideOut(popNavigation = true) },
104+
popEnterTransition = { slideIn(popNavigation = false) },
105+
popExitTransition = { slideOut(popNavigation = false) },
95106
modifier = modifier
96107
) {
97108
composable(BookingFilterPage.List.route) {
@@ -127,6 +138,20 @@ private fun FiltersNavHost(
127138
private val BookingFilterPage.route: String
128139
get() = this::class.java.simpleName
129140

141+
private fun slideIn(popNavigation: Boolean): EnterTransition {
142+
return slideInHorizontally(animationSpec = tween(durationMillis = TRANSITION_DURATION)) { fullWidth ->
143+
if (popNavigation) fullWidth else -fullWidth
144+
} + fadeIn(animationSpec = tween(durationMillis = TRANSITION_DURATION))
145+
}
146+
147+
private fun slideOut(popNavigation: Boolean): ExitTransition {
148+
return slideOutHorizontally(animationSpec = tween(durationMillis = TRANSITION_DURATION)) { fullWidth ->
149+
if (popNavigation) -fullWidth else fullWidth
150+
} + fadeOut(animationSpec = tween(durationMillis = TRANSITION_DURATION))
151+
}
152+
153+
private const val TRANSITION_DURATION = 250
154+
130155
@LightDarkThemePreviews
131156
@Composable
132157
private fun BookingFilterListScreenPreview() {

0 commit comments

Comments
 (0)