package com.ysnows.base.binding;

import android.content.res.ColorStateList;

import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton;
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButtonDrawable;

import androidx.databinding.BindingAdapter;

public class QMUIButtonBindingAdapter {


    @BindingAdapter("qmui_backgroundColor")
    public static void setQmuiBackgroundColor(QMUIRoundButton view, int color) {
        QMUIRoundButtonDrawable background = (QMUIRoundButtonDrawable) view.getBackground();
        background.setBgData(ColorStateList.valueOf(color));
        view.setBackground(background);
    }

    @BindingAdapter("qmui_borderColor")
    public static void setQmuiBorderColor(QMUIRoundButton view, int color) {
        QMUIRoundButtonDrawable background = (QMUIRoundButtonDrawable) view.getBackground();
        background.setStrokeColors(ColorStateList.valueOf(color));
        view.setBackground(background);
    }

    @BindingAdapter("qmui_borderWidth")
    public static void setqmui_borderWidth(QMUIRoundButton view, int width) {
        QMUIRoundButtonDrawable background = (QMUIRoundButtonDrawable) view.getBackground();
        background.setStrokeData(QMUIDisplayHelper.dp2px(view.getContext(), width), null);
        view.setBackground(background);
    }


}

