flow-components icon indicating copy to clipboard operation
flow-components copied to clipboard

Add Notification convenience methods

Open simasch opened this issue 11 months ago • 3 comments

The Notification.show method is very limited and I always have to add a custom Notification class with methods like success, error, warning etc.

And there I do

Notification notification = new Notification("The requested employee was not found", 3000, Notification.Position.TOP_END);
notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
notification.open();

It would be great if the Notification class could already have those methods.

simasch avatar Jan 22 '25 09:01 simasch

Notification are a good example for a builder pattern IMHO. I've created my own NotificationBuilder for our applications where I can specificy globally (based on type (success / error and so on)) timeout, styles and "closeability" so that only the type and content has to be specified.

knoobie avatar Jan 22 '25 09:01 knoobie

Indeed, but the builder would not solve my problem.

It should support both, a builder and default static methods for info, success, warning, and error.

simasch avatar Jan 22 '25 09:01 simasch

Likewise, I had created a Builder for notifications, but in the end, I created another simple one for the ConfirmDialog with pattern builder as well...

I have created something not so perfect, but it works for the moment...

I also agree, show info, warning etc...

  • https://github.com/rucko24/EspFlow/blob/main/src/main/java/com/esp/espflow/util/ConfirmDialogBuilder.java#L44

rucko24 avatar Jan 22 '25 09:01 rucko24