package cn.muchinfo.rma.view.base.procurement.detailsviewholder

import android.view.Gravity
import androidx.appcompat.app.AppCompatActivity
import cn.muchinfo.rma.R
import cn.muchinfo.rma.global.data.ChangeLogData
import cn.muchinfo.rma.global.isShowTimeString
import cn.muchinfo.rma.lifecycle.bindOptional
import cn.muchinfo.rma.view.autoWidget.autoSize
import cn.muchinfo.rma.view.autoWidget.textColorInt
import cn.muchinfo.rma.view.autoWidget.textSizeAuto
import mtp.polymer.com.autowidget.adapter.BaseViewHolder
import org.jetbrains.anko.*

class ChangeRecordViewHolder(private val activity: AppCompatActivity) : BaseViewHolder<ChangeLogData>(activity){
    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)

    override fun _FrameLayout.createContentView() {
        linearLayout {
            gravity = Gravity.CENTER_HORIZONTAL
            // text = "变更时间"
            textView {
                gravity = Gravity.CENTER
                data.bindOptional(context){
                    text = it?.updatetime?.isShowTimeString("yyyy-MM-dd HH:mm")
                }

                textColorInt = R.color.hint_text_color
                textSizeAuto = 24
            }.lparams(autoSize(300), autoSize(100))
            //  text = "类型"
            textView {
                gravity = Gravity.CENTER
                data.bindOptional(context){
                    text = it?.operatelogtypedesc
                }
                textColorInt = R.color.hint_text_color
                textSizeAuto = 24
            }.lparams(autoSize(300), autoSize(100))
            // text = "操作人"
            textView {
                gravity = Gravity.CENTER
                data.bindOptional(context){
                    text = it?.applyname
                }
                textColorInt = R.color.hint_text_color
                textSizeAuto = 24
            }.lparams(autoSize(300), autoSize(100))
        }.lparams(matchParent, autoSize(100))
    }

}