ToastNotification - Toasts with IDs & Event

ToastNotification provides features to display short and long duration Toasts with customizable IDs and messages. Additionally, it includes an event that fires when a Toast is displayed, allowing developers to take actions in response to displayed Toast notifications.


Code Explanation:


component_method (1)

component_method

  • Show Toast Functions:
    • ShowShortToast(int id, String message): Displays a short duration Toast with the specified message and dispatches the ToastShown event with the id and message.
    • ShowLongToast(int id, String message): Displays a long duration Toast with the specified message and dispatches the ToastShown event with the id and message.

  • Internal showToast Method:
    • showToast(int id, String message, int duration): Private method that displays the Toast with the specified message and duration, then dispatches the ToastShown event.

component_event

  • ToastShown Event:
    • ToastShown(int id, String message): Event that triggers when a Toast is shown, providing the id and message as parameters.

component_set_get

component_set_get (1)

  • Id Property:
    • Id(): Getter method to retrieve the current id.
    • Id(int id): Setter method to set the id for the notification.

### Video Example


Extension
ToastNotification.aix (6.0 KB)

Thanks.

5 Likes

Thank you very much for sharing! very good work

1 Like

Thank You so much @Gabriel_Egea