mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-16 17:42:02 +00:00
Add common page for success and warning (#339)
Add common page for success and warning
This commit is contained in:
commit
d944a9e964
@ -13,7 +13,7 @@ from apps.common import HARDENED
|
|||||||
from apps.common.confirm import confirm, require_confirm
|
from apps.common.confirm import confirm, require_confirm
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
from typing import Iterable
|
from typing import Iterable, List
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
|
|
||||||
|
|
||||||
@ -75,3 +75,40 @@ def address_n_to_str(address_n: list) -> str:
|
|||||||
return "m"
|
return "m"
|
||||||
|
|
||||||
return "m/" + "/".join([path_item(i) for i in address_n])
|
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
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user