You've already forked Travel-Agent
chore: Global project refactoring
This commit is contained in:
+36
-32
@@ -1,4 +1,4 @@
|
||||
__all__ = ("sex_keyboard",)
|
||||
__all__ = ("sex_keyboard", "travels_keyboard")
|
||||
|
||||
from aiogram.types import InlineKeyboardButton
|
||||
from aiogram.utils.keyboard import InlineKeyboardBuilder, ReplyKeyboardBuilder
|
||||
@@ -10,9 +10,9 @@ def sex_keyboard(choices: str | list):
|
||||
builder = ReplyKeyboardBuilder()
|
||||
|
||||
if isinstance(choices, str):
|
||||
text = [choices]
|
||||
choices = [choices]
|
||||
|
||||
[builder.button(text=txt) for txt in text]
|
||||
[builder.button(text=choice) for choice in choices]
|
||||
return builder.as_markup(resize_keyboard=True)
|
||||
|
||||
|
||||
@@ -36,41 +36,45 @@ def travels_keyboard(travels: list, page: int, pages: int):
|
||||
|
||||
builder.row(*rows, width=2)
|
||||
|
||||
if pages > 1:
|
||||
navigation_row = []
|
||||
|
||||
if page > 0:
|
||||
navigation_row.append(
|
||||
InlineKeyboardButton(
|
||||
text="⬅️", callback_data=f"travels_page_{page - 1}",
|
||||
),
|
||||
)
|
||||
else:
|
||||
navigation_row.append(
|
||||
InlineKeyboardButton(
|
||||
text=" ", callback_data="pass",
|
||||
),
|
||||
)
|
||||
navigation_row = []
|
||||
|
||||
if page > 0:
|
||||
navigation_row.append(
|
||||
InlineKeyboardButton(
|
||||
text=f"{page + 1}/{pages}", callback_data="pass",
|
||||
text="⬅️",
|
||||
callback_data=f"travels_page_{page - 1}",
|
||||
),
|
||||
)
|
||||
else:
|
||||
navigation_row.append(
|
||||
InlineKeyboardButton(
|
||||
text=" ",
|
||||
callback_data="pass",
|
||||
),
|
||||
)
|
||||
|
||||
if page < pages - 1:
|
||||
navigation_row.append(
|
||||
InlineKeyboardButton(
|
||||
text="➡️", callback_data=f"travels_page_{page + 1}",
|
||||
),
|
||||
)
|
||||
else:
|
||||
navigation_row.append(
|
||||
InlineKeyboardButton(
|
||||
text=" ", callback_data="pass",
|
||||
),
|
||||
)
|
||||
navigation_row.append(
|
||||
InlineKeyboardButton(
|
||||
text=f"{page + 1}/{pages}",
|
||||
callback_data="pass",
|
||||
),
|
||||
)
|
||||
|
||||
builder.row(*navigation_row)
|
||||
if page < pages - 1:
|
||||
navigation_row.append(
|
||||
InlineKeyboardButton(
|
||||
text="➡️",
|
||||
callback_data=f"travels_page_{page + 1}",
|
||||
),
|
||||
)
|
||||
else:
|
||||
navigation_row.append(
|
||||
InlineKeyboardButton(
|
||||
text=" ",
|
||||
callback_data="pass",
|
||||
),
|
||||
)
|
||||
|
||||
builder.row(*navigation_row)
|
||||
|
||||
return builder.as_markup()
|
||||
|
||||
Reference in New Issue
Block a user