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

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import cn.muchinfo.rma.R
import cn.muchinfo.rma.view.base.BaseFragment
import cn.muchinfo.rma.view.base.future.entrusts.EntrustData

/**
 * 成交单
 */
class DealFragment : BaseFragment<DealViewModel>() {

    companion object {
        fun getInstance() = DealFragment()
    }

    private var _view: View? = null
    private var idDealList: RecyclerView? = null


    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        _view = inflater.inflate(R.layout.deal_fragment, container, false)
        initViews()
        return _view
    }

    private fun initViews() {
        idDealList = _view?.findViewById(R.id.id_deal_list)
        val list: ArrayList<DealData>? = ArrayList()
        for (a in 1..5) {
            val m = DealData()
            m.goodsName = "铁矿石" + (2105 + a)
            m.dealNum = 10.0 + a
            m.dealPrice = 188.0 + a
            m.dealTime = "2021-02-25 21:21:21"
            m.direction = a
            m.goodsId = a
            list?.add(m)
        }

        val layoutManager = LinearLayoutManager(context)
        idDealList?.layoutManager = layoutManager
        viewModel.list = list
        idDealList?.adapter = viewModel.getAdapter()
    }
}