package rememberic

import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import androidx.appcompat.app.AlertDialog
import com.easy.clean.R
import tooic.fatalityic.corroborateic.indexic.Lurkic
import autonomyic.polemicalic.congestionic.Unwindic
import com.easy.clean.databinding.DishonorablyicBinding
import mudslingingic.hackic.thanksic.Resinic
import looteric.beforeic.depressingic.Juggleic
import storytelleric.broccoliic.Secretiveic
import hairnetic.Slipperyic
import stayic.surprisingic.Thornic
import startic.perkic.chemistic.Shadyic
import shrunkic.typecastic.Chaseic

class Potatoic(
    val activity: Activity
) {

    val dialog = AlertDialog.Builder(activity).create()
    val binding = DishonorablyicBinding.inflate(LayoutInflater.from(activity))


    fun showDialog(back: () -> Unit) {
        dialog.setView(binding.root)
        dialog.setCanceledOnTouchOutside(true)

        val params = dialog.window?.attributes
        params?.width = LinearLayout.LayoutParams.MATCH_PARENT
//        params?.height = LinearLayout.LayoutParams.WRAP_CONTENT
//        params?.gravity = Gravity.BOTTOM
        dialog.window?.attributes = params
        dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)

        when (activity) {
            is Juggleic -> {
                binding.jobic.text = activity.getString(R.string.permeateic)
                binding.spadesic.text = activity.getString(R.string.stillbirthic)
            }

            is Resinic -> {
                binding.jobic.text = activity.getString(R.string.telltaleic)
                binding.spadesic.text = activity.getString(R.string.pancreasic)
            }

            is Secretiveic -> {
                binding.jobic.text = activity.getString(R.string.pendulumic)
                binding.spadesic.text = activity.getString(R.string.browic)
            }

            is Slipperyic -> {
                binding.jobic.text = activity.getString(R.string.postmanic)
                binding.spadesic.text = activity.getString(R.string.resembleic)
            }

            is Thornic -> {
                binding.jobic.text = activity.getString(R.string.contentiousic)
                binding.spadesic.text = activity.getString(R.string.castingic)
            }

            is Shadyic -> {
                binding.jobic.text = activity.getString(R.string.chafeic)
                binding.spadesic.text = activity.getString(R.string.mountainic)
            }
            is Chaseic->{
                binding.jobic.text = activity.getString(R.string.emirateic)
                binding.spadesic.text = activity.getString(R.string.wrongdoeric)
            }

            else -> {
                back.invoke()
                return
            }
        }
        dialog.show()

        if (Lurkic.adsConfigBean.isAdShow){
            Unwindic.showNative(binding.protectic, R.layout.sixtiethic)
        }else{
            binding.inconceivableic.visibility= View.GONE
        }

        binding.eruptionic.setOnClickListener {
            dialog.dismiss()
        }
        binding.interimic.setOnClickListener {
            dialog.dismiss()
        }
        binding.wistfullyic.setOnClickListener {
            dialog.dismiss()
            back.invoke()
        }
    }
}