package com.dahe.mylibrary.cuspop;

import android.content.Context;
import android.util.Log;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.dahe.mylibrary.R;
import com.dahe.mylibrary.bean.TipsBean;
import com.lxj.xpopup.core.CenterPopupView;

/**
 * Description: 自定义局部阴影弹窗
 * Create by dance, at 2018/12/21
 */
public class TextPopupTipsView extends CenterPopupView {
    private TipsBean data;
    private Context ctx;


    public TextPopupTipsView(@NonNull Context context, TipsBean data) {
        super(context);
        this.data = data;

    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.my_confim_popup_tip;
    }


    @Override
    protected void onCreate() {
        super.onCreate();
        TextView etInput = findViewById(R.id.tv_input);
        TextView tvTitle = findViewById(R.id.tv_title);
        TextView tvCancel = findViewById(R.id.tv_cancel);
        TextView tvConfirm = findViewById(R.id.tv_confirm);
        tvTitle.setText(data.getTitle());
        etInput.setText(data.getContent());
        if (listener != null) {
            tvConfirm.setOnClickListener(view -> {
                listener.okClick();
                dismiss();
            });
        }

        tvCancel.setOnClickListener(v -> dismiss());

    }

    @Override
    protected void onShow() {
        super.onShow();
        Log.e("tag", "CustomPartShadowPopupView onShow");
    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
        Log.e("tag", "CustomPartShadowPopupView onDismiss");
    }


    private OnOkListener listener;

    public TextPopupTipsView setOnOkListener(OnOkListener listener) {
        this.listener = listener;
        return this;
    }

    public interface OnOkListener {
        void okClick();
    }
}
