package rallyedto.farewelledto

import android.app.Activity
import android.view.Gravity
import android.view.ViewGroup
import android.widget.PopupWindow
import androidx.core.view.updatePadding
import com.base.datarecovery.databinding.GrimaceedtoBinding
import rallyedto.talledto.blewedto.Islandedto


class Lakeedto(private val activity: Activity, val onDismiss: () -> Unit) : PopupWindow() {

    init {
        width = ViewGroup.LayoutParams.MATCH_PARENT
        height = ViewGroup.LayoutParams.MATCH_PARENT

        isOutsideTouchable = false
        isFocusable = true
        isClippingEnabled = false
    }

    private val binding by lazy {
        GrimaceedtoBinding.inflate(activity.layoutInflater)
    }
    fun show() {
        contentView = binding.root
        activity.window.decorView.post {
            binding.root.updatePadding(top = Islandedto.getStatusBarHeight())
            Islandedto.setStatusBarLightMode(activity, false)
            showAtLocation(activity.window.decorView, Gravity.CENTER, 0, 0)
        }
        binding.resourceedto.setOnClickListener {
            dismiss()
        }
        binding.windedto.setOnClickListener {
            onDismiss.invoke()
            dismiss()

        }

    }


    override fun dismiss() {
        super.dismiss()
        Islandedto.setStatusBarLightMode(activity, true)
    }
}