From ccc565d53173f1f614c514d995dd9426d33c2369 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Tue, 15 Jul 2025 19:15:58 +0300 Subject: [PATCH] refactor(core): allow any layout for menu details [no changelog] --- core/src/trezor/ui/layouts/menu.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/trezor/ui/layouts/menu.py b/core/src/trezor/ui/layouts/menu.py index c111314404..6963df138f 100644 --- a/core/src/trezor/ui/layouts/menu.py +++ b/core/src/trezor/ui/layouts/menu.py @@ -6,12 +6,14 @@ from trezor.ui.layouts.common import interact from trezor.wire import ActionCancelled if TYPE_CHECKING: - from typing import Callable, Iterable, Sequence + from typing import Callable, Iterable, Sequence, TypeVar from typing_extensions import Self from common import ExceptionType + T = TypeVar("T") + class Menu: def __init__( @@ -29,13 +31,13 @@ class Menu: class Details: - def __init__(self, name: str, factory: Callable[[], Awaitable[None]]) -> None: + def __init__(self, name: str, factory: Callable[[], Awaitable[T]]) -> None: self.name = name self.factory = factory @classmethod def from_layout( - cls, name: str, layout_factory: Callable[[], trezorui_api.LayoutObj[None]] + cls, name: str, layout_factory: Callable[[], trezorui_api.LayoutObj[T]] ) -> Self: return cls( name, @@ -71,7 +73,7 @@ async def show_menu( else: assert isinstance(menu, Details) # Details' layout is created on-demand (saving memory) - await menu.factory() + await menu.factory() # the result is ignored # go one level up, or exit the menu if menu_path: