2024-03-28 10:41:09 +03:00
|
|
|
package tg
|
|
|
|
|
2024-07-21 16:02:47 +03:00
|
|
|
func Go(pth Widget) UI {
|
2024-03-28 10:41:09 +03:00
|
|
|
return UI{
|
2024-07-21 16:02:47 +03:00
|
|
|
WidgetGo{
|
|
|
|
Path: pth,
|
|
|
|
},
|
2024-03-28 10:41:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-21 16:02:47 +03:00
|
|
|
// The type implements changing current path to the widget.
|
|
|
|
type WidgetGo struct {
|
|
|
|
Path Widget
|
|
|
|
Arg any
|
|
|
|
}
|
|
|
|
|
2024-07-23 15:41:31 +03:00
|
|
|
func (w WidgetGo) Act(c Context) {
|
|
|
|
c.WithArg(w.Arg).Go(w.Path)
|
2024-07-21 16:02:47 +03:00
|
|
|
}
|
|
|
|
|
2024-03-28 10:41:09 +03:00
|
|
|
// Implementing the Server interface.
|
2024-07-21 16:02:47 +03:00
|
|
|
func (widget WidgetGo) Serve(c Context) {
|
2024-03-28 10:41:09 +03:00
|
|
|
c.input.Close()
|
2024-07-23 16:08:39 +03:00
|
|
|
c.WithArg(widget.Path).Go(widget.Path)
|
2024-03-28 10:41:09 +03:00
|
|
|
}
|
|
|
|
|
2024-07-21 16:02:47 +03:00
|
|
|
func (widget WidgetGo) Render(c Context) UI {
|
2024-03-28 10:41:09 +03:00
|
|
|
return UI{widget}
|
|
|
|
}
|
|
|
|
|
2024-07-21 16:02:47 +03:00
|
|
|
func (widget WidgetGo) Filter(u Update) bool {
|
2024-03-28 10:41:09 +03:00
|
|
|
return true
|
|
|
|
}
|