From ef5d084e312451e79705c86a5e385e19d5466afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F=20=D0=9B=D1=8E=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D1=81=D0=BA=D0=B8=D0=B9?= <100635212+lubaskinc0de@users.noreply.github.com> Date: Fri, 29 Dec 2023 21:57:17 +0300 Subject: [PATCH] provide support for ShowMode in SwitchTo and Cancel widgets #350 --- src/aiogram_dialog/widgets/kbd/state.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/aiogram_dialog/widgets/kbd/state.py b/src/aiogram_dialog/widgets/kbd/state.py index fb702008..e3146385 100644 --- a/src/aiogram_dialog/widgets/kbd/state.py +++ b/src/aiogram_dialog/widgets/kbd/state.py @@ -8,6 +8,8 @@ from aiogram_dialog.widgets.common import WhenCondition from aiogram_dialog.widgets.text import Const, Text from aiogram_dialog.widgets.widget_event import WidgetEventProcessor +from aiogram_dialog import ShowMode + from .button import Button, OnClick BACK_TEXT = Const("Back") @@ -41,6 +43,7 @@ def __init__( state: State, on_click: Optional[OnClick] = None, when: WhenCondition = None, + show_mode: ShowMode = None, ): super().__init__( text=text, on_click=self._on_click, @@ -49,6 +52,7 @@ def __init__( self.text = text self.user_on_click = on_click self.state = state + self.show_mode = show_mode async def _on_click( self, callback: CallbackQuery, button: Button, @@ -56,7 +60,7 @@ async def _on_click( ): if self.user_on_click: await self.user_on_click(callback, self, manager) - await manager.switch_to(self.state) + await manager.switch_to(self.state, show_mode=self.show_mode) class Next(EventProcessorButton): @@ -117,6 +121,7 @@ def __init__( result: Any = None, on_click: Optional[OnClick] = None, when: WhenCondition = None, + show_mode: ShowMode = None, ): super().__init__( text=text, on_click=self._on_click, @@ -125,6 +130,7 @@ def __init__( self.text = text self.result = result self.user_on_click = on_click + self.show_mode = show_mode async def _on_click( self, callback: CallbackQuery, button: Button, @@ -132,7 +138,7 @@ async def _on_click( ): if self.user_on_click: await self.user_on_click(callback, self, manager) - await manager.done(self.result) + await manager.done(self.result, show_mode=self.show_mode) class Start(EventProcessorButton):