package com.base.appzxhy.ui.main


import androidx.core.graphics.toColorInt
import com.base.appzxhy.R
import com.base.appzxhy.base.BaseFragment
import com.base.appzxhy.bean.FeatureBean
import com.base.appzxhy.bean.FeatureBean.Companion.ANTIVIRUS
import com.base.appzxhy.bean.FeatureBean.Companion.BATTERY_INFO
import com.base.appzxhy.bean.FeatureBean.Companion.JUNK_CLEAN
import com.base.appzxhy.bean.FeatureBean.Companion.LARGE_FILE_CLEAN
import com.base.appzxhy.bean.FeatureBean.Companion.PHOTO_COMPRESSION
import com.base.appzxhy.bean.FeatureBean.Companion.SCREENSHOT_CLEAN
import com.base.appzxhy.bean.FeatureBean.Companion.SETTINGS
import com.base.appzxhy.bean.FeatureBean.Companion.SIMILAR_PHOTOS

import com.base.appzxhy.databinding.FragmentHomeBinding


class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::inflate) {

    private val adapter = FeatureItemAdapter()

    private val featureList by lazy {
        listOf<FeatureBean>(
            FeatureBean(
                JUNK_CLEAN,
                R.string.clean_junk,
                R.drawable.icon_clean,
                R.string.make_your_phone_clean,
                "#FFF7F2".toColorInt()
            ),
            FeatureBean(
                ANTIVIRUS,
                R.string.antivirus,
                R.drawable.icon_antivirus,
                R.string.mobile_antivirus_protection,
                "#F2FFF7".toColorInt()
            ),
            FeatureBean(
                SCREENSHOT_CLEAN,
                R.string.screenshot_clean,
                R.drawable.icon_screenshot,
                R.string.clear_phone_screenshot,
                "#FFFCF2".toColorInt()
            ),
            FeatureBean(
                LARGE_FILE_CLEAN,
                R.string.large_file_clean,
                R.drawable.icon_large_file_clean,
                R.string.clear_large_files_on_the_phone,
                "#F2FFF7".toColorInt()
            ),
            FeatureBean(
                SIMILAR_PHOTOS,
                R.string.similar_photos,
                R.drawable.icon_similar,
                R.string.cear_simnilar_pictures_on_the_phone,
                "#FBF7FF".toColorInt()
            ),
            FeatureBean(
                PHOTO_COMPRESSION,
                R.string.image_compression,
                R.drawable.icon_compression,
                R.string.coepress_mobile_phone_images,
                "#FFF7F2".toColorInt()
            ),
            FeatureBean(
                BATTERY_INFO,
                R.string.battery_info,
                R.drawable.icon_battery,
                R.string.wiew_battery_information,
                "#F2FFF7".toColorInt()
            ),
            FeatureBean(
                SETTINGS,
                R.string.settings,
                R.drawable.icon_set,
                R.string.show_all_settings,
                "#FBF7FF".toColorInt()
            ),
        )
    }

    override fun initView() {
        super.initView()
        (requireActivity() as MainActivity).insetsCallBack = { insets ->
            binding.flTop.setPadding(0, insets.top, 0, 0)
        }
        binding.rv.adapter = adapter
        adapter.submitList(featureList)

    }

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