package cn.muchinfo.rma.view.base.chart;

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.widget.ImageView
import android.widget.TextView
import androidx.lifecycle.Observer
import cn.muchinfo.rma.R
import cn.muchinfo.rma.view.base.BaseActivity
import org.jetbrains.anko.verticalLayout

/**
 * 图表相关
 */
class ChartActivity : BaseActivity<ChartViewModel>() {

    companion object {
        // 启动页面
        fun start(goodsCode: String?, outGoodsCode: String?, context: Context) {
            val intent = Intent()
            intent.setClass(context, ChartActivity::class.java)
            intent.putExtra("goodsCode", goodsCode)
            intent.putExtra("outGoodsCode", outGoodsCode)
            context.startActivity(intent)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_chart)
        initView()


        viewModel.initData(intent)
        viewModel.initRequest()
    }

    fun initView(){
        findViewById<ImageView>(R.id.back_img).setOnClickListener {
            finish()
        }

        viewModel.goodsInfo.observe(this, Observer {
            findViewById<TextView>(R.id.goods_name_tv).text = it?.goodsname
            findViewById<TextView>(R.id.goods_code_tv).text = it?.goodscode
        })
    }




}
