package com.xyzshell.myphoneinfo.main

import android.util.Log
import android.view.LayoutInflater
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayoutMediator
import com.xyzshell.andinfo.AndInfo
import com.xyzshell.myphoneinfo.R

import com.xyzshell.myphoneinfo.base.BaseActivity
import com.xyzshell.myphoneinfo.dashboard.AppsFragment
import com.xyzshell.myphoneinfo.dashboard.BatteryFragment
import com.xyzshell.myphoneinfo.dashboard.CameraFragment
import com.xyzshell.myphoneinfo.dashboard.DashboardFragment
import com.xyzshell.myphoneinfo.dashboard.HardWareFragment
import com.xyzshell.myphoneinfo.dashboard.NetworkFragment
import com.xyzshell.myphoneinfo.dashboard.SensorsFragment
import com.xyzshell.myphoneinfo.dashboard.SystemShowFragment
import com.xyzshell.myphoneinfo.databinding.ActivityMainBinding
import com.xyzshell.myphoneinfo.dialog.SlideInPopView

class MainScrollActivity : BaseActivity<ActivityMainBinding>() {
    override fun inflateBinding(inflater: LayoutInflater): ActivityMainBinding =
        ActivityMainBinding.inflate(inflater)
    override fun initView() {
        super.initView()
        binding.run {

            val stringArray = resources.getStringArray(R.array.tab_title)
            TabLayoutMediator(tablelayout, viewpager3.apply {
                adapter = ViewPagerAdapter(
                    this@MainScrollActivity, listOf(
                        DashboardFragment.newInstance(),
                        HardWareFragment.newInstance(),
                        SystemShowFragment.newInstance(),
                        BatteryFragment.newInstance(),
                        NetworkFragment.newInstance(),
                        AppsFragment.newInstance(),
                        CameraFragment.newInstance(),
                        SensorsFragment.newInstance()
                    )
                )
                offscreenPageLimit = 1
                registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
                    override fun onPageSelected(position: Int) {
                        super.onPageSelected(position)
                    }
                })
            }) { tab, position ->
                tab.text = stringArray[position]
//                tab.setCustomView(R.layout.custom_ta
//
//                tab.customView?.run {
//                    val indicator: ImageView = findViewById(R.id.image_indicator)
//                    indicator.isVisible = position == 0
//                }
            }.attach()

        }

        binding.imageTool.setOnClickListener {
            val sidebarDialog = SlideInPopView(this)
            sidebarDialog.show()
        }
    }


    override fun initData() {
        super.initData()
    }

}