All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.tech.skot.core.components.SKPager.kt Maven / Gradle / Ivy

The newest version!
package tech.skot.core.components

import tech.skot.core.di.coreViewInjector

class SKPager(
    initialScreens: List>,
    onUserSwipeToPage: ((index: Int) -> Unit)? = null,
    initialSelectedPageIndex: Int = 0,
    swipable: Boolean = true,
) : SKComponent() {


    override val view = coreViewInjector.pager(
        screens = initialScreens.map { it.view },
        onUserSwipeToPage = onUserSwipeToPage,
        initialSelectedPageIndex = initialSelectedPageIndex,
        swipable = swipable
    )

    var selectedIndex: Int
        get() = view.selectedPageIndex
        set(value) {
            view.selectedPageIndex = value
        }

    var screens: List> = initialScreens
        set(value) {
            view.screens = value.map { it.view }
            field = value
        }

    override fun onRemove() {
        super.onRemove()
        screens.forEach { it.onRemove() }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy