package com.abbidot.tracker.ui.activity.pet

import androidx.activity.viewModels
import com.abbidot.tracker.R
import com.abbidot.tracker.adapter.PetsParentBadgesAdapter
import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.bean.ParentBadgeBean
import com.abbidot.tracker.bean.PetBean
import com.abbidot.tracker.constant.ConstantString
import com.abbidot.tracker.databinding.ActivityBadgesListBinding
import com.abbidot.tracker.util.Util
import com.abbidot.tracker.util.ViewUtil
import com.abbidot.tracker.vm.PetInfoViewModel

class BadgesListActivity :
    BaseActivity<ActivityBadgesListBinding>(ActivityBadgesListBinding::inflate) {

    private val mPetViewModel: PetInfoViewModel by viewModels()

    private lateinit var mParentBadgesAdapter: PetsParentBadgesAdapter

    private var mPetBean: PetBean? = null

    override fun getTopBar() = mViewBinding.petBadgesListTopBar.titleTopBar

    override fun initData() {
        super.initData()
        setTopBarTitle(R.string.txt_badges)

        intent.extras?.apply {
            mPetBean = Util.getParcelableAdaptive(intent, ConstantString.Pet, PetBean::class.java)
        }

        mViewBinding.apply {
            root.setBackgroundResource(R.color.white)
            val parentBadges = mutableListOf<ParentBadgeBean>()
            ParentBadgeBean().apply {
                parentName = getString(R.string.txt_adventure)

                val badges = if (null==mPetBean) mPetViewModel.getBadges(mContext, "")
                else mPetViewModel.getBadges(mContext, mPetBean!!.createDate)
//                for (i in 0 until 23) badges.add(DataBean())
                badgeList = badges
                parentBadges.add(this)
            }
//            ParentBadgeBean().apply {
//                parentName = getString(R.string.txt_social)
//                val badges = mutableListOf<DataBean>()
//                for (i in 0 until 3) badges.add(DataBean())
//                badgeList = badges
//                parentBadges.add(this)
//            }
//            ParentBadgeBean().apply {
//                parentName = getString(R.string.txt_sporty)
//                val badges = mutableListOf<DataBean>()
//                for (i in 0 until 3) badges.add(DataBean())
//                badgeList = badges
//                parentBadges.add(this)
//            }
            mParentBadgesAdapter = PetsParentBadgesAdapter(mContext, parentBadges)
            ViewUtil.instance.setRecyclerViewVerticalLinearLayout(
                mContext, rvPetParentBadgesList, mParentBadgesAdapter
            )
        }
    }
}