package com.base.scanqrclear.ui.spotifyqr

import android.app.Activity
import android.app.AlertDialog
import android.view.Gravity
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.base.scanqrclear.R
import com.base.scanqrclear.ads.AdsMgr
import com.base.scanqrclear.databinding.DialogSpotifyBinding

object SpotifyDialog {

    fun Activity.showSpotifyDialog() {
        val dialog = AlertDialog.Builder(this).create()
        val binding = DialogSpotifyBinding.inflate(LayoutInflater.from(this))
        dialog.setView(binding.root)
        dialog.setCanceledOnTouchOutside(false)

        dialog.show()

        val params = dialog.window?.attributes
        params?.width = ConstraintLayout.LayoutParams.MATCH_PARENT
//        params?.height = resources.getDimensionPixelOffset(R.dimen.dp_400)
        params?.gravity = Gravity.BOTTOM
//        params?.y = 50

        dialog.window?.attributes = params
        dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)


        AdsMgr.showNative(binding.flAd, R.layout.layout_admob_native_custom)

        binding.flClose.setOnClickListener {
            dialog.dismiss()
        }
    }
}