NavEntryDecorator
-
Cmn
open class NavEntryDecorator<T : Any>
ResultEventBusNavEntryDecorator |
Wraps the content of a |
SaveableStateHolderNavEntryDecorator |
Wraps the content of a |
ViewModelStoreNavEntryDecorator |
Provides the content of a |
Decorate the NavEntrys that are integrated with a rememberDecoratedNavEntries.
HOW TO USE Primary usages include but are not limited to:
-
provide information to entries with
androidx.compose.runtime.CompositionLocal, i.e.
val decorator = NavEntryDecorator<Any> { entry ->
...
CompositionLocalProvider(LocalMyStateProvider provides myState) {
entry.Content()
}
}
-
Wrap entry content with other composable content
val decorator = NavEntryDecorator<Any> { entry ->
...
MyComposableFunction {
entry.Content()
}
}
REUSABILITY To enhance reusability, the NavEntryDecorator can be returned by a function or subclassed:
// a reusable function
fun <T : Any> myDecorator(val myState: MyState): NavEntryDecorator<T> =
NavEntryDecorator(onPop = { contentKey -> myState.clear(contentKey) }) { entry ->
myState.storeState(entry.contentKey)
entry.Content()
}
// or subclass NavEntryDecorator
class MyDecorator(
val myState: MyState
): NavEntryDecorator(
onPop = { contentKey -> myState.clear(contentKey) },
decorate = { entry ->
myState.storeState(entry.contentKey)
entry.Content()
}
)| Parameters | |
|---|---|
<T : Any> |
the type of the backStack key |
| See also | |
|---|---|
contentKey |
Summary
Public constructors |
|
|---|---|
<T : Any> NavEntryDecorator( |
Cmn
|
Public constructors
NavEntryDecorator
<T : Any> NavEntryDecorator(
onPop: (key: Any) -> Unit = {},
decorate: @Composable (entry: NavEntry<T>) -> Unit
)
| Parameters | |
|---|---|
<T : Any> |
the type of the backStack key |
onPop: (key: Any) -> Unit = {} |
the callback to clean up the decorator state associated with a |
decorate: @Composable (entry: NavEntry<T>) -> Unit |
the composable function to decorate a |