|
1 | 1 | package com.woocommerce.android.ui.bookings.filter |
2 | 2 |
|
3 | 3 | 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 |
4 | 11 | import androidx.compose.foundation.background |
5 | 12 | import androidx.compose.foundation.layout.Column |
6 | 13 | import androidx.compose.foundation.layout.fillMaxSize |
@@ -92,6 +99,10 @@ private fun FiltersNavHost( |
92 | 99 | NavHost( |
93 | 100 | navController = navController, |
94 | 101 | startDestination = BookingFilterPage.List.route, |
| 102 | + enterTransition = { slideIn(true) }, |
| 103 | + exitTransition = { slideOut(true) }, |
| 104 | + popEnterTransition = { slideIn(false) }, |
| 105 | + popExitTransition = { slideOut(false) }, |
95 | 106 | modifier = modifier |
96 | 107 | ) { |
97 | 108 | composable(BookingFilterPage.List.route) { |
@@ -127,6 +138,23 @@ private fun FiltersNavHost( |
127 | 138 | private val BookingFilterPage.route: String |
128 | 139 | get() = this::class.java.simpleName |
129 | 140 |
|
| 141 | + |
| 142 | +private fun slideIn(popNavigation: Boolean): EnterTransition { |
| 143 | + return slideInHorizontally(animationSpec = tween(durationMillis = TRANSITION_DURATION)) { fullWidth -> |
| 144 | + if (popNavigation) fullWidth else -fullWidth |
| 145 | + } + fadeIn(animationSpec = tween(durationMillis = TRANSITION_DURATION)) |
| 146 | + |
| 147 | +} |
| 148 | + |
| 149 | +private fun slideOut(popNavigation: Boolean): ExitTransition { |
| 150 | + return slideOutHorizontally(animationSpec = tween(durationMillis = TRANSITION_DURATION)) { fullWidth -> |
| 151 | + if (popNavigation) -fullWidth else fullWidth |
| 152 | + } + fadeOut(animationSpec = tween(durationMillis = TRANSITION_DURATION)) |
| 153 | +} |
| 154 | + |
| 155 | +private const val TRANSITION_DURATION = 250 |
| 156 | + |
| 157 | + |
130 | 158 | @LightDarkThemePreviews |
131 | 159 | @Composable |
132 | 160 | private fun BookingFilterListScreenPreview() { |
|
0 commit comments