package com.swago.baseswago.dialog

import android.os.Bundle
import com.swago.baseswago.R
import com.swago.baseswago.databinding.DialogOrderLostBinding
import com.swago.baseswago.util.AppContext
import com.swago.baseswago.util.NoDoubleClickListener

/**
 *@date 2021/12/12 16:08
 *description:掉单弹窗
 */
class OrderLostDialog : BaseXDFragment<DialogOrderLostBinding>() {

    private var orderId:String = ""
    var commitLostOrderFun:(()->Unit)? = null

    init {
        setCanCancel(false)
    }

    companion object{
        fun newInstance(orderId:String):OrderLostDialog{
            val dialog = OrderLostDialog()
            val bundle = Bundle()
            bundle.putString("orderId",orderId)
            dialog.arguments = bundle
            return dialog
        }
    }

    override fun initOther() {
        arguments?.let {
            orderId =  it.getString("orderId","")
            if (orderId.isNotEmpty()){
                binding.tvContent.text = AppContext.getContext().resources.getString(R.string.consume_order).format(orderId)
            }
        }


        binding.tvConsume.setOnClickListener(object:NoDoubleClickListener(){
            override fun onClick() {
                commitLostOrderFun?.invoke()
            }
        })

    }

    override fun initLiveData() {

    }


}