tg/ui.go

31 lines
695 B
Go
Raw Normal View History

package tg
2023-09-26 17:13:31 +03:00
// The type describes dynamic screen widget
// That can have multiple UI components.
type Widget interface {
2024-03-29 14:30:48 +03:00
Render(Context) UI
}
// The way to describe custom function based Widgets.
2024-03-29 14:30:48 +03:00
type RenderFunc func(c Context) UI
func (fn RenderFunc) Render(c Context) UI {
return fn(c)
}
2023-09-26 17:13:31 +03:00
// The type that represents endpoint user interface
// via set of components that will work on the same screen
// in the same time.
type UI []Component
// The type describes interfaces
// needed to be implemented to be endpoint handlers.
2023-09-26 17:13:31 +03:00
type Component interface {
// Optionaly component can implement the
// Renderable interface to automaticaly be sent to the
// user side.
Filterer
Server
}