NavDestinationBuilder


@NavDestinationDsl
open class NavDestinationBuilder<D : NavDestination>

Known indirect subclasses

DSL for constructing a new NavDestination

Summary

Public constructors

<D : NavDestination> NavDestinationBuilder(
    navigator: Navigator<D>,
    id: @IdRes Int
)

This function is deprecated. Use routes to build your NavDestination instead

<D : NavDestination> NavDestinationBuilder(
    navigator: Navigator<D>,
    route: String?
)

DSL for constructing a new NavDestination with a unique route.

<D : NavDestination> NavDestinationBuilder(
    navigator: Navigator<D>,
    route: KClass<*>?,
    typeMap: Map<KTypeNavType<*>>
)

DSL for constructing a new NavDestination with a serializable KClass.

Public functions

Unit
action(actionId: Int, actionBuilder: NavActionBuilder.() -> Unit)

This function is deprecated. Building NavDestinations using IDs with the Kotlin DSL has been deprecated in favor of using routes.

Unit
argument(name: String, argumentBuilder: NavArgumentBuilder.() -> Unit)

Add a NavArgument to this destination.

Unit
argument(name: String, argument: NavArgument)

Add a NavArgument to this destination.

open D

Build the NavDestination by calling Navigator.createDestination.

inline Unit
<T : Any> deepLink(basePath: String)

Add a deep link to this destination.

Unit
deepLink(navDeepLink: NavDeepLinkDslBuilder.() -> Unit)

Add a deep link to this destination.

Unit
deepLink(navDeepLink: NavDeepLink)

Add a deep link to this destination.

Unit
deepLink(uriPattern: String)

Add a deep link to this destination.

inline Unit
<T : Any> deepLink(basePath: String, noinline navDeepLink: NavDeepLinkDslBuilder.() -> Unit)

Add a deep link to this destination.

Protected functions

open D

Instantiate a new instance of D that will be passed to build.

Public properties

Int

The destination's unique ID.

CharSequence?

The descriptive label of the destination

String?

The destination's unique route.

Protected properties

Navigator<D>

The navigator the destination that will be used in instantiateDestination to create the destination.

Public constructors

<D : NavDestination> NavDestinationBuilder(
    navigator: Navigator<D>,
    id: @IdRes Int
)

DSL for constructing a new NavDestination with a unique id.

This sets the destination's route to null.

Parameters
navigator: Navigator<D>

navigator used to create the destination

id: @IdRes Int

the destination's unique id

Returns
NavDestinationBuilder<D>

the newly constructed NavDestination

<D : NavDestination> NavDestinationBuilder(
    navigator: Navigator<D>,
    route: String?
)

DSL for constructing a new NavDestination with a unique route.

This will also update the id of the destination based on route.

Parameters
navigator: Navigator<D>

navigator used to create the destination

route: String?

the destination's unique route

Returns
NavDestinationBuilder<D>

the newly constructed NavDestination

<D : NavDestination> NavDestinationBuilder(
    navigator: Navigator<D>,
    route: KClass<*>?,
    typeMap: Map<KTypeNavType<*>>
)

DSL for constructing a new NavDestination with a serializable KClass.

This will also update the id of the destination based on KClass's serializer.

Parameters
navigator: Navigator<D>

navigator used to create the destination

route: KClass<*>?

the KClass of the destination

typeMap: Map<KTypeNavType<*>>

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if destination does not use custom NavTypes.

Returns
NavDestinationBuilder<D>

the newly constructed NavDestination

Public functions

action

Added in 1.0.0
fun action(actionId: Int, actionBuilder: NavActionBuilder.() -> Unit): Unit

Adds a new NavAction to the destination

argument

Added in 1.0.0
fun argument(name: String, argumentBuilder: NavArgumentBuilder.() -> Unit): Unit

Add a NavArgument to this destination.

argument

fun argument(name: String, argument: NavArgument): Unit

Add a NavArgument to this destination.

build

Added in 1.0.0
open fun build(): D

Build the NavDestination by calling Navigator.createDestination.

deepLink

inline fun <T : Any> deepLink(basePath: String): Unit

Add a deep link to this destination.

