package com.module.backstage.adapter

import android.annotation.SuppressLint
import android.graphics.Typeface
import android.view.LayoutInflater
import android.view.ViewGroup
import com.module.backstage.databinding.BackstageItemOrderdataBinding
import com.module.database.room.entity.LocalOrderBean
import com.quyunshuo.androidbaseframemvvm.base.addressenum.PayEnum
import com.quyunshuo.androidbaseframemvvm.common.util.UiUtil


// 假设有一个Item布局文件item_layout.xml，对应的ViewBinding类为BackstageItemErrorstatBinding
// 以及一个数据模型类DataModel  

class OrderDataAdapter(var productList: MutableList<LocalOrderBean>? = null) :
    BaseBindingAdapter<LocalOrderBean, BackstageItemOrderdataBinding>(productList) {

    override fun createViewBinding(
        inflater: LayoutInflater,
        parent: ViewGroup
    ): BackstageItemOrderdataBinding {
        return BackstageItemOrderdataBinding.inflate(inflater, parent, false)
    }

    @SuppressLint("SetTextI18n", "SimpleDateFormat")
    override fun convert(
        holder: BaseBindViewHolder<BackstageItemOrderdataBinding>,
        warringBean: LocalOrderBean
    ) {
        // 其他数据绑定操作...

        // 使用ViewBinding来绑定数据  
        holder.binding.run {
            if (warringBean.time == "") {
                tvTime.text = "时间"
                tvTime.setTypeface(null, Typeface.BOLD)
                tvPrice.text = "价格"
                tvPrice.setTypeface(null, Typeface.BOLD)
                tvName.text = "产品名称"
                tvName.setTypeface(null, Typeface.BOLD)
                tvOrderid.text = "订单编号"
                tvOrderid.setTypeface(null, Typeface.BOLD)
                tvNumber.text = "序号"
                tvNumber.setTypeface(null, Typeface.BOLD)
                tvPayType.text = "支付方式"
                tvPayType.setTypeface(null, Typeface.BOLD)
                return
            }
//                var formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
//                Log.d(TAG, "bind: "+warringBean.time)
//                val curDate = Date(warringBean.time)
//                val time = formatter.format(curDate)
            tvTime.text = warringBean.time
            tvPrice.text = "${warringBean.price}"
            tvName.text = warringBean.name
            tvOrderid.text = warringBean.sn
            tvNumber.text = "${holder.layoutPosition}"
            tvPayType.text = warringBean.payType

        }
    }
}