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

import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Typeface
import android.view.Gravity
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import cn.muchinfo.rma.R
import cn.muchinfo.rma.global.data.GGConvertConfigData
import cn.muchinfo.rma.global.data.WrStandardData
import cn.muchinfo.rma.lifecycle.bindOptional
import cn.muchinfo.rma.view.autoWidget.autoSize
import cn.muchinfo.rma.view.autoWidget.onThrottleFirstClick
import cn.muchinfo.rma.view.autoWidget.textColorInt
import cn.muchinfo.rma.view.autoWidget.textSizeAuto
import cn.muchinfo.rma.view.base.home.contract.emptyView
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.ToastUtils
import mtp.polymer.com.autowidget.adapter.BaseViewHolder
import org.jetbrains.anko.*

/**
 * 期货品种适配器
 * @property activity AppCompatActivity
 * @property viewModel CommodityInformationViewModel
 * @property itemSize IntArray
 * status 0 停用 1正常
 * @constructor
 */
class CommodityFutureViewHolder(
    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 {
                verticalLayout {
                    gravity = Gravity.LEFT
                    textView {
                        data.bindOptional(context) {
                            text = it?.srcexchangecode + "/" + it?.srcname + "/"
                        }
                        textSizeAuto = 24
                        textColorInt = R.color.hint_text_color
                    }.lparams(wrapContent, wrapContent) {
                        topMargin = autoSize(20)
                        marginStart = autoSize(36)
                    }
                    textView {
                        data.bindOptional(context) {
                            text = it?.srccode + "/" + it?.srcunitidname + "/"
                        }
                        textSizeAuto = 24
                        textColorInt = R.color.hint_text_color
                    }.lparams(wrapContent, wrapContent) {
                        marginStart = autoSize(36)
                    }
                }.lparams(autoSize(300), autoSize(97))

                verticalLayout {
                    gravity = Gravity.CENTER
                    textView {
                        data.bindOptional(context) {
                            text = it?.convertratio
                        }

                        textSizeAuto = 24
                        textColorInt = R.color.hint_text_color
                    }.lparams(wrapContent, wrapContent)
                }.lparams(autoSize(300), autoSize(97))

                verticalLayout {
                    gravity = Gravity.RIGHT
                    textView {
                        data.bindOptional(context) {
                            text = it?.dstexchangecode + "/" + it?.dstname + "/"
                        }
                        textSizeAuto = 24
                        textColorInt = R.color.hint_text_color
                    }.lparams(wrapContent, wrapContent) {
                        topMargin = autoSize(20)
                        marginStart = autoSize(36)
                    }
                    textView {
                        data.bindOptional(context) {
                            text = it?.dstcode + "/" + it?.dstname + "/"
                        }
                        textSizeAuto = 24
                        textColorInt = R.color.hint_text_color
                    }.lparams(wrapContent, wrapContent) {
                        marginEnd = autoSize(36)
                    }
                }.lparams(autoSize(300), autoSize(97))
            }.lparams(matchParent, autoSize(97))
        }
    }

}