package com.dumpster.cleaner.ui.views

import android.app.AlertDialog
import android.content.Context
import android.text.method.ScrollingMovementMethod
import android.view.LayoutInflater
import com.dumpster.cleaner.databinding.DialogLogContentBinding

object LogDialog {

    fun Context.showLogDialog(log: String) {
        val dialog = AlertDialog.Builder(this).create()
        val binding = DialogLogContentBinding.inflate(LayoutInflater.from(this))
        dialog.setView(binding.root)
        dialog.setCanceledOnTouchOutside(true)

        dialog.show()

        val params = dialog.window?.attributes
//        params?.width = resources.getDimensionPixelOffset(R.dimen.dp_320)
//        params?.height = LinearLayout.LayoutParams.WRAP_CONTENT
//        params?.gravity = Gravity.BOTTOM
//        params?.y = 50

        dialog.window?.attributes = params
        dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)

        binding.tvLog.movementMethod = ScrollingMovementMethod()
        binding.tvLog.text = log
    }
}