package com.miya.fastcashier.ui.dialog import android.app.AlertDialog import android.app.Dialog import android.content.Context import android.view.Gravity import android.view.WindowManager import android.widget.ImageButton import android.widget.ImageView import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import com.miya.fastcashier.R import com.miya.fastcashier.utils.StringPriceFormat import com.miya.fastcashier.utils.clickWithTrigger import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse /** * 退款信息弹窗 */ class RefundInfoDialog(context: Context) : Dialog(context) { private lateinit var ivClose: ImageView private lateinit var tvRefund: TextView private lateinit var tvPrice: TextView private lateinit var payServiceResponse: PayServiceResponse init { initWindow() initConfig() initView() } private fun initConfig() { setCancelable(false) } private fun initView() { setContentView(R.layout.dialog_refund_info) ivClose = findViewById(R.id.ivClose) ivClose.clickWithTrigger { dismiss() } tvRefund = findViewById(R.id.tvRefund) tvPrice = findViewById(R.id.tvPrice) } fun setData(payServiceResponse: PayServiceResponse, action: (PayServiceResponse) -> Unit) { this.payServiceResponse = payServiceResponse tvPrice.text = "¥${StringPriceFormat.transStringPriceToDecimalString(payServiceResponse.tradPrice)}" tvRefund.clickWithTrigger { action.invoke(payServiceResponse) } } private fun initWindow() { val win = this.window win!!.decorView.setPadding(0, 0, 0, 0) val lp = win.attributes lp.width = WindowManager.LayoutParams.MATCH_PARENT lp.height = WindowManager.LayoutParams.WRAP_CONTENT lp.gravity = Gravity.BOTTOM lp.windowAnimations = R.style.BottomInAndOutStyle win.attributes = lp win.setBackgroundDrawableResource(R.color.transparent) } }