package rallyedto.finishedto.fictionedto.thanedto

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2
import com.base.datarecovery.databinding.NonremittaledtoBinding
import rallyedto.battleedto.acresedto.Lemonedto
import rallyedto.sunedto.tumouredto.majorityedto.loseedto.Togetheredto
import rallyedto.talledto.blewedto.Islandedto


class Farmedto : Lemonedto<NonremittaledtoBinding>() {
    override val binding: NonremittaledtoBinding by lazy {
        NonremittaledtoBinding.inflate(layoutInflater)
    }
    private val page1: Heroinedto by lazy {
        Heroinedto().apply { page = 0 }
    }
    private val page2: Heroinedto by lazy {
        Heroinedto().apply { page = 1 }
    }
    private val adPage: Seriesedto by lazy {
        Seriesedto().apply { page = 2 }
    }
    private val page3: Heroinedto by lazy {
        Heroinedto().apply { page = 3 }
    }
    private val page4: Heroinedto by lazy {
        Heroinedto().apply { page = 4 }
    }
    private val fragments by lazy {
        mutableListOf(page1, page2, adPage, page3, page4)
    }


    override fun initView() {
        Islandedto.setStatusBarLightMode(this, true)
        if (!Togetheredto.checkNative()) {
            fragments.removeAt(2)
        }

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

                override fun createFragment(position: Int): Fragment {
                    return fragments[position]
                }
            }
        }
        binding.lunchedto.registerOnPageChangeCallback(object :
            ViewPager2.OnPageChangeCallback() {
            override fun onPageSelected(position: Int) {
            }
        })

    }

    fun setPosition(position: Int) {
        binding.lunchedto.currentItem = position
    }
}