diff --git a/src/apps/monero/layout/common.py b/src/apps/monero/layout/common.py index 4fb34a41b4..a7b2c74c11 100644 --- a/src/apps/monero/layout/common.py +++ b/src/apps/monero/layout/common.py @@ -46,6 +46,9 @@ async def tx_dialog( await ctx.call(ButtonRequest(code=code), MessageType.ButtonAck) + if scroll_tuple and scroll_tuple[1] > 1: + content = Scrollpage(content, scroll_tuple[0], scroll_tuple[1]) + dialog = ConfirmDialog( content, cancel=cancel_btn, @@ -53,9 +56,6 @@ async def tx_dialog( cancel_style=cancel_style, confirm_style=confirm_style, ) - if scroll_tuple and scroll_tuple[1] > 1: - dialog = Scrollpage(dialog, scroll_tuple[0], scroll_tuple[1]) - return await ctx.wait(dialog) diff --git a/src/trezor/ui/confirm.py b/src/trezor/ui/confirm.py index 8899e48e5b..475a85fe72 100644 --- a/src/trezor/ui/confirm.py +++ b/src/trezor/ui/confirm.py @@ -66,6 +66,11 @@ class HoldToConfirmDialog(Widget): self.button = Button(ui.grid(4, n_x=1), hold, style=button_style) self.loader = Loader(style=loader_style) + if content.__class__.__iter__ is not Widget.__iter__: + raise TypeError( + "HoldToConfirmDialog does not support widgets with custom event loop" + ) + def taint(self): super().taint() self.button.taint() @@ -73,6 +78,8 @@ class HoldToConfirmDialog(Widget): def render(self): self.button.render() + if not self.loader.is_active(): + self.content.render() def touch(self, event, pos): button = self.button @@ -94,12 +101,15 @@ class HoldToConfirmDialog(Widget): result = None while result is None or result < 0: # _STARTED or _STOPPED if self.loader.is_active(): - content_loop = self.loader + if __debug__: + result = await loop.spawn( + self.loader, super().__iter__(), confirm_signal + ) + else: + result = await loop.spawn(self.loader, super().__iter__()) else: - content_loop = self.content - confirm_loop = super().__iter__() # default loop (render on touch) - if __debug__: - result = await loop.spawn(content_loop, confirm_loop, confirm_signal) - else: - result = await loop.spawn(content_loop, confirm_loop) + if __debug__: + result = await loop.spawn(super().__iter__(), confirm_signal) + else: + result = await super().__iter__() return result diff --git a/src/trezor/ui/scroll.py b/src/trezor/ui/scroll.py index 115079b04c..89d2fad39b 100644 --- a/src/trezor/ui/scroll.py +++ b/src/trezor/ui/scroll.py @@ -75,6 +75,11 @@ class Scrollpage(ui.Widget): self.page = page self.page_count = page_count + if content.__class__.__iter__ is not ui.Widget.__iter__: + raise TypeError( + "Scrollpage does not support widgets with custom event loop" + ) + def taint(self): super().taint() self.content.taint() @@ -83,5 +88,5 @@ class Scrollpage(ui.Widget): self.content.render() render_scrollbar(self.page, self.page_count) - async def __iter__(self): - return await loop.spawn(super().__iter__(), self.content) + def touch(self, event, pos): + return self.content.touch(event, pos)