D3vugu-components/components/navigation/pagination-binder.go

27 lines
1010 B
Go
Raw Normal View History

package navigation
// PaginationBinder is an interface that everything that every type that wants to bind to a pagination component must implement.
type PaginationBinder interface {
PaginationPage() int // Page returns the current page, as a 1-based index. A value of 0 means there is no active page.
PaginationPages() int // Pages returns the total number of pages.
SetPaginationPage(page int) // SetPage changes the current page as a 1-based index. A value of 0 means there is no active page.
}
// PaginationInfo implements the PaginationBinder interface and represents the current state of a pagination component.
type PaginationInfo struct {
Page int // The current page as a 1-based index. A value of 0 means there is no current page.
Pages int // The number of total pages.
}
func (p *PaginationInfo) PaginationPage() int {
return p.Page
}
func (p *PaginationInfo) PaginationPages() int {
return p.Pages
}
func (p *PaginationInfo) SetPaginationPage(page int) {
p.Page = page
}