mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 13:38:12 +00:00
fix(core): update confirm_value
to allow showing info
This commit is contained in:
parent
deb6967f67
commit
6912bf6e7f
@ -926,7 +926,7 @@ async def confirm_properties(
|
||||
)
|
||||
|
||||
|
||||
def confirm_value(
|
||||
async def confirm_value(
|
||||
title: str,
|
||||
value: str,
|
||||
description: str,
|
||||
@ -935,7 +935,8 @@ def confirm_value(
|
||||
*,
|
||||
verb: str | None = None,
|
||||
hold: bool = False,
|
||||
) -> Awaitable[None]:
|
||||
info_items: Iterable[tuple[str, str]] | None = None,
|
||||
) -> None:
|
||||
"""General confirmation dialog, used by many other confirm_* functions."""
|
||||
|
||||
if not verb and not hold:
|
||||
@ -944,7 +945,8 @@ def confirm_value(
|
||||
if verb:
|
||||
verb = verb.upper()
|
||||
|
||||
return raise_if_not_confirmed(
|
||||
if info_items is None:
|
||||
return await raise_if_not_confirmed(
|
||||
interact(
|
||||
RustLayout(
|
||||
trezorui2.confirm_value( # type: ignore [Argument missing for parameter "subtitle"]
|
||||
@ -959,6 +961,34 @@ def confirm_value(
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
else:
|
||||
info_items_list = list(info_items)
|
||||
if len(info_items_list) > 1:
|
||||
raise NotImplementedError("Only one info item is supported")
|
||||
|
||||
while True:
|
||||
should_show_info = await should_show_more(
|
||||
title,
|
||||
para=((ui.NORMAL, value),),
|
||||
button_text="INFO",
|
||||
br_type=br_type,
|
||||
br_code=br_code,
|
||||
)
|
||||
|
||||
if not should_show_info:
|
||||
return
|
||||
|
||||
try:
|
||||
info_title, info_value = info_items_list[0]
|
||||
await confirm_action(
|
||||
br_type="confirm_value_info",
|
||||
title=info_title,
|
||||
action=info_value,
|
||||
verb="BACK",
|
||||
verb_cancel="<",
|
||||
)
|
||||
except ActionCancelled:
|
||||
continue
|
||||
|
||||
|
||||
async def confirm_total(
|
||||
|
@ -844,7 +844,7 @@ def confirm_value(
|
||||
verb: str | None = None,
|
||||
subtitle: str | None = None,
|
||||
hold: bool = False,
|
||||
info_button: bool = False,
|
||||
info_items: Iterable[tuple[str, str]] | None = None,
|
||||
) -> Awaitable[None]:
|
||||
"""General confirmation dialog, used by many other confirm_* functions."""
|
||||
|
||||
@ -854,8 +854,16 @@ def confirm_value(
|
||||
if verb:
|
||||
verb = verb.upper()
|
||||
|
||||
info_items = info_items or []
|
||||
info_layout = RustLayout(
|
||||
trezorui2.show_info_with_cancel(
|
||||
title="INFORMATION",
|
||||
items=info_items,
|
||||
)
|
||||
)
|
||||
|
||||
return raise_if_not_confirmed(
|
||||
interact(
|
||||
with_info(
|
||||
RustLayout(
|
||||
trezorui2.confirm_value(
|
||||
title=title.upper(),
|
||||
@ -864,9 +872,10 @@ def confirm_value(
|
||||
value=value,
|
||||
verb=verb,
|
||||
hold=hold,
|
||||
info_button=info_button,
|
||||
info_button=bool(info_items),
|
||||
)
|
||||
),
|
||||
info_layout,
|
||||
br_type,
|
||||
br_code,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user