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

androidMain.tech.skot.core.components.SKBoxViewProxy.kt Maven / Gradle / Ivy

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

import android.view.ViewGroup
import androidx.fragment.app.Fragment
import tech.skot.view.live.MutableSKLiveData
import tech.skot.viewlegacy.R

class SKBoxViewProxy(
    itemsInitial: List>, hiddenInitial: Boolean? = false,
    override val asItemVertical: Boolean? = null
) :
    SKComponentViewProxy(), SKBoxVC {

    private val itemsLD: MutableSKLiveData>> =
        MutableSKLiveData(itemsInitial)

    override var items: List
        get() = itemsLD.value
        set(newVal) {
            itemsLD.postValue(newVal as List>)
        }

    override val layoutId =
        if (asItemVertical == true) R.layout.sk_box_vertical else R.layout.sk_box_horizontal

    private val hiddenLD: MutableSKLiveData = MutableSKLiveData(hiddenInitial)

    override var hidden: Boolean? by hiddenLD

    override fun bindTo(
        activity: SKActivity,
        fragment: Fragment?,
        binding: ViewGroup
    ): SKComponentView =
        SKBoxView(this, activity, fragment, binding).apply {
            itemsLD.observe {
                onItems(it)
            }
            hiddenLD.observe {
                onHidden(it)
            }
        }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy