tg/cmd/test/panel.go

36 lines
752 B
Go
Raw Normal View History

2024-03-29 14:30:48 +03:00
package main
import (
"surdeus.su/core/tg"
2024-03-29 14:30:48 +03:00
)
var DynamicPanelWidget = tg.RenderFunc(func(c tg.Context) tg.UI {
2024-03-29 14:30:48 +03:00
return tg.UI{
tg.Messagef("Paged panel").PanelPager(
c, 0, 5,
tg.PanelPagerFunc(func(c tg.Context, page, size int) tg.PanelPage {
rows := []tg.ButtonRow{}
for i := 0; i < size; i++ {
num := 1 + page*size + i
rows = append(rows, tg.ButtonRow{
tg.Buttonf("%d", num).Rand().WithAction(tg.Func(func(c tg.Context) {
_, err := c.Sendf("%d", num*num)
if err != nil {
}
})),
tg.Buttonf("%d", num*num),
})
}
return tg.PanelPage{
Rows: rows,
Next: page < 3,
Prev: page != 0,
}
}),
),
2024-03-29 14:30:48 +03:00
tg.Messagef("").Reply(
BackKeyboard.Reply(),
),
}
})