package pxds.etmo.ibpc

import android.graphics.Bitmap
import android.graphics.Color
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.webkit.WebView
import androidx.core.view.isVisible
import androidx.core.view.updatePadding
import com.blankj.utilcode.util.BarUtils
import com.test.basd.supercleanermax.R
import com.test.basd.supercleanermax.databinding.PdghoeBinding
import pxds.lmmd.zmwf.Bpfw
import pxds.lmmd.zmwf.Khko.setTrackedOnClickListener
import pxds.lmmd.zmwf.Khko.string

class Wayu : Bpfw<PdghoeBinding>() {

    override val binding: PdghoeBinding by lazy {
        PdghoeBinding.inflate(layoutInflater)
    }

    private var currentTab = 0

    private val tabs = mutableListOf<Foee?>(null)

    override fun initListener() {
        binding.prcvwew.setTrackedOnClickListener {

        }
        binding.vtbviqv.setTrackedOnClickListener {
            loadUrl(R.string.ދޟޜޣސ_D.string())
        }
        binding.okvzxoj.setTrackedOnClickListener {

        }
        binding.srcxxbh.setTrackedOnClickListener {

        }
        binding.kjyhgwg.setTrackedOnClickListener {

        }
        binding.prbunng.setTrackedOnClickListener {

        }
        binding.dpxnerk.setTrackedOnClickListener {

        }
        binding.qrpnmdv.setTrackedOnClickListener {

        }
    }

    override fun initView() {
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
        binding.root.updatePadding(top = BarUtils.getStatusBarHeight())

    }

    private fun loadUrl(url: String) {

        binding.ktrnjrn.isVisible = true
        binding.xouqnjd.isVisible=false
        if (tabs[currentTab] == null) {
            tabs[currentTab] = Foee(
                object : Foee.WebViewListener {
                    override val activity = this@Wayu

                    override fun onProgressChanged(progress: Int) {

                    }

                    override fun onReceivedTitle(title: String) {

                    }

                    override fun onReceivedIcon(icon: Bitmap?) {

                    }

                    override fun onPageStarted(url: String, icon: Bitmap?) {

                    }

                    override fun onPageFinished(view: WebView?, url: String) {

                        binding.hirpzcs.isSelected = view?.canGoBack() == true
                        binding.zytlwhc.isSelected = view?.canGoForward() == true

                    }
                }, url
            )
        } else {
            tabs[currentTab]?.loadUrl(url)
        }
        tabs[currentTab]?.isHome = false

        binding.ktrnjrn.removeAllViews()
        binding.ktrnjrn.addView(tabs[currentTab]?.getWebView(), 0, MATCH_PARENT)
    }
}