package pxds.dlpf.buoz.fico

import android.content.Context
import android.text.SpannableString
import android.text.Spanned
import android.text.style.ForegroundColorSpan
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import com.test.basd.supercleanermax.R
import com.test.basd.supercleanermax.databinding.RoydzbBinding
import pxds.lmmd.zmwf.Khko.setTrackedOnClickListener
import pxds.lmmd.zmwf.Khko.string

object Ouwp {

    fun Context.showFileDeleteDialog(click: () -> Unit) {
        val binding = RoydzbBinding.inflate(LayoutInflater.from(this))
        val dialog = AlertDialog.Builder(this).setView(binding.root).create()

        dialog.setContentView(binding.root)
        dialog.setCanceledOnTouchOutside(true)
        dialog.show()

        val lp = dialog.window?.attributes
        lp?.width = this.resources.getDimensionPixelOffset(R.dimen.ބޢގނސ)
        lp?.height = ViewGroup.LayoutParams.WRAP_CONTENT
        dialog.window?.attributes = lp
        dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)

        val text = R.string.ރޝނވޒ_D.string()
        val spannableString = SpannableString(text)
        val start = text.indexOf(R.string.ބޓޤޢޅ_D.string())
        if (start != -1) {
            val end = start + R.string.ޠޏޖޕޕ_D.string().length
            val colorSpan = ForegroundColorSpan(ContextCompat.getColor(this, R.color.ލކއޣށ))
            spannableString.setSpan(colorSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
        }

        binding.iiyuoks.text = spannableString
        binding.afhzdgi.setTrackedOnClickListener {
            dialog.dismiss()
            click.invoke()
        }
        binding.udpuzmr.setTrackedOnClickListener {
            dialog.dismiss()
        }
    }
}