Skip to content

2.1.0-beta02

Pre-release
Pre-release
Compare
Choose a tag to compare
@raamcosta raamcosta released this 27 Apr 21:49
· 45 commits to main since this release
ef07917

Breaking Changes 馃槺

  • Most of our NavController extension functions were removed. Instead, if you want to use the type safe Compose Destinations friendly APIs, you'll need to use DestinationsNavigator.
    There are two new APIs to get this navigator from NavController: (you can also just receive DestinationsNavigator on your annotated Composables)

    • If you are inside a Composable, use navController.rememberDestinationsNavigator()
    • If not, use navController.toDestinationsNavigator()

Keep in mind you can still use NavController directly by adding .route. For example: navController.navigate(Destination(args).route).

We were forced to do this since new navigation versions introduced a new member function of NavController class that would shadow our extension functions (i.e, users of the lib would start calling it silently instead of our extension functions - the result would be a runtime crash). By removing the APIs on our side, it forces users of Compose Destinations to go handle this change and avoid runtime issues that way.

  • Parameter onlyIfResumed removed from navigate APIs. (including navigating back with result).
    Users should replace it with the new APIs dropUnlessResumed:
onClick = dropUnlessResumed {
    navigator.navigate(SomeDestination)
}

// BEFORE

onClick = {
    navigator.navigate(SomeDestination, onlyIfResumed = true)
}

Here it was just a timing thing. Given that we were forced into other breaking changes, might as well do this too. It also made it easier to provide functions to get DestinationsNavigator (see above) since it no longer depends on the NavBackStackEntry.

Improvements

  • Changes to help send SharedTransitionScope and AnimatedVisibilityScope.

Here is the recommended way to implement shared transition elements with the library:

//...
    SharedTransitionLayout {
        DestinationsNavHost(
           //...
            dependenciesContainerBuilder = {
                dependency(this@SharedTransitionLayout) // provide SharedTransitionScope to screens that need it
            }
        )
    }

// On screens:

@Destination<MyGraph>//...
@Composable
fun SharedTransitionScope.MyScreen(
    animatedVisibilityScope: AnimatedVisibilityScope //no need to do anything, it will be provided
) {
    Box( // just an example ofc
         modifier = Modifier
            .sharedElement(
                state = rememberSharedContentState(key = "whatever id"),
                animatedVisibilityScope = animatedVisibilityScope
            )
    )
//....
}

Full Changelog: 2.1.0-beta01...2.1.0-beta02