package pxds.dlpf.buoz.fico

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.test.basd.supercleanermax.R
import com.test.basd.supercleanermax.databinding.XasozwBinding
import pxds.lmmd.zmwf.Khko.setTrackedOnClickListener
import pxds.lmmd.zmwf.Khko.string
import pxds.lmmd.zmwf.Onaw.PAST_60_MINUS_QUERY
import pxds.lmmd.zmwf.Onaw.SEVEN_DAYS_QUERY
import pxds.lmmd.zmwf.Onaw.TODAY_QUERY
import pxds.lmmd.zmwf.Onaw.YESTERDAY_QUERY
import java.text.SimpleDateFormat
import kotlin.time.Duration.Companion.days
import kotlin.time.DurationUnit

object Wncp {

    fun Context.showTimeSelectDialog(click: (mode: Int) -> Unit) {
        val dialog = BottomSheetDialog(this)
        val binding = XasozwBinding.inflate(LayoutInflater.from(this))
        dialog.setContentView(binding.root)
        dialog.setCanceledOnTouchOutside(true)
        dialog.show()

        val lp = dialog.window?.attributes
        lp?.width = ViewGroup.LayoutParams.MATCH_PARENT
        lp?.height = ViewGroup.LayoutParams.WRAP_CONTENT
        dialog.window?.attributes = lp
        dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)

        val simpleDateFormat2 = SimpleDateFormat(R.string.އށބސސ_D.string())
        binding.ypowooa.text = R.string.ޅޥޡބޙ_D.string() + simpleDateFormat2.format(System.currentTimeMillis())
        binding.ijdlhxy.text = R.string.ށޣޠހޢ_D.string() + simpleDateFormat2.format(System.currentTimeMillis() - 1.days.toLong(DurationUnit.MILLISECONDS))

        binding.gjggubw.setTrackedOnClickListener {
            dialog.dismiss()
            click.invoke(PAST_60_MINUS_QUERY)
        }
        binding.ypowooa.setTrackedOnClickListener {
            dialog.dismiss()
            click.invoke(TODAY_QUERY)
        }
        binding.ijdlhxy.setTrackedOnClickListener {
            dialog.dismiss()
            click.invoke(YESTERDAY_QUERY)
        }
        binding.rpfftzz.setTrackedOnClickListener {
            dialog.dismiss()
            click.invoke(SEVEN_DAYS_QUERY)
        }
    }
}