package com.base.filerecoveryrecyclebin.fragment

import android.annotation.SuppressLint
import com.base.filerecoveryrecyclebin.BuildConfig
import com.base.filerecoveryrecyclebin.R
import com.base.filerecoveryrecyclebin.activity.guide.GuideActivity
import com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
import com.base.filerecoveryrecyclebin.databinding.FragmentGuideBinding
import com.base.filerecoveryrecyclebin.help.BaseFragment

class GuideFragment : BaseFragment<FragmentGuideBinding>() {

    private val TAG = "GuideFragment"

    var page: Int = 1

    override val binding: FragmentGuideBinding by lazy {
        FragmentGuideBinding.inflate(layoutInflater)
    }


    @SuppressLint("SetTextI18n")
    override fun setView() {

        when (page) {
            0 -> {
                binding.iv.setImageResource(R.mipmap.yindaotu1)
                binding.ivDian.setImageResource(R.mipmap.dian1)
                binding.tvContent.text = "Clean up clutter to unlock more space and\n" +
                        "keep your phone running smoothly."
            }

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

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

    override fun setListener() {
        super.setListener()
        binding.tvBtn.setOnClickListener {
            val activity = requireActivity() as GuideActivity?
            activity ?: requireActivity()
            activity?.next(page)
        }

    }

    override fun onResume() {
        super.onResume()

        if (AdmobMaxHelper.showGuideNativeSp() || BuildConfig.DEBUG) {
            kotlin.runCatching {
                AdmobMaxHelper.admobMaxShowNativeAd(requireActivity(), binding.flAd)
            }
        }

    }

}