PreCompose icon indicating copy to clipboard operation
PreCompose copied to clipboard

[BUG] `NavTransition::createTransition` and `destroyTransition ` not used when navigating

Open Dambakk opened this issue 8 months ago • 4 comments

I have defined the following NavTransition:

val slideEnterFromLeftTowardsRight: (width: Int) -> Int = { width -> -width }
val slideExitTowardsLeft: (width: Int) -> Int = { width -> -width }
val slideExitTowardsRight: (width: Int) -> Int = { width -> width }
val slideEnterFromRightTowardsLeft: (width: Int) -> Int = { width -> width }

val defaultNavTransition = NavTransition(
        createTransition = slideInHorizontally(
            initialOffsetX = slideEnterFromRightTowardsLeft,
        ),
        destroyTransition = slideOutHorizontally(
            targetOffsetX = slideExitTowardsRight,
        ),
        pauseTransition = slideOutHorizontally(
            targetOffsetX = slideExitTowardsLeft,
        ),
        resumeTransition = slideInHorizontally(
            initialOffsetX = slideEnterFromLeftTowardsRight,
        ),
    )

and provided it to the NavHost like the following:

    val navController = rememberNavigator()
    NavHost(
        modifier = Modifier.fillMaxSize(),
        navigator = navController,
        initialRoute = "list",
        navTransition = defaultNavTransition,
        swipeProperties = remember { SwipeProperties() }

    ) {
        scene(
            ...
      }

Bug: When navigating from screen A to B none of the transitions are used. When popping the backstack from B to A I get the expected transition as defined above. Same behaviour on both android and ios.

Have I misconfigured anything or is there a bug in PreCompose?

PreCompose version: 1.6.0

Dambakk avatar May 31 '24 11:05 Dambakk