diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt index 521fbfac2..eade0d0b7 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt @@ -28,6 +28,8 @@ import kotlin.reflect.KClass */ @Serializable sealed class MainNavigation : NavigationDestination() { + var enableTransition = true + @Serializable data object SentDestination : MainNavigation() @Serializable diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt index 61604bfa7..1313e6d2f 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt @@ -18,6 +18,10 @@ package com.infomaniak.swisstransfer.ui.screen.main +import androidx.compose.animation.EnterTransition +import androidx.compose.animation.ExitTransition +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut import androidx.compose.foundation.layout.safeDrawingPadding import androidx.compose.material3.adaptive.WindowAdaptiveInfo import androidx.compose.runtime.Composable @@ -37,8 +41,15 @@ import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.TransferDetai fun MainNavHost( navController: NavHostController, windowAdaptiveInfo: WindowAdaptiveInfo, + currentDestination: MainNavigation, ) { - NavHost(navController, MainNavigation.startDestination, modifier = Modifier.safeDrawingPadding()) { + NavHost( + navController = navController, + startDestination = MainNavigation.startDestination, + modifier = Modifier.safeDrawingPadding(), + enterTransition = { if (currentDestination.enableTransition) fadeIn() else EnterTransition.None }, + exitTransition = { if (currentDestination.enableTransition) fadeOut() else ExitTransition.None }, + ) { composable { SentScreen( navigateToDetails = { navController.navigate(TransferDetailsDestination(it)) }, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScaffold.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScaffold.kt index f070580bb..fbaf6c487 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScaffold.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScaffold.kt @@ -97,6 +97,7 @@ private fun rememberNavType( } private fun NavHostController.navigateToSelectedItem(destination: MainNavigation) { + destination.enableTransition = false navigate(destination) { // Pop up to the start destination of the graph to avoid building up a large stack of destinations // on the back stack as users select items diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScreen.kt index 39e89a9b1..d4cfc4ec3 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScreen.kt @@ -45,7 +45,7 @@ fun MainScreen() { } MainScaffold(navController, currentDestination, windowAdaptiveInfo) { - MainNavHost(navController, windowAdaptiveInfo) + MainNavHost(navController, windowAdaptiveInfo, currentDestination) } }