-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from vlkorsakov/update_docs
Add docs for ShowMode, Toggle widget and some micro changes
- Loading branch information
Showing
9 changed files
with
126 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
async def open_next_window(event, widget, manager: DialogManager): | ||
manager.show_mode = ShowMode.SEND | ||
await manager.next() | ||
|
||
|
||
async def switch_to_another_window(event, widget, manager: DialogManager): | ||
await manager.switch_to( | ||
state=SomeStatesSG.SomeState, | ||
show_mode=ShowMode.SEND, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
How are messages updated | ||
===================== | ||
|
||
ShowMode | ||
******************** | ||
|
||
Currently, to manage the update of the dialog, we use the feature called ShowMode. | ||
|
||
When we need to change show mode we can just use show_mode setter on DialogManager or pass it in DialogManager methods (.start, .update, .switch_to, etc.) | ||
|
||
.. literalinclude:: ./example.py | ||
|
||
.. important:: | ||
|
||
ShowMode changes only for the next update and then returns to AUTO mode. | ||
|
||
.. autoclass:: aiogram_dialog.api.entities.modes.ShowMode(Enum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@dataclass | ||
class Fruit: | ||
id: str | ||
name: str | ||
emoji: str | ||
|
||
|
||
async def get_fruits(**kwargs): | ||
return { | ||
"fruits": [ | ||
Fruit("apple_a", "Apple", "🍏"), | ||
Fruit("banana_b", "Banana", "🍌"), | ||
Fruit("orange_o", "Orange", "🍊"), | ||
Fruit("pear_p", "Pear", "🍐"), | ||
], | ||
} | ||
|
||
|
||
dialog = Dialog( | ||
Window( | ||
Const("Toggle widget"), | ||
Toggle( | ||
Format("{item.emoji} {item.name}"), | ||
id="radio", | ||
items="fruits", | ||
item_id_getter=lambda fruit: fruit.id, | ||
), | ||
state=ToggleExampleSG.START, | ||
getter=get_fruits, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.. _toggle: | ||
|
||
Toggle | ||
************* | ||
|
||
**Toggle** is a button that switches between elements when clicked. Works like a :ref:`Radio<radio>`. | ||
|
||
Code example: | ||
|
||
.. literalinclude:: ./example.py | ||
|
||
Result: | ||
|
||
.. image:: /resources/toggle.gif | ||
|
||
Classes | ||
=========== | ||
|
||
.. autoclass:: aiogram_dialog.widgets.kbd.select.OnItemStateChanged | ||
:special-members: __call__ | ||
|
||
.. autoclass:: aiogram_dialog.widgets.kbd.select.OnItemClick | ||
:special-members: __call__ | ||
|
||
.. autoclass:: aiogram_dialog.widgets.kbd.select.Toggle | ||
:special-members: __init__, | ||
|
||
.. autoclass:: aiogram_dialog.widgets.kbd.ManagedToggle | ||
:members: is_checked, get_checked, set_checked |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters