package com.kaixed.kchat.utils

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.Gravity
import android.view.LayoutInflater
import android.view.Window
import android.view.WindowManager
import com.kaixed.kchat.databinding.DialogDeleteContactBinding
import com.kaixed.kchat.databinding.DialogLoadingBinding
import com.kaixed.kchat.utils.DensityUtil.dpToPx

/**
 * @Author: kaixed
 * @Date: 2024/11/5 21:26
 */
object WidgetUtil {
    fun showLoadingDialog(context: Context, str: String): Dialog {
        val binding = DialogLoadingBinding.inflate(LayoutInflater.from(context))
        val dialog = Dialog(context)
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
        dialog.setCancelable(false)
        dialog.setContentView(binding.root)
        dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        val params = binding.root.layoutParams
        params.height = dpToPx(150)
        params.width = dpToPx(150)
        binding.root.layoutParams = params
        binding.tvLoading.text = str
        return dialog
    }
}