package com.guadou.lib_baselib.engine

import android.view.Gravity
import com.guadou.basiclib.R
import com.hjq.toast.ToastUtils
import com.hjq.toast.style.BlackToastStyle


/** toast相关 使用的是ToastUtils库 **/

fun Any.toast(msg: String?) {
    ToastUtils.setStyle(BlackToastStyle())
    ToastUtils.setGravity(Gravity.BOTTOM, 0, 150)
    ToastUtils.show(msg)
}

fun Any.toast(res: Int) {
    ToastUtils.setStyle(BlackToastStyle())
    ToastUtils.setGravity(Gravity.BOTTOM, 0, 150)
    ToastUtils.show(res)
}

fun Any.toastError(msg: String?) {
    ToastUtils.setView(R.layout.custom_toast_failed_view)
    ToastUtils.setGravity(Gravity.CENTER)
    ToastUtils.show(msg)
}

fun Any.toastError(res: Int) {
    ToastUtils.setView(R.layout.custom_toast_failed_view)
    ToastUtils.setGravity(Gravity.CENTER)
    ToastUtils.show(res)
}

fun Any.toastSuccess(msg: String?) {
    ToastUtils.setView(R.layout.custom_toast_success_view)
    ToastUtils.setGravity(Gravity.CENTER)
    ToastUtils.show(msg)
}

fun Any.toastSuccess(res: Int) {
    ToastUtils.setView(R.layout.custom_toast_success_view)
    ToastUtils.setGravity(Gravity.CENTER)
    ToastUtils.show(res)
}

fun Any.cancleToast() {
    ToastUtils.cancel()
}