Package-level declarations

Types

Link copied to clipboard
@Serializable
open class BackDestination(val result: Any? = null, val args: Destination.Args = Destination.Args()) : Destination

Pass this as parameter to the NavigationController.navigate to return to the previous screen in the current backstack.

Link copied to clipboard
@Serializable
open class BackstackDestination(val backstackIndex: Int, val args: Destination.Args = Destination.Args(backstackIndex = backstackIndex)) : Destination

Pass this as parameter to the NavigationController.navigate to switch current backstack.

Link copied to clipboard
class Consumable<T : Any>

A result, delivered after a BackDestination carrying it was handled.

Link copied to clipboard
interface Destination

Implementations of Destination represent minimum set of data, required to show screen.

Link copied to clipboard
Link copied to clipboard
sealed interface ResultSource

Read-only source of navigation results.

Link copied to clipboard
Link copied to clipboard
@Serializable
sealed class Transition

Represents a screen transition animation strategy.

Properties

Link copied to clipboard

Default time-to-live for stored results: after this duration a result is no longer observable or consumable. Expired entries are pruned lazily when results are stored, observed, consumed, cleared or discarded during navigation.

Functions

Link copied to clipboard
suspend fun <T : Any> Flow<Consumable<T>>.consume(block: suspend (T) -> Unit)

Collects results of type T and passes every result, which was consumed successfully, to block. Results, already consumed by another collector or expired, are skipped.

inline fun <T : Any> ResultSource.consume(scope: CoroutineScope, noinline block: suspend (T) -> Unit): Job

Launches collection of results of type T in scope and passes every consumed result to block.

Link copied to clipboard
fun NavigationContainer(key: Any, onClose: () -> Unit, screenSize: Size, controller: NavigationController, foreground: @Composable BoxScope.() -> Unit? = null, background: @Composable BoxScope.() -> Unit? = null, topBar: @Composable () -> Unit? = null, navigationBar: @Composable () -> Unit? = null, setup: NavigationConfiguration.() -> Unit = {})

Container component that provides navigation for screens, which were added in scope. It is expected to have only one NavigationContainer per application.

Link copied to clipboard
inline fun <T : Any> ResultSource.observeResults(): Flow<Consumable<T>>

Observes results of type T, delivered after BackDestination is handled. Every result is wrapped into Consumable: it is removed from the store once consumed and cannot be consumed twice.

Link copied to clipboard
fun rememberNavigationController(startDestinations: List<Destination>, onScreenChange: (debugInfo: String) -> Unit = {}, resultTtl: Duration = DEFAULT_RESULT_TTL): NavigationController

Creates a controller with its own ResultStore.

fun rememberNavigationController(startDestinations: List<Destination>, onScreenChange: (debugInfo: String) -> Unit = {}, resultSource: ResultSource): NavigationController

Creates a controller backed by the provided resultSource. Pass the same source to application wrappers when they need to observe results independently of the controller.

Link copied to clipboard
fun SimpleNavigationContainer(key: Any, onClose: () -> Unit, screenSize: Size, controller: NavigationController, animateTransitions: Boolean = false, screenTransition: Transition = Transition.Slide(isReversed = true, isVertical = false), switchTransition: BackstackSwitchTransition = { previousBackstackId, nextBackstackId -> Transition.Slide(isReversed = previousBackstackId < nextBackstackId, isVertical = false) }, foreground: @Composable BoxScope.() -> Unit? = null, background: @Composable BoxScope.() -> Unit? = null)