package com.develop.common.ui


import androidx.viewbinding.ViewBinding

import com.develop.base.mvvm.BaseBindingFragment
import com.develop.common.R
import com.develop.common.dialog.PlainDialogView

abstract class CommonBindingFragment<T : ViewBinding> : BaseBindingFragment<T>() {


    private val plainDialogView by lazy {
        PlainDialogView(hostActivity, R.layout.dialog_easy_view)
    }


    fun showPlainDialog(cancelable: Boolean = false) {
        if (hostActivity is CommonBindingActivity<*>) {
            (hostActivity as CommonBindingActivity<*>).showPlainDialog(cancelable)
        } else {
            plainDialogView.showDialog(cancelable)
        }
    }

    fun dismissPlainDialog() {
        if (hostActivity is CommonBindingActivity<*>) {
            (hostActivity as CommonBindingActivity<*>).dismissPlainDialog()
        } else {
            plainDialogView.hideDialog()
        }
    }
}