package com.adealink.weparty.commonui.widget

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes

open class SlideBottomDialogFragment(@LayoutRes override val layoutId: Int) :
    BottomDialogFragment(layoutId), SlideLayout.Callback {

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?,
    ): View? {
        val view = super.onCreateView(inflater, container, savedInstanceState)
        (view as? SlideLayout)?.callback = this@SlideBottomDialogFragment
        return view
    }

    override fun onSlideOut() {
        dismiss()
    }

    override fun onDestroyView() {
        super.onDestroyView()
        if (view is SlideLayout) {
            (view as SlideLayout).callback = null
        }
    }

}