-
Notifications
You must be signed in to change notification settings - Fork 0
ToastController Object
The ToastController object is a globally available object that helps to spawn Toast instances. It has a few basic utility methods, as well as configurable settings.
Creates and opens a new Toast based on the set parameters, and returns an instance of the Toast object created.
- [
name
| String]: name of the new Toast; used to reference the Toast later - [
text
| String]: text to display inside the Toast - [
icon
| String]: (optional) name of icon to add to Toast; by default uses Google Material Icons. Requires you to import the Material Icons font - [
delay
| Integer]: (optional) amount of time, in whole milliseconds, for the Toast to stay on the screen before it closes itself - [
priority
| ToastPriority]: (optional) priority level of the Toast; there are two possible options:ToastPriority.HIGH
orToastPriority.LOW
Example:
ToastController.openToast({
name: "hello.world",
text: "Hello, World!",
delay: 15000, // wait 15 seconds
icon: "done" // checkmark icon
});
Closes an existing Toast (if it exists) via its given name specified on creation. The toastName
is the same name
specified when calling ToastController.openToast()
.
Example:
ToastController.closeToast("hello.world");
Quick alias to open a "success" type Toast. This toast has a green color (configurable in the SASS), and the "done" Material Icon. Has a priority of ToastPriority.LOW
.
Example:
ToastController.success("Hello, World!");
Quick alias to open an "error" type Toast. This toast has a red color (configurable in the SASS), and the "error" Material Icon. Has a priority of ToastPriority.HIGH
.
Example:
ToastController.error("Hello, World!");
Quick alias to open a "warning" type Toast. This toast has a yellow color (configurable in the SASS), and the "warning" Material Icon. Has a priority of ToastPriority.HIGH
.
Example:
ToastController.warn("Hello, World!");
Type: String
Default: "material-icons"
You can configure the base icon set that the ToastController uses by setting the set's base class using this property. To understand better how the ToastController generates icons, it uses the iconBase
as the class for the icon, and the icon name (specified when creating a toast) as the contents of the icon DOM element:
<i class="icon [ToastController.iconBase]">[icon name]</i>
Example:
ToastController.iconBase = "fa";