add profile dialog

This commit is contained in:
2025-09-25 20:48:39 +03:00
parent 8c801eb66e
commit cbe1919343
12 changed files with 117 additions and 14 deletions

View File

@@ -1,6 +1,8 @@
from aiogram import Router
from .start.dialogs import start_dialog
from .profile.dialogs import user_profile_dialog
from .start.dialogs import user_start_dialog
user_router = Router(name="user")
user_router.include_router(start_dialog)
user_router = Router(name="user dialogs")
user_router.include_router(user_start_dialog)
user_router.include_router(user_profile_dialog)

View File

@@ -0,0 +1,38 @@
from aiogram_dialog import Dialog, Window
from aiogram_dialog.widgets.input import TextInput
from aiogram_dialog.widgets.kbd import Back, Cancel, SwitchTo
from aiogram_dialog.widgets.text import Const, Format
from .states import UserProfileSG
user_profile_dialog = Dialog(
Window(
Const("*Профиль*"),
Format("Имя:"),
Format("Телефон:"),
SwitchTo(
Const("изменить имя"),
id="change_name",
state=UserProfileSG.change_name,
),
SwitchTo(
Const("изменить телефон"),
id="change_phone",
state=UserProfileSG.change_phone,
),
Cancel(Const("назад")),
state=UserProfileSG.profile,
),
Window(
Const("Введите имя"),
SwitchTo(Const("отмена"), id="go_profile", state=UserProfileSG.profile),
TextInput(id="name_input"),
state=UserProfileSG.change_name,
),
Window(
Const("Введите телефон"),
SwitchTo(Const("отмена"), id="go_profile", state=UserProfileSG.profile),
TextInput(id="phone_input"),
state=UserProfileSG.change_phone,
),
)

View File

@@ -0,0 +1,9 @@
from aiogram.fsm.state import State, StatesGroup
class UserProfileSG(StatesGroup):
profile = State()
change_name = State()
input_name = State()
change_phone = State()
change_phone = State()

View File

@@ -1,14 +1,18 @@
from aiogram_dialog import Dialog, Window
from aiogram_dialog.widgets.text import Format
from aiogram_dialog.widgets.kbd import Button, Start
from aiogram_dialog.widgets.text import Const, Format
from app.bot.dialogs.flows.user.profile.dialogs import UserProfileSG
from app.bot.dialogs.widgets.getters import username_getter
from .states import StartSG
from .states import UserStartSG
start_dialog = Dialog(
user_start_dialog = Dialog(
Window(
Format("Hello, {username}"),
Button(Const("События"), id="events"),
Start(Const("Профиль"), id="profile", state=UserProfileSG.profile),
getter=username_getter,
state=StartSG.start,
state=UserStartSG.start,
)
)

View File

@@ -1,5 +1,5 @@
from aiogram.fsm.state import State, StatesGroup
class StartSG(StatesGroup):
class UserStartSG(StatesGroup):
start = State()