package com.swiftcleaner.chovey.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.widget.ImageView;

import androidx.appcompat.widget.AppCompatButton;
import androidx.cardview.widget.CardView;

import com.swiftcleaner.chovey.R;

public class AppExitDialog extends Dialog {

    private Context context;
    private OnDialogClickListener listener;
    public interface OnDialogClickListener {
        void onCancel();
        void onSubmit();
    }
    public AppExitDialog(Context context) {
        super(context, R.style.TransparentDialogTheme);
        this.context = context;
        setContentView(R.layout.dialog_app_exit_item);

        AppCompatButton dialog_exit = findViewById(R.id.dialog_exit);
        AppCompatButton dialog_experience = findViewById(R.id.dialog_experience);
        ImageView iv_dialog_close = findViewById(R.id.iv_dialog_close);
        CardView cardView = findViewById(R.id.cardview);
        cardView.setCardBackgroundColor(Color.TRANSPARENT);

        dialog_exit.setOnClickListener(v -> {
            if (listener != null) {
                listener.onCancel();
            }
            dismiss();
        });

        dialog_experience.setOnClickListener(v -> {
            if (listener != null) {
                listener.onSubmit();
            }
            dismiss();
        });
        iv_dialog_close.setOnClickListener(v->{
            dismiss();
        });
        setCanceledOnTouchOutside(false);
    }

    public void show() {
        super.show();
    }

    public void setOnDialogClickListener(OnDialogClickListener listener) {
        this.listener = listener;
    }
}