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.FragmentGuide2Binding
import com.base.appzxhy.ui.main.MainActivity

class Guide2Fragment : BaseFragment<FragmentGuide2Binding>(FragmentGuide2Binding::inflate) {
    var page: Int = 1


    @SuppressLint("SetTextI18n")
    override fun initView() {
        super.initView()

        when (page) {
            0 -> {
                binding.iv.setImageResource(R.drawable.image_guide_1)
                binding.ivDian.setImageResource(R.drawable.dian_1)
                binding.tvContent.text = getString(R.string.guide_tip_1)
            }

            1 -> {
                binding.iv.setImageResource(R.drawable.image_guide_2)
                binding.ivDian.setImageResource(R.drawable.dian_2)
                binding.tvContent.text = getString(R.string.guide_tip_2)
            }

            3 -> {
                binding.iv.setImageResource(R.drawable.image_guide_3)
                binding.ivDian.setImageResource(R.drawable.dian_3)
                binding.tvContent.text = getString(R.string.guide_tip_3)
                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)
        }
    }
}