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.lifecycle.bindOptional
import cn.muchinfo.rma.view.autoWidget.autoSize
import cn.muchinfo.rma.view.autoWidget.textColorInt
import cn.muchinfo.rma.view.autoWidget.textSizeAuto
import cn.muchinfo.rma.view.base.procurement.data.ContractDetailsData
import mtp.polymer.com.autowidget.adapter.BaseViewHolder
import org.jetbrains.anko.*

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

    override fun _FrameLayout.createContentView() {
        linearLayout {
            gravity = Gravity.CENTER_VERTICAL
            background = resources.getDrawable(R.color.white)
            linearLayout {
                gravity = Gravity.CENTER_VERTICAL
                textView {
                    data.bindOptional(context){
                        text = it?.title
                    }
                    textSizeAuto = 31
                    textColorInt = R.color.rma_gray_color
                }.lparams(wrapContent, wrapContent){
                    marginStart = autoSize(35)
                }
            }.lparams(autoSize(250), autoSize(120))

            textView {
                data.bindOptional(context){
                    text = it?.content
                }
                textSizeAuto = 31
                textColorInt = R.color.rma_black_33
            }.lparams(wrapContent, wrapContent){
                marginStart = autoSize(35)
            }

        }.lparams(matchParent, autoSize(120))
    }

}