package com.xty.server.frag

import androidx.recyclerview.widget.LinearLayoutManager
import com.xty.base.fragment.BaseFragList
import com.xty.base.fragment.BaseVmFrag
import com.xty.base.fragment.IBaseFrag
import com.xty.network.model.AppointmentBean
import com.xty.network.model.AppointmentNewBean
import com.xty.server.adapter.AppointmentAdapter
import com.xty.server.databinding.FragHistoryBinding
import com.xty.server.vm.MyAppointmentVm

class HistoryFrag: BaseFragList<MyAppointmentVm>() {

    val adapter by lazy{ AppointmentAdapter(1) }
    val binding by lazy { FragHistoryBinding.inflate(layoutInflater)}
    override fun setLayout()=binding.root

    override fun setViewModel()=MyAppointmentVm()

    override fun observer() {
        mViewModel.apponitMentBean.observe(this){
            var list= mutableListOf<AppointmentNewBean>()
            it.data.forEach {
                if(it.orderStatus!=2){
                    list.add(it)
                }
            }
            setDate(adapter,list)
        }
    }
    override fun initView() {
        super.initView()
        initAdapter()
         setRecycleRefresh(binding.mRecycle,binding.mRefresh)
    }


    override fun refresh() {
        mViewModel.getAppointment(7)
    }


    override   fun initAdapter(){
        binding.mRecycle.layoutManager=LinearLayoutManager(requireContext())
        binding.mRecycle.adapter=adapter
    }


}