chore: Global project refactoring

This commit is contained in:
ITQ
2024-03-23 10:47:39 +03:00
parent 1802ce81b0
commit 7b28635f09
21 changed files with 143 additions and 116 deletions
+36 -32
View File
@@ -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()