package com.remax.visualnovel.app.widget

import android.content.Context
import com.remax.visualnovel.databinding.DialogLoadingBinding
import com.remax.visualnovel.widget.dialoglib.LBindingDialog

class LoadingDialog {

    private lateinit var dialog: LBindingDialog<DialogLoadingBinding>
    private var context: Context? = null

    fun build(context: Context): LoadingDialog {
        this.context = context
        dialog = LBindingDialog(context,DialogLoadingBinding::inflate)
        dialog.with()
            .setCenter()
            .setBgRadius(4)
            .setWidth(80)
            .setHeight(80)
        dialog.setCancelable(false)
        dialog.setCanceledOnTouchOutside(false)
        return this
    }

    fun getDialog(): LBindingDialog<DialogLoadingBinding> {
        return dialog
    }

    fun show() {
        if (this::dialog.isInitialized) {
            dialog.show()
        }
    }

    fun dismiss() {
        if (this::dialog.isInitialized) {
            dialog.dismiss()
        }
    }
}