androidMain.tech.skot.core.components.SKPagerWithTabsViewProxy.kt Maven / Gradle / Ivy
package tech.skot.core.components
import android.view.View
import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayout
import tech.skot.view.live.MutableSKLiveData
class SKPagerWithTabsViewProxy(
override val pager: SKPagerViewProxy,
initialTabConfigs: List,
initialTabsVisibility: SKPagerWithTabsVC.Visibility,
) : SKComponentViewProxy(), SKPagerWithTabsVC {
private val tabConfigsLD = MutableSKLiveData(initialTabConfigs)
override var tabConfigs: List
get() = tabConfigsLD.value
set(value) {
tabConfigsLD.postValue(value)
}
private val tabsVisibilityLD = MutableSKLiveData(initialTabsVisibility)
override var tabsVisibility: SKPagerWithTabsVC.Visibility
get() = tabsVisibilityLD.value
set(value) {
tabsVisibilityLD.postValue(value)
}
override fun saveState() {
pager.saveState()
}
override fun bindTo(
activity: SKActivity,
fragment: Fragment?,
binding: View
): SKPagerWithTabsView {
val pagerView = binding.findViewWithTag("sk_view_pager2")
val tabLayoutView = binding.findViewWithTag("sk_tab_layout")
return SKPagerWithTabsView(
this,
activity,
fragment,
binding,
pagerView,
tabLayoutView
).apply {
pager.bindTo(activity, fragment, pagerView)
tabConfigsLD.observe {
onLabels(it)
}
tabsVisibilityLD.observe {
onShowTabs(it)
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy