inline-keyboard-pagination icon indicating copy to clipboard operation
inline-keyboard-pagination copied to clipboard

Redesign Paginator

Open mehrdadkhoddami opened this issue 8 years ago • 4 comments

  • Reformat generateButton to get label
  • define Offset for range
  • Refactor generateRange to have better algorithm and consider Offsets
  • Refactor generateKeyboard to work with this new solution
  • Add optional setMaxPageBasedOnLabels to generate max_page according to labels

mehrdadkhoddami avatar Oct 15 '17 19:10 mehrdadkhoddami

Hi, thanks for your contribution.

Please make sure you adhere to the PSR-2 guidelines, in your case 4 spaces instead of tabs.

Then I can take a look and see what your actual addition is 👍

noplanman avatar Oct 15 '17 19:10 noplanman

Hi, Sure

Notes with thanks. I reformat file with PSR-2 . But I didn't change tests.

mehrdadkhoddami avatar Oct 15 '17 20:10 mehrdadkhoddami

I can have a look at the tests and see what's up.

Before that though, could you please explain in more depth what this PR does exactly? Best show some examples of what is new / changed.

Thanks!

noplanman avatar Oct 16 '17 08:10 noplanman

Sure.

  • First of all, I add a range for selected page. e.g if we have 9 pages, selected page is 6 & range for it was set 1, in the pagination, user can see 5 & 7 (default is 1 as range). img In this case, I rewrite generateRange() method.

  • Also, User can pass only labels which he/she wants. (Same as before) but now user can call setMaxPageBasedOnLabels() method to set $max_buttons according to passed labels & and range of selected page.

  • I changed generateButton() to get label of button.

  • I added two conditions to setSelectedPage() :

  1. If user requests negative or zero page number, method sets it to page #1 automatically.
  2. If user requests page which is greater than total number of pages, method sets it to total number of pages automatically.
  • Finally I refactor generateKeyboard() based on these changes.

Thank you.

mehrdadkhoddami avatar Oct 16 '17 23:10 mehrdadkhoddami