package main import ( "vultras.su/core/tg" ) const ( PanelPath tg.Path = "panel" ) var PanelWidget = tg.RenderFunc(func(c tg.Context) tg.UI { var ( n = 0 ln = 4 panel *tg.PanelCompo ) panel = tg.Messagef( "Some panel", ).Panel(c, tg.RowserFunc(func(c tg.Context) []tg.ButtonRow { btns := []tg.ButtonRow{ tg.ButtonRow{tg.Buttonf("Page %d", n)}, } for i := 0; i < ln; i++ { num := 1 + n*ln + i btns = append(btns, 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), }) } btns = append(btns, tg.ButtonRow{ tg.Buttonf("Prev").WithAction(tg.Func(func(c tg.Context) { n-- panel.Update(c) })), tg.Buttonf("Next").WithAction(tg.Func(func(c tg.Context) { n++ panel.Update(c) })), }) return btns })) return tg.UI{ panel, tg.Messagef("").Reply( BackKeyboard.Reply(), ), } })