package cn.muchinfo.rma.view.base.home.commodity.viewholder

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.isBlankString
import cn.muchinfo.rma.global.isShowTimeString
import cn.muchinfo.rma.global.toPercentage
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 com.blankj.utilcode.util.TimeUtils
import mtp.polymer.com.autowidget.adapter.BaseViewHolder
import org.jetbrains.anko.*

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

    override fun _FrameLayout.createContentView() {
        linearLayout {
            /**"修改时间"**/
            textView {
                gravity = Gravity.CENTER
                data.bindOptional(context) {
                    text = it?.updatetime?.isShowTimeString("MM-dd HH:mm")
                }
                textColorInt = R.color.hint_text_color
                textSizeAuto = 31
            }.lparams(autoSize(225), autoSize(100))
            /**"修改前套保比例"**/
            textView {
                gravity = Gravity.CENTER
                data.bindOptional(context) {
                    text = it?.beforevalue?.toPercentage()
                }
                text = "修改前套保比例"
                textColorInt = R.color.hint_text_color
                textSizeAuto = 31
            }.lparams(autoSize(225), autoSize(100))
            textView {
                gravity = Gravity.CENTER
                data.bindOptional(context) {
                    text = it?.logvalue?.toPercentage()
                }
                textColorInt = R.color.hint_text_color
                textSizeAuto = 31
            }.lparams(autoSize(225), autoSize(100))
            textView {
                gravity = Gravity.CENTER
                data.bindOptional(context) {
                    text = it?.applyname?.isBlankString()
                }
                textColorInt = R.color.hint_text_color
                textSizeAuto = 31
            }.lparams(autoSize(225), autoSize(100))
        }.lparams(matchParent, autoSize(100))
    }

}