package rememberic

import android.view.Gravity
import android.view.LayoutInflater
import android.widget.LinearLayout
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.easy.clean.R
import com.easy.clean.databinding.HypothesesicBinding

class Stringsic(
    val activity: AppCompatActivity
) {
    val dialog = AlertDialog.Builder(activity).create()
    val binding = HypothesesicBinding.inflate(LayoutInflater.from(activity))

    var action: (() -> Unit)? = null

    fun showDialog(type: String) {
        dialog.setView(binding.root)
        dialog.setCanceledOnTouchOutside(true)

        dialog.show()

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

        when (type) {
            "delete" -> {
                binding.jobic.text = activity.getString(R.string.amplifyic)
                binding.spadesic.text = activity.getString(R.string.swapic)
                binding.counterfeiteric.text = activity.getString(R.string.involvedic)
            }
        }
        binding.interimic.setOnClickListener {
            dialog.dismiss()
        }
        binding.counterfeiteric.setOnClickListener {
            dialog.dismiss()
            action?.invoke()
        }

    }
}