1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

core: add common page for success and warning

This commit is contained in:
Tomas Susanka 2019-07-16 14:48:42 +02:00
parent 3750ade2ab
commit 7c0a20b5bb

View File

@ -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
)