commonMain.com.arkivanov.decompose.router.pages.Pages.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of decompose Show documentation
Show all versions of decompose Show documentation
Kotlin Multiplatform lifecycle-aware business logic components
package com.arkivanov.decompose.router.pages
/**
* Represents a state of Child Pages navigation model.
*
* @param items a list of child configurations, must be unique, can be empty.
* @param selectedIndex an index of the selected child configuration.
* Must be within the range of [items] indices if [items] is not empty, otherwise can be any number.
*/
data class Pages(
val items: List,
val selectedIndex: Int,
) {
/**
* Creates empty [Pages].
*/
constructor() : this(items = emptyList(), selectedIndex = -1)
init {
if (items.isNotEmpty()) {
require(selectedIndex in items.indices) {
"The selectedIndex argument must be with the range: ${items.indices}. Actual: $selectedIndex."
}
}
}
}