package cn.muchinfo.rma.view.base.future.trade

import android.os.Bundle
import android.view.Gravity
import androidx.appcompat.app.AppCompatActivity
import cn.muchinfo.rma.R
import cn.muchinfo.rma.view.autoWidget.*
import cn.muchinfo.rma.view.base.BaseActivity
import cn.muchinfo.rma.view.base.home.contract.emptyView
import cn.muchinfo.rma.view.eventbus.EventConstent
import cn.muchinfo.rma.view.eventbus.MessageEvent
import mtp.polymer.com.autowidget.dialog.creatSelectAccountDialog
import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.*

/**
 * 期货交易页面
 */
class GoodsTradeActivity : BaseActivity<GoodsTradeViewModel>(){

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        /**
         * 页面ui
         */
        verticalLayout {
            background = resources.getDrawable(R.color.segtabment_bg_color)
            //头部标题
            linearLayout {
                background = resources.getDrawable(R.color.main_title_bg_color)
                gravity = Gravity.CENTER_VERTICAL
                imageView {
                    imageResource = R.mipmap.back
                    onThrottleFirstClick {
                        finish()
                    }
                }.lparams(autoSize(48), autoSize(48)){
                    marginStart = autoSize(36)
                }

                emptyView()

                verticalLayout {
                    /** 资金账户选择 **/
                    onThrottleFirstClick {
                        (context as AppCompatActivity).creatSelectAccountDialog{
                            EventBus.getDefault().post(MessageEvent(EventConstent.USERACCOUNTCHANGE))
                        }.show()
                    }
                    textView {
                        text = "交易"
                        textColorInt = R.color.white
                        textSizeAuto = 36
                    }.lparams(wrapContent, wrapContent) {
                        gravity = Gravity.CENTER_HORIZONTAL
                    }
                    textView {
                        text = "张三（100000）"
                        textColorStr = "#AED6F0"
                        textSizeAuto = 29
                    }.lparams(wrapContent, wrapContent) {
                        gravity = Gravity.CENTER_HORIZONTAL
                    }
                }.lparams(wrapContent, autoSize(90))

                emptyView()

                view {

                }.lparams(autoSize(48), autoSize(48)){
                    marginEnd = autoSize(36)
                }
            }.lparams(matchParent, autoSize(120))
        }
    }



}