package com.example.doctor.Patients.Reports

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.example.doctor.R
import com.example.doctor.databinding.ItemQuestionnaireBeforeBinding


class QBAdapter() : ListAdapter<QBModel, QBAdapter.Holder>(Comparator()) {
    class Holder(view: View) :
        RecyclerView.ViewHolder(view) {

        val binding = ItemQuestionnaireBeforeBinding.bind(view)


        @SuppressLint("SuspiciousIndentation")
        fun bind(item: QBModel) = with(binding) {
//            if (item.one == 1) {
//                txtB1.text = "Да"
//            } else {
//                txtB1.text = "Нет"
//            }



//            txtB1.text = item.one.toString()
//
//            if (item.two == 2) {
//                txtB2.text = "Да"
//            } else {
//                txtB2.text = "Нет"
//            }
//
//            if (item.three == 3) {
//                txtB3.text = "Да"
//            } else {
//                txtB3.text = "Нет"
//            }
//
//            if (item.four == 4) {
//                txtB4.text = "Да"
//            } else {
//                txtB4.text = "Нет"
//            }
//
//            if (item.five == 5) {
//                txtB5.text = "Да"
//            } else {
//                txtB5.text = "Нет"
//            }
//
//            if (item.six == 6) {
//                txtB6.text = "Да"
//            } else {
//                txtB6.text = "Нет"
//            }
//
//            if (item.seven == 7) {
//                txtB7.text = "Да"
//            } else {
//                txtB7.text = "Нет"
//            }
//
//            if (item.eight == 8) {
//                txtB8.text = "Да"
//            } else {
//                txtB8.text = "Нет"
//            }
//
//            if (item.nine == 9) {
//                txtB9.text = "Да"
//            } else {
//                txtB9.text = "Нет"
//            }
//
        }


    }


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_questionnaire_before, parent, false)
        return Holder(view)
    }

    override fun onBindViewHolder(holder: Holder, position: Int) {
        val view = holder.bind(getItem(position))
    }

    class Comparator : DiffUtil.ItemCallback<QBModel>() {
        override fun areItemsTheSame(oldItem: QBModel, newItem: QBModel): Boolean {
            return oldItem.id == newItem.id
        }

        override fun areContentsTheSame(oldItem: QBModel, newItem: QBModel): Boolean {
            return oldItem == newItem
        }
    }



}




