package com.quyunshuo.androidbaseframemvvm.common.util

import android.annotation.SuppressLint
import android.util.Log
import android.widget.Toast
import com.hjq.toast.ToastParams
import com.hjq.toast.Toaster
import com.hjq.toast.style.CustomToastStyle
import com.quyunshuo.androidbaseframemvvm.common.R

object ToastUtil {
    private val TAG = "ToastUtil"
    private val mToast: Toast? = null



    @SuppressLint("ShowToast")
    fun showToast(text: String) {
        switchToastStyleToInfo(text)
    }

    fun switchToastStyleToInfo(text: String) {
        val params: ToastParams = ToastParams()
        params.text = text
        params.style = CustomToastStyle(R.layout.toast_info)
        Toaster.show(params)
    }

    fun switchToastStyleToWarn(text: String) {
        val params: ToastParams = ToastParams()
        params.text = text
        params.style = CustomToastStyle(R.layout.toast_warn)
        Toaster.show(params)
    }

    fun switchToastStyleToSuccess(text: String) {
        Log.d(TAG, "switchToastStyleToSuccess: $text")
        val params: ToastParams = ToastParams()
        params.text = text
        params.style = CustomToastStyle(R.layout.toast_success)
        Toaster.show(params)
    }

    fun switchToastStyleToError(text: String) {
        val params: ToastParams = ToastParams()
        params.text = text
        params.style = CustomToastStyle(R.layout.toast_error)
        Toaster.show(params)
    }
}