2023-09-25 23:43:22 +03:00
|
|
|
package tg
|
|
|
|
|
2023-09-26 17:13:31 +03:00
|
|
|
// The type describes dynamic screen widget
|
|
|
|
// That can have multiple UI components.
|
2023-09-25 23:43:22 +03:00
|
|
|
type Widget interface {
|
2024-03-29 14:30:48 +03:00
|
|
|
Render(Context) UI
|
2023-09-25 23:43:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 {
|
2023-09-25 23:43:22 +03:00
|
|
|
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
|
|
|
|
|
2023-09-25 23:43:22 +03:00
|
|
|
// 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.
|
2023-09-25 23:43:22 +03:00
|
|
|
|
|
|
|
Filterer
|
|
|
|
Server
|
|
|
|
}
|
|
|
|
|