2024-03-29 14:30:48 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-05-15 20:41:53 +03:00
|
|
|
"surdeus.su/core/tg"
|
2024-03-29 14:30:48 +03:00
|
|
|
)
|
|
|
|
|
2024-07-21 16:02:47 +03:00
|
|
|
var DynamicPanelWidget = tg.RenderFunc(func(c tg.Context) tg.UI {
|
2024-03-29 14:30:48 +03:00
|
|
|
return tg.UI{
|
2024-07-23 15:05:20 +03:00
|
|
|
tg.Messagef("Paged panel").PanelPager(
|
2024-07-22 18:45:53 +03:00
|
|
|
c, 0, 5,
|
2024-07-25 17:48:02 +03:00
|
|
|
tg.PanelPagerFunc(func(
|
|
|
|
panel *tg.PanelPagerCompo,
|
|
|
|
c tg.Context, page, size int,
|
|
|
|
) tg.PanelPage {
|
2024-07-22 18:45:53 +03:00
|
|
|
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-07-23 15:05:20 +03:00
|
|
|
}),
|
2024-07-22 18:45:53 +03:00
|
|
|
),
|
2024-03-29 14:30:48 +03:00
|
|
|
tg.Messagef("").Reply(
|
|
|
|
BackKeyboard.Reply(),
|
|
|
|
),
|
|
|
|
}
|
|
|
|
})
|