From 1eff1d8e0e7660386e2475c7cdf99b63b35a9523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ioan=20Biz=C4=83u?= Date: Wed, 20 Nov 2024 16:17:03 +0100 Subject: [PATCH] fixup! fixup! fixup! feat(core/ui): add cancel button to paginated blobs --- .../src/ui/model_mercury/flow/confirm_action.rs | 14 +++----------- core/embed/rust/src/ui/model_mercury/flow/util.rs | 9 +-------- core/embed/rust/src/ui/model_mercury/layout.rs | 14 ++++++++++---- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs index 5d92bb2a0b..ccaa5f33dd 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs @@ -70,7 +70,6 @@ impl ConfirmActionStrings { #[derive(PartialEq)] pub struct ConfirmActionMenuStrings { verb_cancel: TString<'static>, - has_info: bool, verb_info: Option>, } @@ -78,7 +77,6 @@ impl ConfirmActionMenuStrings { pub fn new() -> Self { Self { verb_cancel: TR::buttons__cancel.into(), - has_info: false, verb_info: None, } } @@ -88,8 +86,7 @@ impl ConfirmActionMenuStrings { self } - pub const fn with_info(mut self, has_info: bool, verb_info: Option>) -> Self { - self.has_info = has_info; + pub const fn with_verb_info(mut self, verb_info: Option>) -> Self { self.verb_info = verb_info; self } @@ -343,15 +340,10 @@ fn create_menu( let mut menu_choices = VerticalMenu::empty().danger(theme::ICON_CANCEL, menu_strings.verb_cancel); - if menu_strings.has_info { + if let Some(verb_info) = menu_strings.verb_info { // The Info menu item (if present) has to be the 2nd, // because of MENU_ITEM_INFO = 1! - menu_choices = menu_choices.item( - theme::ICON_CHEVRON_RIGHT, - menu_strings - .verb_info - .unwrap_or(TR::words__title_information.into()), - ); + menu_choices = menu_choices.item(theme::ICON_CHEVRON_RIGHT, verb_info); } let content_menu = Frame::left_aligned("".into(), menu_choices) diff --git a/core/embed/rust/src/ui/model_mercury/flow/util.rs b/core/embed/rust/src/ui/model_mercury/flow/util.rs index 4f1fa61889..044fc8b3f6 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/util.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/util.rs @@ -41,7 +41,6 @@ pub struct ConfirmBlobParams { verb: Option>, verb_cancel: TString<'static>, verb_info: Option>, - info_button: bool, cancel_button: bool, menu_button: bool, prompt: bool, @@ -71,7 +70,6 @@ impl ConfirmBlobParams { verb: None, verb_cancel: TR::buttons__cancel.into(), verb_info: None, - info_button: false, cancel_button: false, menu_button: false, prompt: false, @@ -108,11 +106,6 @@ impl ConfirmBlobParams { self } - pub const fn with_info_button(mut self, info_button: bool) -> Self { - self.info_button = info_button; - self - } - pub const fn with_verb(mut self, verb: Option>) -> Self { self.verb = verb; self @@ -287,7 +280,7 @@ impl ConfirmBlobParams { ConfirmActionExtra::Menu( ConfirmActionMenuStrings::new() .with_verb_cancel(self.verb_cancel) - .with_info(self.info_button, self.verb_info), + .with_verb_info(self.verb_info), ) }; diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index efbe9880a1..d3ab2d1824 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -302,9 +302,12 @@ extern "C" fn new_confirm_blob(n_args: usize, args: *const Obj, kwargs: *mut Map .with_subtitle(subtitle) .with_verb(verb) .with_verb_cancel(verb_cancel.unwrap_or(TR::buttons__cancel.into())) - .with_verb_info(verb_info) + .with_verb_info(if info { + Some(verb_info.unwrap_or(TR::words__title_information.into())) + } else { + None + }) .with_extra(extra) - .with_info_button(info) .with_chunkify(chunkify) .with_page_counter(page_counter) .with_cancel(cancel) @@ -344,7 +347,6 @@ extern "C" fn new_confirm_blob_intro(n_args: usize, args: *const Obj, kwargs: *m .with_footer_description(Some( TR::buttons__confirm.into(), /* or words__confirm?? */ )) - .with_info_button(true) .with_chunkify(chunkify) .with_page_limit(Some(1)) .with_frame_margin(CONFIRM_BLOB_INTRO_MARGIN) @@ -778,7 +780,11 @@ extern "C" fn new_confirm_value(n_args: usize, args: *const Obj, kwargs: *mut Ma .with_subtitle(subtitle) .with_verb(verb) .with_verb_cancel(verb_cancel.unwrap_or(TR::buttons__cancel.into())) - .with_info_button(info_button) + .with_verb_info(if info_button { + Some(TR::words__title_information.into()) + } else { + None + }) .with_chunkify(chunkify) .with_text_mono(text_mono) .with_prompt(hold)