package it.integry.integrywmsnative.core.model;

import androidx.databinding.Observable;
import it.integry.integrywmsnative.core.di.BindableBoolean;
import it.integry.integrywmsnative.view.dialogs.choose_arts_from_lista_arts.DialogChooseArtsFromListaArtsItemModel;

public class CheckableMtbColr {


    private DialogChooseArtsFromListaArtsItemModel item;
    private BindableBoolean checked = new BindableBoolean(false);
    private BindableBoolean hidden = new BindableBoolean(false);

    public CheckableMtbColr(DialogChooseArtsFromListaArtsItemModel item) {
        this.item = item;

        this.item.getHidden().addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(Observable sender, int propertyId) {
                hidden.set(item.isHidden());
            }
        });
    }

    public DialogChooseArtsFromListaArtsItemModel getItem() {
        return item;
    }

    public CheckableMtbColr setItem(DialogChooseArtsFromListaArtsItemModel item) {
        this.item = item;

        this.item.getHidden().addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(Observable sender, int propertyId) {
                hidden.set(item.isHidden());
            }
        });

        return this;
    }

    public BindableBoolean getChecked() {
        return checked;
    }

    public CheckableMtbColr setChecked(BindableBoolean checked) {
        this.checked = checked;
        return this;
    }

    public BindableBoolean getHidden() {
        return hidden;
    }

    public boolean isHidden() {
        return hidden.get();
    }

    public CheckableMtbColr setHidden(BindableBoolean hidden) {
        this.hidden = hidden;
        return this;
    }

    public void toggleCheck() {
        this.checked.set(!this.checked.get());
    }
}
