From 7c0a20b5bbb3ed8736faefeec4b3cb7ddb52c266 Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Tue, 16 Jul 2019 14:48:42 +0200 Subject: [PATCH] core: add common page for success and warning --- core/src/apps/common/layout.py | 39 +++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/core/src/apps/common/layout.py b/core/src/apps/common/layout.py index 061e3c3e2..8a7ca60a6 100644 --- a/core/src/apps/common/layout.py +++ b/core/src/apps/common/layout.py @@ -13,7 +13,7 @@ from apps.common import HARDENED from apps.common.confirm import confirm, require_confirm if False: - from typing import Iterable + from typing import Iterable, List from trezor import wire @@ -75,3 +75,40 @@ def address_n_to_str(address_n: list) -> str: return "m" return "m/" + "/".join([path_item(i) for i in address_n]) + + +async def show_warning( + ctx: wire.Context, + content: List[str], + subheader: str = None, + button: str = "Continue", +) -> None: + text = Text("Warning", ui.ICON_WRONG, ui.RED) + await _message(ctx, text, content, subheader, button) + + +async def show_success( + ctx: wire.Context, + content: List[str], + subheader: str = None, + button: str = "Continue", +) -> None: + text = Text("Success", ui.ICON_CONFIRM, ui.GREEN) + await _message(ctx, text, content, subheader, button) + + +async def _message( + ctx: wire.Context, + text: Text, + content: List[str], + subheader: str = None, + button: str = "Continue", +) -> None: + if subheader: + text.bold(subheader) + text.br_half() + for row in content: + text.normal(row) + await require_confirm( + ctx, text, ButtonRequestType.Other, confirm=button, cancel=None + )