package com.base.appzxhy.ui.guide

import android.annotation.SuppressLint
import android.content.Intent
import com.base.appzxhy.R
import com.base.appzxhy.base.BaseFragment
import com.base.appzxhy.business.ads.AdsMgr
import com.base.appzxhy.databinding.FragmentGuideBinding
import com.base.appzxhy.ui.main.MainActivity


class GuideFragment : BaseFragment<FragmentGuideBinding>(FragmentGuideBinding::inflate) {
    var page: Int = 1


    @SuppressLint("SetTextI18n")
    override fun initView() {
        super.initView()
        when (page) {
            0 -> {
                binding.iv.setImageResource(R.drawable.chahua04)
                binding.ivDian.setImageResource(R.drawable.icon1)
                binding.tvContent.text = "Clean up clutter to unlock more space and\n" +
                        "keep your phone running smoothly."
            }

            1 -> {
                binding.iv.setImageResource(R.drawable.chahua03)
                binding.ivDian.setImageResource(R.drawable.icon2)
                binding.tvContent.text = "Quickly clear junk files and free up valuable\n" +
                        "storage with just a few taps."
            }

            3 -> {
                binding.iv.setImageResource(R.drawable.chahua01)
                binding.ivDian.setImageResource(R.drawable.icon4)
                binding.tvContent.text = "Clean photos,videos,and audio files to\n" +
                        "save space and keep your phone tidy."
                binding.tvBtn.text = "Start"
            }
        }

    }

    override fun initListener() {
        super.initListener()
        binding.tvSkip.setOnClickListener {
            val activity = requireActivity() as GuideActivity?
            activity?.startActivity(Intent(activity, MainActivity::class.java))
            activity?.finish()
        }
        binding.tvBtn.setOnClickListener {
            val activity = requireActivity() as GuideActivity?
            activity ?: requireActivity()
            activity?.next(page)
        }
    }

    override fun onResume() {
        super.onResume()

        if (!binding.flAd.isAdShowed) {
            AdsMgr.showNative(binding.flAd, R.layout.layout_admob_native_custom)
        }
    }

}
