state.go 834 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package views
  2. import (
  3. "fyne.io/fyne/v2"
  4. )
  5. var (
  6. // Views - the map of all the view components
  7. views = make(map[string]fyne.CanvasObject)
  8. )
  9. const (
  10. Networks = "networks"
  11. NetDetails = "netdetails"
  12. Notify = "notification"
  13. Join = "join"
  14. Confirm = "confirm"
  15. )
  16. // GetView - returns the requested view and sets the CurrentView state
  17. func GetView(viewName string) fyne.CanvasObject {
  18. return views[viewName]
  19. }
  20. // SetView - sets a view in the views map
  21. func SetView(viewName string, component fyne.CanvasObject) {
  22. views[viewName] = component
  23. }
  24. // HideView - hides a specific view
  25. func HideView(viewName string) {
  26. views[viewName].Hide()
  27. }
  28. // ShowView - show's a specific view
  29. func ShowView(viewName string) {
  30. for k := range views {
  31. if k == Notify {
  32. continue
  33. }
  34. HideView(k)
  35. }
  36. views[viewName].Show()
  37. }