package com.bc_chat.contacts.view

import android.view.View
import com.bc_chat.contacts.R
import com.bc_chat.contacts.databinding.DialogForbiddenBinding
import com.zhaohaoting.framework.abs.AbsBottomDialogFragment
import com.zhaohaoting.framework.abs.contract.BaseContract

/**
 * Created by zhaoting on 2019/3/2.
 * Desc：禁言
 */
class ForbiddenFragmentDialog : AbsBottomDialogFragment<BaseContract.BasePresenter>() {

    private val binding by lazy {
        rootDataBinding as DialogForbiddenBinding
    }
    private var onClickListener: View.OnClickListener? = null

    override fun initPresenter(): BaseContract.BasePresenter? = null

    override fun getLayoutResId(): Int = R.layout.dialog_forbidden

    override fun initialize() {
        binding.onClickEvent = onClickListener
    }

    fun setForbiddenResultListener(listener: (min: Int) -> Unit) {
        onClickListener = View.OnClickListener { v ->
            when (v?.id) {
                R.id.tv_open -> {
                    listener(0)
                }
                R.id.tv_close_10m -> {
                    listener(10)
                }
                R.id.tv_close_30m -> {
                    listener(30)
                }
                R.id.tv_close_1h -> {
                    listener(60)
                }
                R.id.tv_close_1d -> {
                    listener(60 * 24)
                }
                R.id.tv_close_30d -> {
                    listener(60 * 24 * 30)
                }
                R.id.tv_cancel -> {
                }
            }
            dismissAllowingStateLoss()
        }
    }
}
