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

import android.view.Gravity
import androidx.appcompat.app.AppCompatActivity
import cn.muchinfo.rma.R
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.contract.emptyView
import mtp.polymer.com.autowidget.adapter.BaseViewHolder
import org.jetbrains.anko.*

/**
 * 交易查询历史的viewholder
 * @property activity AppCompatActivity
 * @property viewModel TradingQueryViewModel
 * @property itemSize IntArray
 * @constructor
 */
class TradingHistoryViewHolder(
    private val activity: AppCompatActivity,
    private val viewModel: TradingQueryViewModel
) : BaseViewHolder<String>(activity) {
    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)

    override fun _FrameLayout.createContentView() {
        verticalLayout {
            linearLayout {
                verticalLayout {
                    gravity = Gravity.LEFT
                    textView {
                        text = "PT789"
                        textSizeAuto = 29
                        textColorInt = R.color.rma_black_33
                    }.lparams(wrapContent, wrapContent)
                    textView {
                        text = "买多"
                        textSizeAuto = 22
                        textColorInt = R.color.rma_star_color
                    }.lparams(wrapContent, wrapContent)
                }.lparams(autoSize(300), autoSize(100))

                verticalLayout {
                    gravity = Gravity.CENTER
                    textView {
                        text = "2"
                        textSizeAuto = 29
                        textColorInt = R.color.rma_black_33
                    }.lparams(wrapContent, wrapContent)
                    textView {
                        text = "4500"
                        textSizeAuto = 22
                        textColorInt = R.color.hint_text_color
                    }.lparams(wrapContent, wrapContent)
                }.lparams(autoSize(300), autoSize(100))

                verticalLayout {
                    gravity = Gravity.RIGHT
                    textView {
                        text = "全部成交"
                        textSizeAuto = 29
                        textColorInt = R.color.rma_black_33
                    }.lparams(wrapContent, wrapContent)
                    textView {
                        text = "2019-09-09 10:10:10"
                        textSizeAuto = 22
                        textColorInt = R.color.hint_text_color
                    }.lparams(wrapContent, wrapContent)
                }.lparams(autoSize(300), autoSize(100))
            }.lparams(matchParent, autoSize(100))

            linearLayout {
                gravity = Gravity.CENTER_VERTICAL

                emptyView()

                textView {
                    backgroundResource = R.drawable.rma_item_click_bg
                    gravity = Gravity.CENTER
                    text = "图表"
                    textColorInt = R.color.rma_item_click_color
                    textSizeAuto = 26
                }.lparams(autoSize(120), autoSize(48)) {
                    marginEnd = autoSize(36)
                }

                textView {
                    backgroundResource = R.drawable.rma_item_click_bg
                    gravity = Gravity.CENTER
                    text = "详情"
                    textColorInt = R.color.rma_item_click_color
                    textSizeAuto = 26
                }.lparams(autoSize(120), autoSize(48)) {
                    marginEnd = autoSize(36)
                }
            }.lparams(matchParent, autoSize(90))
        }.lparams(matchParent, wrapContent)
    }

}