refactor + fix добавление проекта
This commit is contained in:
21
tg_bot/screens/ui/buttons.go
Normal file
21
tg_bot/screens/ui/buttons.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package ui
|
||||
|
||||
import "github.com/NicoNex/echotron/v3"
|
||||
|
||||
// BuildGrid builds button rows from items using a callback builder.
|
||||
func BuildGrid[T any](items []T, itemsPerRow, itemsPerPage, totalPages int, itemFn func(T) (title string, callback string)) [][]echotron.InlineKeyboardButton {
|
||||
if len(items) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
buttons := make([]echotron.InlineKeyboardButton, 0, len(items))
|
||||
for _, item := range items {
|
||||
title, callback := itemFn(item)
|
||||
buttons = append(buttons, echotron.InlineKeyboardButton{
|
||||
Text: title,
|
||||
CallbackData: callback,
|
||||
})
|
||||
}
|
||||
|
||||
return BuildPageRows(buttons, itemsPerRow, itemsPerPage, totalPages)
|
||||
}
|
||||
Reference in New Issue
Block a user