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

import android.annotation.SuppressLint
import android.view.Gravity
import androidx.appcompat.app.AppCompatActivity
import cn.muchinfo.rma.R
import cn.muchinfo.rma.global.data.GGConvertConfigData
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.home.commodity.CommodityInformationViewModel
import cn.muchinfo.rma.view.base.home.contract.emptyView
import cn.muchinfo.rma.view.base.home.contract.viewItemUI
import mtp.polymer.com.autowidget.adapter.BaseViewHolder
import org.jetbrains.anko.*

class HedgeFutureVarietyViewholder(
    private val activity: AppCompatActivity,
    private val viewModel: CommodityInformationViewModel
): BaseViewHolder<GGConvertConfigData>(activity) {
    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)

    @SuppressLint("SetTextI18n")
    override fun _FrameLayout.createContentView() {
        verticalLayout {
            linearLayout {
                background = resources.getDrawable(R.color.white)
                gravity = Gravity.CENTER_VERTICAL

                textView {
                    data.bindOptional(context){
                        text = "期货品种" + dataIndex.plus(1)
                    }
                    textSizeAuto = 31
                    textColorInt = R.color.rma_black_33
                }.lparams(wrapContent, wrapContent) {
                    marginStart = autoSize(60)
                }

                textView {
                    data.bindOptional(context){
                        text = it?.dstname
                    }
                    text = "请选择套保品种自动填入"
                    textSizeAuto = 31
                    textColorInt = R.color.rma_hint_text_color_ccc
                }.lparams(wrapContent, wrapContent) {
                    marginStart = autoSize(80)
                }

                emptyView()

            }.lparams(matchParent, autoSize(132))

            viewItemUI()

            linearLayout {
                background = resources.getDrawable(R.color.white)
                gravity = Gravity.CENTER_VERTICAL

                textView {
                    data.bindOptional(context){
                        text = "期货品种系数" + dataIndex.plus(1)
                    }
                    textSizeAuto = 31
                    textColorInt = R.color.rma_black_33
                }.lparams(wrapContent, wrapContent) {
                    marginStart = autoSize(60)
                }

                textView {
                    data.bindOptional(context){
                        text = it?.convertratio
                    }
                    text = "请选择套保品种自动填入"
                    textSizeAuto = 31
                    textColorInt = R.color.rma_hint_text_color_ccc
                }.lparams(wrapContent, wrapContent) {
                    marginStart = autoSize(30)
                }

                emptyView()

            }.lparams(matchParent, autoSize(132))
            view {
                background = resources.getDrawable(R.color.rma_hint_line_color_eee)
            }.lparams(matchParent, autoSize(8))
        }
    }

}