ui.go 698 B

123456789101112131415161718192021222324252627282930
  1. package tg
  2. // The type describes dynamic screen widget
  3. // That can have multiple UI components.
  4. type Widget interface {
  5. Render(*Context) UI
  6. }
  7. // The way to describe custom function based Widgets.
  8. type RenderFunc func(c *Context) UI
  9. func (fn RenderFunc) Render(c *Context) UI {
  10. return fn(c)
  11. }
  12. // The type that represents endpoint user interface
  13. // via set of components that will work on the same screen
  14. // in the same time.
  15. type UI []Component
  16. // The type describes interfaces
  17. // needed to be implemented to be endpoint handlers.
  18. type Component interface {
  19. // Optionaly component can implement the
  20. // Renderable interface to automaticaly be sent to the
  21. // user side.
  22. Filterer
  23. Server
  24. }