2023-05-29 12:23:37 +00:00
|
|
|
package navigation
|
|
|
|
|
2023-05-29 12:32:25 +00:00
|
|
|
// PaginationBinder is an interface that everything that every type that wants to bind to a pagination component must implement.
|
2023-05-29 12:23:37 +00:00
|
|
|
type PaginationBinder interface {
|
2023-05-29 12:32:25 +00:00
|
|
|
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.
|
2023-05-29 12:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// PaginationInfo implements the PaginationBinder interface and represents the current state of a pagination component.
|
|
|
|
type PaginationInfo struct {
|
2023-05-29 12:32:25 +00:00
|
|
|
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.
|
2023-05-29 12:23:37 +00:00
|
|
|
}
|
|
|
|
|
2023-05-29 12:32:25 +00:00
|
|
|
func (p *PaginationInfo) PaginationPage() int {
|
|
|
|
return p.Page
|
2023-05-29 12:23:37 +00:00
|
|
|
}
|
|
|
|
|
2023-05-29 12:32:25 +00:00
|
|
|
func (p *PaginationInfo) PaginationPages() int {
|
|
|
|
return p.Pages
|
2023-05-29 12:23:37 +00:00
|
|
|
}
|
|
|
|
|
2023-05-29 12:32:25 +00:00
|
|
|
func (p *PaginationInfo) SetPaginationPage(page int) {
|
|
|
|
p.Page = page
|
2023-05-29 12:23:37 +00:00
|
|
|
}
|