Class dkb.toast
Class to represent and display Toasts.
Each toast will be displayed according to the provided parameters, and can
be reused. A toast can belong to a group. Each time a toast belonging to a group
is displayed any toast pertaining to that group that is being displayed
will be dismissed.
Uses hs.alert
behind the scenes.
This module returns a func
used to instantiate toasts. See usage in the function below.
Functions
dkb.toast (message, group, duration, params) | Function returned by this module when imported. |
Methods
dkb.toast:dismiss () | Dismiss toast. |
dkb.toast:dismiss_group () | Dismiss any toast pertaining to the provided group |
dkb.toast:show () | Display the toast. |
dkb.toast:set_message (message) | |
dkb.toast:set_duration (duration) | |
dkb.toast:set_params (params) |
Functions
Methods- dkb.toast (message, group, duration, params)
-
Function returned by this module when imported. Used to create Modal instances.
Parameters:
- message string[opt] Text to display.
- group string[opt] Group name.
- duration int[opt] Time the toast will be displayed.
- params
table[opt]
Parameters acccepted by
hs.alert.show
. At the moment the following parameters are accepted:- padding
- fadeInDuration
- fadeOutDuration
Usage:
local Toast = require("dkb.toast") --> Import class -- Instantiate toasts in group main local t1 = Toast("1", "main") local t2 = Toast("2", "main") -- t2 will dismiss t1 and show itself t1.show() t2.show()
Methods
- dkb.toast:dismiss ()
-
Dismiss toast.
Returns:
-
Toast
toast object
- dkb.toast:dismiss_group ()
- Dismiss any toast pertaining to the provided group
- dkb.toast:show ()
-
Display the toast.
Returns:
-
Toast
toast object
- dkb.toast:set_message (message)
-
Parameters:
- message string Message to display
Returns:
-
Toast
toast object
- dkb.toast:set_duration (duration)
-
Parameters:
- duration int
Returns:
-
Toast
toast object
- dkb.toast:set_params (params)
-
Parameters:
Returns:
-
Toast
toast object