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

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

/**
 * 资金流水
 */
class CostListFragment(type: String?) : BaseFragment<CostViewModel>() {

    private var type: String? = type

    companion object {
        fun getInstance(type: String?) = CostListFragment(type)
    }

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

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

    private fun initViews() {
        idCostList = _view?.findViewById(R.id.id_cost_list)
        val costList: ArrayList<CostListData>? = ArrayList() // 资金流水
        for (a in 1..10) {
            val temp = CostListData()
            temp.setTime("10:10:$a")
            temp.setOperateType("结算盈亏")
            temp.setAm("10$a")
            costList?.add(temp)
        }
        val layoutManager = LinearLayoutManager(context)
        idCostList?.layoutManager = layoutManager
        viewModel.costList = costList
        idCostList?.adapter = viewModel.getCostListAdapter()
    }
}