notification.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package views
  2. import (
  3. "image/color"
  4. "fyne.io/fyne/v2"
  5. "github.com/gravitl/netmaker/netclient/gui/components"
  6. )
  7. // GenerateNotification - generates a notification
  8. func GenerateNotification(text string, c color.Color) fyne.CanvasObject {
  9. return components.ColoredText(text, c)
  10. }
  11. // ChangeNotification - changes the current notification in the view
  12. func ChangeNotification(text string, c color.Color) {
  13. RefreshComponent(Notify, GenerateNotification(text, c))
  14. }
  15. // ClearNotification - hides the notifications
  16. func ClearNotification() {
  17. RefreshComponent(Notify, GenerateNotification("", color.Transparent))
  18. }
  19. // LoadingNotify - changes notification to loading...
  20. func LoadingNotify() {
  21. RefreshComponent(Notify, GenerateNotification("loading...", components.Blue_color))
  22. }
  23. // ErrorNotify - changes notification to a specified error
  24. func ErrorNotify(msg string) {
  25. RefreshComponent(Notify, GenerateNotification(msg, components.Danger_color))
  26. }
  27. // SuccessNotify - changes notification to a specified success message
  28. func SuccessNotify(msg string) {
  29. RefreshComponent(Notify, GenerateNotification(msg, components.Gravitl_color))
  30. }