package com.adealink.weparty.profile.dialog

import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.adealink.frame.base.fastLazy
import com.adealink.frame.mvvm.view.viewBinding
import com.adealink.frame.util.onClick
import com.adealink.weparty.commonui.recycleview.adapter.MultiTypeListAdapter
import com.adealink.weparty.commonui.widget.BottomDialogFragment
import com.adealink.weparty.profile.R
import com.adealink.weparty.profile.databinding.DialogCreateOrderBinding
import com.adealink.weparty.profile.dialog.adapter.OrderGoodItemViewBinder
import com.adealink.weparty.profile.dialog.data.OrderGoodItemData
import com.adealink.weparty.profile.dialog.data.OrderItemData

class CreateOrderDialog : BottomDialogFragment(R.layout.dialog_create_order) {
    private val binding by viewBinding(DialogCreateOrderBinding::bind)

    private val listAdapter by fastLazy { MultiTypeListAdapter<OrderGoodItemData>() }
    override fun initViews() {
        super.initViews()
        listAdapter.register(OrderGoodItemViewBinder())
        binding.rvGoods.adapter = listAdapter
        binding.rvGoods.layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false)
        binding.btnOrder.onClick {

        }
    }

    override fun loadData() {
        super.loadData()
        listAdapter.submitList(
            listOf(
                OrderGoodItemData(OrderItemData("")),
                OrderGoodItemData(OrderItemData("")),
                OrderGoodItemData(OrderItemData("")),
            )
        )
    }

    private fun createOrder() {

    }

}