1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-19 12:58:13 +00:00

fix(core): add subtitle to confirm action

[no changelog]
This commit is contained in:
tychovrahe 2024-05-17 15:38:51 +02:00 committed by TychoVrahe
parent 7e2f985037
commit 2e10d440fa
7 changed files with 35 additions and 8 deletions

View File

@ -121,6 +121,10 @@ fn new_confirm_action_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let action: Option<TString> = kwargs.get(Qstr::MP_QSTR_action)?.try_into_option()?;
let description: Option<TString> = kwargs.get(Qstr::MP_QSTR_description)?.try_into_option()?;
let subtitle: Option<TString> = kwargs
.get(Qstr::MP_QSTR_subtitle)
.unwrap_or(Obj::const_none())
.try_into_option()?;
// let verb: Option<TString> = kwargs
// .get(Qstr::MP_QSTR_verb)
// .unwrap_or_else(|_| Obj::const_none())
@ -150,10 +154,16 @@ fn new_confirm_action_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
paragraphs.into_paragraphs()
};
let content_intro = Frame::left_aligned(title, SwipePage::vertical(paragraphs))
let mut content_intro = Frame::left_aligned(title, SwipePage::vertical(paragraphs))
.with_menu_button()
.with_footer(TR::instructions__swipe_up.into(), None)
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info));
.with_footer(TR::instructions__swipe_up.into(), None);
if let Some(subtitle) = subtitle {
content_intro = content_intro.with_subtitle(subtitle);
}
let content_intro =
content_intro.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info));
let content_menu = if let Some(verb_cancel) = verb_cancel {
Frame::left_aligned(
@ -189,14 +199,13 @@ fn new_confirm_action_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
)
};
let content_confirm = Frame::left_aligned(title, prompt)
let mut content_confirm = Frame::left_aligned(title, prompt)
.with_footer(prompt_action, None)
.with_menu_button();
// .with_overlapping_content();
// if let Some(subtitle) = subtitle {
// content_confirm = content_confirm.with_subtitle(subtitle);
// }
if let Some(subtitle) = subtitle {
content_confirm = content_confirm.with_subtitle(subtitle);
}
let content_confirm = content_confirm.map(move |msg| match msg {
FrameMsg::Content(()) => Some(FlowMsg::Confirmed),

View File

@ -1642,11 +1642,13 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// title: str,
/// action: str | None,
/// description: str | None,
/// subtitle: str | None = None,
/// verb: str = "CONFIRM",
/// verb_cancel: str | None = None,
/// hold: bool = False,
/// hold_danger: bool = False, # unused on TR
/// reverse: bool = False,
/// prompt_screen: bool = False,
/// ) -> LayoutObj[UiResult]:
/// """Confirm action."""
Qstr::MP_QSTR_confirm_action => obj_fn_kw!(0, new_confirm_action).as_obj(),

View File

@ -1708,11 +1708,13 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// title: str,
/// action: str | None,
/// description: str | None,
/// subtitle: str | None = None,
/// verb: str | None = None,
/// verb_cancel: str | None = None,
/// hold: bool = False,
/// hold_danger: bool = False,
/// reverse: bool = False,
/// prompt_screen: bool = False,
/// ) -> LayoutObj[UiResult]:
/// """Confirm action."""
Qstr::MP_QSTR_confirm_action => obj_fn_kw!(0, new_confirm_action).as_obj(),

View File

@ -623,11 +623,13 @@ def confirm_action(
title: str,
action: str | None,
description: str | None,
subtitle: str | None = None,
verb: str = "CONFIRM",
verb_cancel: str | None = None,
hold: bool = False,
hold_danger: bool = False, # unused on TR
reverse: bool = False,
prompt_screen: bool = False,
) -> LayoutObj[UiResult]:
"""Confirm action."""
@ -1147,11 +1149,13 @@ def confirm_action(
title: str,
action: str | None,
description: str | None,
subtitle: str | None = None,
verb: str | None = None,
verb_cancel: str | None = None,
hold: bool = False,
hold_danger: bool = False,
reverse: bool = False,
prompt_screen: bool = False,
) -> LayoutObj[UiResult]:
"""Confirm action."""

View File

@ -283,6 +283,7 @@ async def confirm_action(
action: str | None = None,
description: str | None = None,
description_param: str | None = None,
subtitle: str | None = None,
verb: str | None = None,
verb_cancel: str | None = None,
hold: bool = False,
@ -290,6 +291,7 @@ async def confirm_action(
reverse: bool = False,
exc: ExceptionType = ActionCancelled,
br_code: ButtonRequestType = BR_TYPE_OTHER,
prompt_screen: bool = False,
) -> None:
if description is not None and description_param is not None:
description = description.format(description_param)
@ -301,11 +303,13 @@ async def confirm_action(
title=title,
action=action,
description=description,
subtitle=subtitle,
verb=verb,
verb_cancel=verb_cancel,
hold=hold,
hold_danger=hold_danger,
reverse=reverse,
prompt_screen=prompt_screen,
)
),
br_type,

View File

@ -374,6 +374,7 @@ def confirm_action(
action: str | None = None,
description: str | None = None,
description_param: str | None = None,
subtitle: str | None = None,
verb: str | None = None,
verb_cancel: str | None = "",
hold: bool = False,
@ -381,6 +382,7 @@ def confirm_action(
reverse: bool = False,
exc: ExceptionType = ActionCancelled,
br_code: ButtonRequestType = BR_TYPE_OTHER,
prompt_screen: bool = False,
) -> Awaitable[None]:
verb = verb or TR.buttons__confirm # def_arg
if description is not None and description_param is not None:
@ -393,6 +395,7 @@ def confirm_action(
title=title,
action=action,
description=description,
subtitle=subtitle,
verb=verb,
verb_cancel=verb_cancel,
hold=hold,

View File

@ -289,6 +289,7 @@ def confirm_action(
action: str | None = None,
description: str | None = None,
description_param: str | None = None,
subtitle: str | None = None,
verb: str | None = None,
verb_cancel: str | None = None,
hold: bool = False,
@ -296,6 +297,7 @@ def confirm_action(
reverse: bool = False,
exc: ExceptionType = ActionCancelled,
br_code: ButtonRequestType = BR_TYPE_OTHER,
prompt_screen: bool = False,
) -> Awaitable[None]:
if description is not None and description_param is not None:
description = description.format(description_param)
@ -307,6 +309,7 @@ def confirm_action(
title=title,
action=action,
description=description,
subtitle=subtitle,
verb=verb,
verb_cancel=verb_cancel,
hold=hold,