The arguments in T are expected to be identical (in name and type) to the arguments in the route from KClass that was used to construct this NavDestinationBuilder.

Extracts deeplink arguments from T and appends it to the basePath. See docs on the safe args version of NavDeepLink.Builder.setUriPattern for the final uriPattern's generation logic.

In addition to a direct Uri match, basePaths without a scheme are assumed as http and https. For example, www.example.com will match http://www.example.com and https://www.example.com.

Parameters
<T : Any>

The deepLink KClass to extract arguments from

basePath: String

The base uri path to append arguments onto

See also
setUriPattern

for the final uriPattern's generation logic.

deepLink

Added in 2.3.0
fun deepLink(navDeepLink: NavDeepLinkDslBuilder.() -> Unit): Unit

Add a deep link to this destination.

In addition to a direct Uri match, the following features are supported:

  • Uris without a scheme are assumed as http and https. For example, www.example.com will match http://www.example.com and https://www.example.com.

  • Placeholders in the form of {placeholder_name} matches 1 or more characters. The String value of the placeholder will be available in the arguments Bundle with a key of the same name. For example, http://www.example.com/users/{id} will match http://www.example.com/users/4.

  • The .* wildcard can be used to match 0 or more characters.

Parameters
navDeepLink: NavDeepLinkDslBuilder.() -> Unit

the NavDeepLink to be added to this destination

deepLink

fun deepLink(navDeepLink: NavDeepLink): Unit

Add a deep link to this destination.

In addition to a direct Uri match, the following features are supported:

  • Uris without a scheme are assumed as http and https. For example, www.example.com will match http://www.example.com and https://www.example.com.

  • Placeholders in the form of {placeholder_name} matches 1 or more characters. The String value of the placeholder will be available in the arguments Bundle with a key of the same name. For example, http://www.example.com/users/{id} will match http://www.example.com/users/4.

  • The .* wildcard can be used to match 0 or more characters.

Parameters
navDeepLink: NavDeepLink

the NavDeepLink to be added to this destination

deepLink

Added in 1.0.0
fun deepLink(uriPattern: String): Unit

Add a deep link to this destination.

In addition to a direct Uri match, the following features are supported:

  • Uris without a scheme are assumed as http and https. For example, www.example.com will match http://www.example.com and https://www.example.com.

  • Placeholders in the form of {placeholder_name} matches 1 or more characters. The String value of the placeholder will be available in the arguments Bundle with a key of the same name. For example, http://www.example.com/users/{id} will match http://www.example.com/users/4.

  • The .* wildcard can be used to match 0 or more characters.

Parameters
uriPattern: String

The uri pattern to add as a deep link

See also
deepLink

deepLink

inline fun <T : Any> deepLink(basePath: String, noinline navDeepLink: NavDeepLinkDslBuilder.() -> Unit): Unit

Add a deep link to this destination.

The arguments in T are expected to be identical (in name and type) to the arguments in the route from KClass that was used to construct this NavDestinationBuilder.

Extracts deeplink arguments from T and appends it to the basePath. See docs on the safe args version of NavDeepLink.Builder.setUriPattern for the final uriPattern's generation logic.

In addition to a direct Uri match, basePaths without a scheme are assumed as http and https. For example, www.example.com will match http://www.example.com and https://www.example.com.

Parameters
<T : Any>

The deepLink KClass to extract arguments from

basePath: String

The base uri path to append arguments onto

noinline navDeepLink: NavDeepLinkDslBuilder.() -> Unit

the NavDeepLink to be added to this destination

See also
setUriPattern

for the final uriPattern's generation logic.

Protected functions

instantiateDestination

protected open fun instantiateDestination(): D

Instantiate a new instance of D that will be passed to build.

By default, this calls Navigator.createDestination on navigator, but can be overridden to call a custom constructor, etc.

Public properties

id

Added in 1.0.0
val idInt

The destination's unique ID.

label

Added in 1.0.0
var labelCharSequence?

The descriptive label of the destination

route

val routeString?

The destination's unique route.

Protected properties

Added in 1.0.0
protected val navigatorNavigator<D>

The navigator the destination that will be used in instantiateDestination to create the destination.