ToastUtils.ets 573 Bytes
import prompt from '@ohos.promptAction'

export class ToastUtils {
  private static longToastTime: number = 3000
  private static shortToastTime: number = 1000

  static showToast(message: ResourceStr, duration: number) {
    prompt.showToast({ message: message, duration: duration, alignment: Alignment.Center })
  }

  static shortToast(message: ResourceStr) {
    ToastUtils.showToast(message, ToastUtils.shortToastTime)
  }

  static longToast(message: ResourceStr) {
    ToastUtils.showToast(message, ToastUtils.longToastTime)
  }
}

// export default new ToastUtils()