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,
|
title: str,
|
||||||
value: str,
|
value: str,
|
||||||
description: str,
|
description: str,
|
||||||
@ -935,7 +935,8 @@ def confirm_value(
|
|||||||
*,
|
*,
|
||||||
verb: str | None = None,
|
verb: str | None = None,
|
||||||
hold: bool = False,
|
hold: bool = False,
|
||||||
) -> Awaitable[None]:
|
info_items: Iterable[tuple[str, str]] | None = None,
|
||||||
|
) -> None:
|
||||||
"""General confirmation dialog, used by many other confirm_* functions."""
|
"""General confirmation dialog, used by many other confirm_* functions."""
|
||||||
|
|
||||||
if not verb and not hold:
|
if not verb and not hold:
|
||||||
@ -944,21 +945,50 @@ def confirm_value(
|
|||||||
if verb:
|
if verb:
|
||||||
verb = verb.upper()
|
verb = verb.upper()
|
||||||
|
|
||||||
return raise_if_not_confirmed(
|
if info_items is None:
|
||||||
interact(
|
return await raise_if_not_confirmed(
|
||||||
RustLayout(
|
interact(
|
||||||
trezorui2.confirm_value( # type: ignore [Argument missing for parameter "subtitle"]
|
RustLayout(
|
||||||
title=title.upper(),
|
trezorui2.confirm_value( # type: ignore [Argument missing for parameter "subtitle"]
|
||||||
description=description,
|
title=title.upper(),
|
||||||
value=value,
|
description=description,
|
||||||
verb=verb or "HOLD TO CONFIRM",
|
value=value,
|
||||||
hold=hold,
|
verb=verb or "HOLD TO CONFIRM",
|
||||||
)
|
hold=hold,
|
||||||
),
|
)
|
||||||
br_type,
|
),
|
||||||
br_code,
|
br_type,
|
||||||
|
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(
|
async def confirm_total(
|
||||||
|
@ -844,7 +844,7 @@ def confirm_value(
|
|||||||
verb: str | None = None,
|
verb: str | None = None,
|
||||||
subtitle: str | None = None,
|
subtitle: str | None = None,
|
||||||
hold: bool = False,
|
hold: bool = False,
|
||||||
info_button: bool = False,
|
info_items: Iterable[tuple[str, str]] | None = None,
|
||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
"""General confirmation dialog, used by many other confirm_* functions."""
|
"""General confirmation dialog, used by many other confirm_* functions."""
|
||||||
|
|
||||||
@ -854,8 +854,16 @@ def confirm_value(
|
|||||||
if verb:
|
if verb:
|
||||||
verb = verb.upper()
|
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(
|
return raise_if_not_confirmed(
|
||||||
interact(
|
with_info(
|
||||||
RustLayout(
|
RustLayout(
|
||||||
trezorui2.confirm_value(
|
trezorui2.confirm_value(
|
||||||
title=title.upper(),
|
title=title.upper(),
|
||||||
@ -864,9 +872,10 @@ def confirm_value(
|
|||||||
value=value,
|
value=value,
|
||||||
verb=verb,
|
verb=verb,
|
||||||
hold=hold,
|
hold=hold,
|
||||||
info_button=info_button,
|
info_button=bool(info_items),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
info_layout,
|
||||||
br_type,
|
br_type,
|
||||||
br_code,
|
br_code,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user