#set( $regex = "([a-z])([A-Z]+)")
#set( $replacement = "$1_$2")
#set( $dashName = $NAME.replaceAll($regex, $replacement).toLowerCase())
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import javax.inject.Inject;

import it.integry.integrywmsnative.MainApplication;
import it.integry.integrywmsnative.core.expansion.BaseDialogFragment;

public class Dialog${NAME}View extends BaseDialogFragment {

/*
Create the following layout resource file [dialog_${dashName}.xml]

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        app:cardCornerRadius="16dp"
        app:cardElevation="0dp">


        <androidx.appcompat.widget.LinearLayoutCompat
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingHorizontal="16dp"
            android:paddingVertical="16dp">

            <androidx.appcompat.widget.AppCompatImageView
                style="@style/MaterialAlertDialog.Material3.Title.Icon.CenterStacked"
                android:layout_width="36dp"
                android:layout_height="36dp"
                android:src="@drawable/ic_error_white_24dp"
                app:tint="?colorPrimary" />


            <androidx.appcompat.widget.AppCompatTextView
                android:id="@+id/title_text"
                style="@style/MaterialAlertDialog.Material3.Title.Text.CenterStacked"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:layout_marginBottom="16dp"
                android:text="Title here" />


            <androidx.appcompat.widget.AppCompatTextView
                android:id="@+id/description_text"
                style="@style/TextAppearance.Material3.BodyMedium"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:text="Description here" />


        </androidx.appcompat.widget.LinearLayoutCompat>
    </androidx.cardview.widget.CardView>
</layout>

*/


    @Inject
    Dialog${NAME}ViewModel mViewModel;
    
    //private Dialog${NAME}Binding mBindings;
    private Context mContext;

    //Pass here all external parameters
    public static Dialog${NAME}View newInstance() {
        return new Dialog${NAME}View();
    }
    
    private Dialog${NAME}View() {
        super();
    }
    
    
    @NonNull
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        this.mContext = requireContext();

        //mBindings = Dialog${NAME}Binding.inflate(LayoutInflater.from(this.mContext), null, false);
        //mBindings.setLifecycleOwner(this);


        /*
            - Add following lines into MainApplicationComponent
            
            [a] into @Component
            Dialog${NAME}Module.class
            
            [b] into interface body
            Dialog${NAME}Component.Factory dialog${NAME}Component();
        */
        MainApplication.appComponent
                .dialog${NAME}Component()
                .create()
                .inject(this);
                
        setCancelable(false);
                
        var alertDialog = new MaterialAlertDialogBuilder(this.mContext)
            .setView(mBindings.getRoot())
            .setCancelable(isCancelable())
            .create();
            
        alertDialog.setCanceledOnTouchOutside(isCancelable());
        alertDialog.setOnShowListener(this);
        return alertDialog;
    }

}