package importantedto.appliededto.surgeonedto.promiseedto.respectableedto.prisonedto.comfortableedto

import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import android.view.View
import androidx.activity.addCallback
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2
import com.base.datarecovery.databinding.CabinedtoBinding
import importantedto.admireedto.sweptedto.Differenceedto
import importantedto.afteredto.constitutionaledto.Murderedto
import importantedto.candidateedto.Stepedto
import importantedto.concreteedto.cameedto.Hateedto.privacyPinPassword
import importantedto.gallonedto.Transcendedto

/**
 * 隐私空间
 */
class Exclaimededto : Murderedto<CabinedtoBinding>() {

    override val binding: CabinedtoBinding by lazy {
        CabinedtoBinding.inflate(layoutInflater)
    }
    private val photosFragment: Stepedto by lazy {
        Stepedto("Photos")
    }

    private val videosFragment: Stepedto by lazy {
        Stepedto("Videos")
    }
    private val fragments by lazy {
        mutableListOf(photosFragment, videosFragment)
    }


    @SuppressLint("SetTextI18n")
    override fun initView() {
        Transcendedto.setStatusBarLightMode(this, true)
        Transcendedto.setStatusBarColor(this, Color.TRANSPARENT)

        binding.relatededto.run {
            adapter = object : FragmentStateAdapter(this@Exclaimededto) {
                override fun getItemCount(): Int {
                    return fragments.size
                }

                override fun createFragment(position: Int): Fragment {
                    return fragments[position]
                }
            }
        }
        binding.relatededto.registerOnPageChangeCallback(object :
            ViewPager2.OnPageChangeCallback() {
            override fun onPageSelected(position: Int) {
                if (position == 0) {
                    binding.headededto.isSelected = true
                    binding.seasonaledto.isSelected = false
                } else {
                    binding.seasonaledto.isSelected = true
                    binding.headededto.isSelected = false
                }
            }
        })
        if (privacyPinPassword.isEmpty()) {
            binding.wagonedto.setTextColor(Color.parseColor("#FAB44B"))
            binding.ghostwriteredto.text = "Setting"
        } else {
            binding.weightedto.visibility = View.GONE
            binding.ghostwriteredto.text = "Got it"
        }
    }

    override fun initListener() {
        super.initListener()

        binding.ghostwriteredto.setOnClickListener {
            if (privacyPinPassword.isEmpty()) {
                startActivity(Intent(this, Knitedto::class.java))
            } else {
                binding.headquartersedto.visibility = View.GONE
            }
        }
        binding.headededto.setOnClickListener {
            binding.relatededto.currentItem = 0
        }
        binding.seasonaledto.setOnClickListener {
            binding.relatededto.currentItem = 1
        }
        onBackPressedDispatcher.addCallback {
            Differenceedto.admobMaxShowInterstitialAd(this@Exclaimededto,false) {
                finishToMain()
            }
        }
        binding.bangedto.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }

    }

}