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

feat: Disable navigation transitions #18

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
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 @@ -28,6 +28,8 @@ import kotlin.reflect.KClass
*/
@Serializable
sealed class MainNavigation : NavigationDestination() {
var enableTransition = true

@Serializable
data object SentDestination : MainNavigation()
@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<SentDestination> {
SentScreen(
navigateToDetails = { navController.navigate(TransferDetailsDestination(it)) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fun MainScreen() {
}

MainScaffold(navController, currentDestination, windowAdaptiveInfo) {
MainNavHost(navController, windowAdaptiveInfo)
MainNavHost(navController, windowAdaptiveInfo, currentDestination)
}
}

Expand Down
Loading