NavOptionsBuilder


@NavOptionsDsl
class NavOptionsBuilder


DSL for constructing a new NavOptions

Summary

Public constructors

Public functions

Unit
anim(animBuilder: AnimBuilder.() -> Unit)

Sets any custom Animation or Animator resources that should be used.

inline Unit
<T : Any> popUpTo(noinline popUpToBuilder: PopUpToBuilder.() -> Unit)

Pop up to a given destination before navigating.

Unit
popUpTo(id: @IdRes Int, popUpToBuilder: PopUpToBuilder.() -> Unit)

Pop up to a given destination before navigating.

Unit
<T : Any> popUpTo(route: KClass<T>, popUpToBuilder: PopUpToBuilder.() -> Unit)

Pop up to a given destination before navigating.

Unit
<T : Any> popUpTo(route: T, popUpToBuilder: PopUpToBuilder.() -> Unit)

Pop up to a given destination before navigating.

Unit
popUpTo(route: String, popUpToBuilder: PopUpToBuilder.() -> Unit)

Pop up to a given destination before navigating.

Public properties

Boolean

Whether this navigation action should launch as single-top (i.e., there will be at most one copy of a given destination on the top of the back stack).

Int

This property is deprecated. Use the popUpToId property.

@IdRes Int

Returns the current destination that the builder will pop up to.

String?

The destination to pop up to before navigating.

KClass<*>?

The destination to pop up to before navigating.

Any?

The destination to pop up to before navigating.

Boolean

Whether this navigation action should restore any state previously saved by PopUpToBuilder.saveState or the popUpToSaveState attribute.

Public constructors

Added in 1.0.0
NavOptionsBuilder()

Public functions

anim

Added in 1.0.0
fun anim(animBuilder: AnimBuilder.() -> Unit): Unit

Sets any custom Animation or Animator resources that should be used.

Note: Animator resources are not supported for navigating to a new Activity

popUpTo

inline fun <T : Any> popUpTo(noinline popUpToBuilder: PopUpToBuilder.() -> Unit = {}): Unit

Pop up to a given destination before navigating. This pops all non-matching destination routes from the back stack until the destination with a matching route is found.

Parameters
<T : Any>

route from a KClass for the destination

noinline popUpToBuilder: PopUpToBuilder.() -> Unit = {}

builder used to construct a popUpTo operation

popUpTo

Added in 1.0.0
fun popUpTo(id: @IdRes Int, popUpToBuilder: PopUpToBuilder.() -> Unit = {}): Unit

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

popUpTo

fun <T : Any> popUpTo(route: KClass<T>, popUpToBuilder: PopUpToBuilder.() -> Unit): Unit

Pop up to a given destination before navigating. This pops all non-matching destination routes from the back stack until the destination with a matching route is found.

Parameters
route: KClass<T>

the KClass of the destination T

popUpToBuilder: PopUpToBuilder.() -> Unit

builder used to construct a popUpTo operation

popUpTo

fun <T : Any> popUpTo(route: T, popUpToBuilder: PopUpToBuilder.() -> Unit = {}): Unit

Pop up to a given destination before navigating. This pops all non-matching destination routes from the back stack until the destination with a matching route is found.

Parameters
route: T

route from a Object for the destination

popUpToBuilder: PopUpToBuilder.() -> Unit = {}

builder used to construct a popUpTo operation

popUpTo

fun popUpTo(route: String, popUpToBuilder: PopUpToBuilder.() -> Unit = {}): Unit

Pop up to a given destination before navigating. This pops all non-matching destination routes from the back stack until the destination with a matching route is found.

Parameters
route: String

route for the destination

popUpToBuilder: PopUpToBuilder.() -> Unit = {}

builder used to construct a popUpTo operation

Public properties

launchSingleTop

Added in 1.0.0
var launchSingleTopBoolean

Whether this navigation action should launch as single-top (i.e., there will be at most one copy of a given destination on the top of the back stack).

This functions similarly to how android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP works with activities.

popUpTo

Added in 1.0.0
var popUpToInt

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

popUpToId

val popUpToId: @IdRes Int

Returns the current destination that the builder will pop up to.

popUpToRoute

val popUpToRouteString?

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

popUpToRouteClass

val popUpToRouteClassKClass<*>?

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

popUpToRouteObject

val popUpToRouteObjectAny?

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

restoreState

var restoreStateBoolean

Whether this navigation action should restore any state previously saved by PopUpToBuilder.saveState or the popUpToSaveState attribute. If no state was previously saved with the destination ID being navigated to, this has no effect.