package com.doverfuelingsolutions.issp.utils

import android.app.Application
import android.graphics.Color
import android.view.Gravity
import androidx.annotation.StringRes
import com.doverfuelingsolutions.issp.R
import com.hjq.toast.IToastStyle
import com.hjq.toast.ToastUtils

class DFSToastUtil {

    companion object {

        fun init(app: Application) {
            ToastUtils.init(app)
            ToastUtils.initStyle(object : IToastStyle {
                override fun getGravity() = Gravity.CENTER
                override fun getXOffset() = 0
                override fun getYOffset() = 0
                override fun getZ() = 8
                override fun getCornerRadius() = 8
                override fun getBackgroundColor() = Color.parseColor("#cc000000")
                override fun getTextColor() = Color.WHITE
                override fun getTextSize() = 32f
                override fun getMaxLines() = 8
                override fun getPaddingStart() = 40
                override fun getPaddingTop() = 10
                override fun getPaddingEnd() = 40
                override fun getPaddingBottom() = 10
            })
        }

        fun success(@StringRes string: Int) = success(StringUtil.get(string))
        fun success(msg: String) = ToastUtils.show(StringUtil.get(R.string.toastSuccess, msg))

        fun fail(@StringRes string: Int) = fail(StringUtil.get(string))
        fun fail(msg: String) = ToastUtils.show(StringUtil.get(R.string.toastFail, msg))

        fun info(@StringRes string: Int) = info(StringUtil.get(string))
        fun info(msg: String) = ToastUtils.show(StringUtil.get(R.string.toastInfo, msg))

        fun warn(@StringRes string: Int) = warn(StringUtil.get(string))
        fun warn(msg: String) = ToastUtils.show(StringUtil.get(R.string.toastWarn, msg))
    }
}