package com.utopiaindustries.qualitychecker.utils;

import android.app.Dialog;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

import com.utopiaindustries.qualitychecker.R;


public class FullScreenImageDialog extends DialogFragment {
    private Bitmap imageBitmap;

    public FullScreenImageDialog(Bitmap imageBitmap) {
        this.imageBitmap = imageBitmap;
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        Dialog dialog = new Dialog(requireContext());
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.dialog_fullscreen_image);

        /*ImageView imageView = dialog.findViewById(R.id.fullscreenImageView);
        imageView.setImageBitmap(imageBitmap);*/

        //imageView.setOnClickListener(v -> dismiss()); // Close on image click
        ImageView imageView = dialog.findViewById(R.id.img_view);
        imageView.setImageBitmap(imageBitmap);

        ImageView btnClose = dialog.findViewById(R.id.btn_close);
        btnClose.setOnClickListener(v -> dismiss());

        dialog.getWindow().setLayout(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT
        );
        return dialog;
    }
}
