LocalNavAnimatedContentScopeKt

Added in 1.0.0-alpha02

public final class LocalNavAnimatedContentScopeKt


Summary

Public methods

getLocalNavAnimatedContentScope

public static final @NonNull ProvidableCompositionLocal<@NonNull AnimatedContentScopegetLocalNavAnimatedContentScope()

Local provider of AnimatedContentScope to androidx.navigation3.runtime.NavEntry.content.

This does not have a default value since the AnimatedContentScope is provided at runtime by AnimatedContent.

import androidx.compose.animation.SharedTransitionLayout
import androidx.compose.runtime.remember
import androidx.navigation3.runtime.entry
import androidx.navigation3.runtime.entryProvider
import androidx.navigation3.runtime.rememberNavBackStack
import androidx.navigation3.ui.NavDisplay

val backStack = rememberNavBackStack(CatList)
SharedTransitionLayout {
    NavDisplay(
        backStack = backStack,
        onBack = { backStack.removeAt(backStack.lastIndex) },
        entryProvider =
            entryProvider {
                entry<CatList> {
                    CatList(this@SharedTransitionLayout) { cat ->
                        backStack.add(CatDetail(cat))
                    }
                }
                entry<CatDetail> { args ->
                    CatDetail(args.cat, this@SharedTransitionLayout) {
                        backStack.removeAt(backStack.lastIndex)
                    }
                }
            },
    )
}