package com.example.quiz.utils;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.lifecycle.Observer;

import com.example.quiz.R;
import com.example.quiz.data.model.dtos.auth.LoginResponse;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

public class MessageDialog {

    public static void showSuccess(Context context, String message) {
        Dialog dialog = new Dialog(context);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_success, null);

        TextView txtMessage = view.findViewById(R.id.txtMessage);
        Button btnOk = view.findViewById(R.id.btnOk);

        txtMessage.setText(message);

        btnOk.setOnClickListener(v -> dialog.dismiss());

        dialog.setContentView(view);
        dialog.setCancelable(true);
        dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        dialog.show();
    }

    public static void showError(Context context, String message) {
        Dialog dialog = new Dialog(context);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_error, null);

        TextView txtMessage = view.findViewById(R.id.txtMessage);
        Button btnOk = view.findViewById(R.id.btnOk);

        txtMessage.setText(message);

        btnOk.setOnClickListener(v -> dialog.dismiss());

        dialog.setContentView(view);
        dialog.setCancelable(true);
        dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        dialog.show();
    }

}
