package rallyedto.finishedto.exampleedto

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.SmashedtoBinding
import rallyedto.battleedto.acresedto.Lemonedto
import rallyedto.policeedto.huntedto.Snuggleedto.privacyPinPassword
import rallyedto.remarkedto.cooperationedto.agricultureedto.Swimmingedto
import rallyedto.sunedto.tumouredto.majorityedto.loseedto.Togetheredto
import rallyedto.talledto.blewedto.Islandedto

/**
 * 隐私空间
 */
class Thoseedto : Lemonedto<SmashedtoBinding>() {

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

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


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

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

                override fun createFragment(position: Int): Fragment {
                    return fragments[position]
                }
            }
        }
        binding.uncertaintyedto.registerOnPageChangeCallback(object :
            ViewPager2.OnPageChangeCallback() {
            override fun onPageSelected(position: Int) {
                if (position == 0) {
                    binding.calendaredto.isSelected = true
                    binding.manedto.isSelected = false
                } else {
                    binding.manedto.isSelected = true
                    binding.calendaredto.isSelected = false
                }
            }
        })
        if (privacyPinPassword.isEmpty()) {
            binding.thirstyedto.setTextColor(Color.parseColor("#FAB44B"))
            binding.depressededto.text = "Setting"
        } else {
            binding.cottageedto.visibility = View.GONE
            binding.depressededto.text = "Got it"
        }
    }

    override fun initListener() {

        binding.depressededto.setOnClickListener {
            if (privacyPinPassword.isEmpty()) {
                startActivity(Intent(this, Designedto::class.java))
                finish()
            } else {
                binding.abridgeedto.visibility = View.GONE
            }
        }
        binding.calendaredto.setOnClickListener {
            binding.uncertaintyedto.currentItem = 0
        }
        binding.manedto.setOnClickListener {
            binding.uncertaintyedto.currentItem = 1
        }
        onBackPressedDispatcher.addCallback {
            admobMaxShowInterstitialAd(isShow = Togetheredto.isShowAdBackInter()) {
                finishToMain()
            }
        }
        binding.unfortunateedto.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }

    }

}