package rowedto.jockeyedto.sheetedto.atticedto.harboredto

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.ColonedtoBinding
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.privacyPinPassword
import rowedto.jockeyedto.sheetedto.knewedto.economicedto.copyrightedto.Crossingedto
import rowedto.jockeyedto.sheetedto.raceedto.pavementedto.Spareedto
import rowedto.jockeyedto.sheetedto.slideedto.Offsetedto
import rowedto.jockeyedto.sheetedto.strangeedto.pyramidedto.particlesedto.Scandaledto

/**
 * 隐私空间
 */
class Reignedto : Crossingedto<ColonedtoBinding>() {

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

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


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

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

                override fun createFragment(position: Int): Fragment {
                    return fragments[position]
                }
            }
        }
        binding.guiltedto.registerOnPageChangeCallback(object :
            ViewPager2.OnPageChangeCallback() {
            override fun onPageSelected(position: Int) {
                if (position == 0) {
                    binding.slotedto.isSelected = true
                    binding.scatteredto.isSelected = false
                } else {
                    binding.scatteredto.isSelected = true
                    binding.slotedto.isSelected = false
                }
            }
        })
        if (privacyPinPassword.isEmpty()) {
            binding.eachedto.setTextColor(Color.parseColor("#FAB44B"))
            binding.banedto.text = "Setting"
        } else {
            binding.neighborhoodedto.visibility = View.GONE
            binding.banedto.text = "Got it"
        }
    }

    override fun initListener() {

        binding.banedto.setOnClickListener {
            if (privacyPinPassword.isEmpty()) {
                startActivity(Intent(this, Poemedto::class.java))
                finish()
            } else {
                binding.chooseedto.visibility = View.GONE
            }
        }
        binding.slotedto.setOnClickListener {
            binding.guiltedto.currentItem = 0
        }
        binding.scatteredto.setOnClickListener {
            binding.guiltedto.currentItem = 1
        }
        onBackPressedDispatcher.addCallback {
            Scandaledto.admobMaxShowInterstitialAd(this@Reignedto,false) {
                finishToMain()
            }
        }
        binding.conditionedto.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }

    }

}