package com.abbidot.tracker.dialog

import android.content.Context
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.tracker.base.BaseDialog
import com.abbidot.tracker.databinding.DialogListItemLayoutBinding
import com.abbidot.tracker.util.ViewUtil
import com.qmuiteam.qmui.util.QMUIDisplayHelper

/**
 *Created  by .yzq on 2022/1/7/007.
 * @link
 * @description:通用的列表弹窗
 */
class CommonListDialog(
    context: Context,
    adapter: BaseRecyclerAdapter<*>,
    topDP: Int = 0,
    bottomDP: Int = 0,
    itemBottomDP: Int = 0,
    dialogHeightDp: Int = 0
) : BaseDialog<DialogListItemLayoutBinding>(
    DialogListItemLayoutBinding::inflate, context, dialogHeightDp
) {

    private val mAdapter = adapter
    private var mBottom = QMUIDisplayHelper.dpToPx(bottomDP)
    private var mTop = QMUIDisplayHelper.dpToPx(topDP)
    private val mItemBottomDP = QMUIDisplayHelper.dpToPx(itemBottomDP)

    override fun initView() {
        mViewBinding.dialogListRecyclerView.apply {
            if (mTop == 0) mTop = paddingTop
            if (mBottom == 0) mBottom = paddingBottom
            setPadding(paddingLeft, mTop, paddingRight, mBottom)
            ViewUtil.instance.setRecyclerViewVerticalLinearLayout(
                context, this, mAdapter, bottom = mItemBottomDP
            )
        }
    }

}