1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-19 11:50:58 +00:00

feat(contacts): improve confirm_output_contact

- show correct titles and subtitles
- remove key labels
This commit is contained in:
obrusvit 2024-12-11 12:59:58 +01:00
parent 66e2adacd8
commit 951be5a1cd
3 changed files with 14 additions and 8 deletions

View File

@ -68,8 +68,9 @@ impl FlowController for ConfirmOutputContact {
} }
} }
pub fn new_confirm_output_contact( pub fn new_confirm_output_contact(
paragraphs: ParagraphVecShort<'static>,
title: TString<'static>, title: TString<'static>,
subtitle: TString<'static>,
paragraphs: ParagraphVecShort<'static>,
address_params: ShowInfoParams, address_params: ShowInfoParams,
amount_params: ConfirmBlobParams, amount_params: ConfirmBlobParams,
) -> Result<SwipeFlow, error::Error> { ) -> Result<SwipeFlow, error::Error> {
@ -81,6 +82,7 @@ pub fn new_confirm_output_contact(
let content_contact = Frame::left_aligned(title, SwipeContent::new(paragraphs)) let content_contact = Frame::left_aligned(title, SwipeContent::new(paragraphs))
.with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Up, SwipeSettings::default())
.with_swipe(Direction::Left, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default())
.with_subtitle(subtitle)
.with_menu_button() .with_menu_button()
.with_footer(TR::instructions__swipe_up.into(), None) .with_footer(TR::instructions__swipe_up.into(), None)
.map(move |msg| match msg { .map(move |msg| match msg {

View File

@ -625,17 +625,17 @@ extern "C" fn new_confirm_output(n_args: usize, args: *const Obj, kwargs: *mut M
extern "C" fn new_confirm_output_contact(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { extern "C" fn new_confirm_output_contact(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| { let block = move |_args: &[Obj], kwargs: &Map| {
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let subtitle: TString = kwargs.get(Qstr::MP_QSTR_subtitle)?.try_into()?;
let contact_label: TString = kwargs.get(Qstr::MP_QSTR_contact_label)?.try_into()?; let contact_label: TString = kwargs.get(Qstr::MP_QSTR_contact_label)?.try_into()?;
let address: TString = kwargs.get(Qstr::MP_QSTR_address)?.try_into()?; let address: TString = kwargs.get(Qstr::MP_QSTR_address)?.try_into()?;
let amount: Obj = kwargs.get(Qstr::MP_QSTR_amount)?; let amount: Obj = kwargs.get(Qstr::MP_QSTR_amount)?;
let chunkify: bool = kwargs.get_or(Qstr::MP_QSTR_chunkify, true)?; let chunkify: bool = kwargs.get_or(Qstr::MP_QSTR_chunkify, true)?;
let paragraphs = ParagraphVecShort::from_iter([ let paragraphs =
Paragraph::new(&theme::TEXT_SUB_GREY, "Contact"), ParagraphVecShort::from_iter([Paragraph::new(&theme::TEXT_SUPER, contact_label)]);
Paragraph::new(&theme::TEXT_SUPER, contact_label),
]);
let amount_params = ConfirmBlobParams::new(TR::words__amount.into(), amount, None) let amount_params = ConfirmBlobParams::new(TR::words__amount.into(), amount, None)
.with_subtitle(Some(subtitle))
.with_menu_button() .with_menu_button()
.with_footer(TR::instructions__swipe_up.into(), None) .with_footer(TR::instructions__swipe_up.into(), None)
.with_text_mono(true) .with_text_mono(true)
@ -643,13 +643,15 @@ extern "C" fn new_confirm_output_contact(n_args: usize, args: *const Obj, kwargs
.with_swipe_down(); .with_swipe_down();
let mut address_params = ShowInfoParams::new(TR::words__address.into()) let mut address_params = ShowInfoParams::new(TR::words__address.into())
.with_subtitle(Some(subtitle))
.with_cancel_button() .with_cancel_button()
.with_chunkify(chunkify); .with_chunkify(chunkify);
address_params = unwrap!(address_params.add(TR::words__address.into(), address)); address_params = unwrap!(address_params.add(TString::empty(), address));
let flow = flow::new_confirm_output_contact( let flow = flow::new_confirm_output_contact(
paragraphs,
title, title,
subtitle,
paragraphs,
address_params, address_params,
amount_params, amount_params,
)?; )?;
@ -2023,6 +2025,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// def flow_confirm_output_contact( /// def flow_confirm_output_contact(
/// *, /// *,
/// title: str, /// title: str,
/// subtitle: str,
/// contact_label: str, /// contact_label: str,
/// address: str, /// address: str,
/// amount: str, /// amount: str,

View File

@ -389,7 +389,8 @@ async def confirm_output(
if contact_label: if contact_label:
await raise_if_not_confirmed( await raise_if_not_confirmed(
trezorui2.flow_confirm_output_contact( trezorui2.flow_confirm_output_contact(
title = "Send", title="Contact",
subtitle=title,
contact_label=contact_label, contact_label=contact_label,
address=address, address=address,
amount=amount, amount=amount,