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.lxj.xpopup.core.CenterPopupView;

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


    public TextPopupView(@NonNull Context context,String data) {
        super(context);
        this.data = data;

    }

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


    @Override
    protected void onCreate() {
        super.onCreate();
        TextView etInput = findViewById(R.id.tv_input);
        TextView tvCancel = findViewById(R.id.tv_cancel);
        TextView tvConfirm = findViewById(R.id.tv_confirm);
        etInput.setText(data);
        if (listener != null) {
            tvConfirm.setOnClickListener(view -> {
                listener.okClick(etInput.getText().toString());
                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 TextPopupView setOnOkListener(OnOkListener listener) {
        this.listener = listener;
        return this;
    }

    public interface OnOkListener {
        void okClick(String item);
    }
}
