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

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

There is a newer version: 1.2.9
Show newest version
package tech.skot.core.components

import tech.skot.core.di.coreViewInjector

class SKPagerWithTabs(
    initialPages: List = emptyList(),
    onSwipeToPage: ((index: Int) -> Unit)? = null,
    initialSelectedPageIndex: Int = 0,
    swipable: Boolean = false
):SKComponent() {
    class Page(val screen:SKScreen<*>, val label:String)


    val pager = SKPager(
        initialScreens = initialPages.map { it.screen },
        onSwipeToPage = onSwipeToPage,
        initialSelectedPageIndex = initialSelectedPageIndex,
        swipable = swipable
    )

    var pages: List = initialPages
        set(value) {
            pager.screens = value.map { it.screen }
            view.labels = value.map { it.label }
            field = value
        }

    override val view = coreViewInjector.pagerWithTabs(pager.view, initialPages.map { it.label })

    override fun onRemove() {
        pager.onRemove()
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy