From fc0bb630620df3c133a12e9bd437fdc6199d62d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ioan=20Biz=C4=83u?= Date: Wed, 20 Nov 2024 14:46:19 +0100 Subject: [PATCH] fixup! fixup! feat(core/ui): add cancel button to paginated blobs --- .../ui/model_mercury/flow/confirm_action.rs | 19 +++++++++---------- .../rust/src/ui/model_mercury/flow/util.rs | 13 +++++-------- .../embed/rust/src/ui/model_mercury/layout.rs | 6 +++--- 3 files changed, 17 insertions(+), 21 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 74ceb3d54a..5d92bb2a0b 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 @@ -69,7 +69,7 @@ impl ConfirmActionStrings { #[derive(PartialEq)] pub struct ConfirmActionMenuStrings { - verb_cancel: Option>, + verb_cancel: TString<'static>, has_info: bool, verb_info: Option>, } @@ -77,13 +77,13 @@ pub struct ConfirmActionMenuStrings { impl ConfirmActionMenuStrings { pub fn new() -> Self { Self { - verb_cancel: None, + verb_cancel: TR::buttons__cancel.into(), has_info: false, verb_info: None, } } - pub const fn with_verb_cancel(mut self, verb_cancel: Option>) -> Self { + pub const fn with_verb_cancel(mut self, verb_cancel: TString<'static>) -> Self { self.verb_cancel = verb_cancel; self } @@ -225,7 +225,10 @@ pub fn new_confirm_action( new_confirm_action_simple( paragraphs, - ConfirmActionExtra::Menu(ConfirmActionMenuStrings::new().with_verb_cancel(verb_cancel)), + ConfirmActionExtra::Menu( + ConfirmActionMenuStrings::new() + .with_verb_cancel(verb_cancel.unwrap_or(TR::buttons__cancel.into())), + ), ConfirmActionStrings::new(title, subtitle, None, prompt_screen.then_some(prompt_title)), hold, None, @@ -337,12 +340,8 @@ fn create_menu( // because of the MENU_ITEM_CANCEL = 0. // If we want the cancel item to be somewhere else, // we would need to account for that and we could not use a constant. - let mut menu_choices = VerticalMenu::empty().danger( - theme::ICON_CANCEL, - menu_strings - .verb_cancel - .unwrap_or(TR::buttons__cancel.into()), - ); + let mut menu_choices = + VerticalMenu::empty().danger(theme::ICON_CANCEL, menu_strings.verb_cancel); if menu_strings.has_info { // The Info menu item (if present) has to be the 2nd, 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 a2034f3aa6..4f1fa61889 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/util.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/util.rs @@ -10,6 +10,7 @@ use crate::{ maybe_trace::MaybeTrace, micropython::obj::Obj, strutil::TString, + translations::TR, ui::{ component::{ base::ComponentExt, @@ -38,7 +39,7 @@ pub struct ConfirmBlobParams { description_font: &'static TextStyle, extra: Option>, verb: Option>, - verb_cancel: Option>, + verb_cancel: TString<'static>, verb_info: Option>, info_button: bool, cancel_button: bool, @@ -57,11 +58,7 @@ pub struct ConfirmBlobParams { } impl ConfirmBlobParams { - pub const fn new( - title: TString<'static>, - data: Obj, - description: Option>, - ) -> Self { + pub fn new(title: TString<'static>, data: Obj, description: Option>) -> Self { Self { title, subtitle: None, @@ -72,7 +69,7 @@ impl ConfirmBlobParams { description_font: &theme::TEXT_NORMAL, extra: None, verb: None, - verb_cancel: None, + verb_cancel: TR::buttons__cancel.into(), verb_info: None, info_button: false, cancel_button: false, @@ -121,7 +118,7 @@ impl ConfirmBlobParams { self } - pub const fn with_verb_cancel(mut self, verb_cancel: Option>) -> Self { + pub const fn with_verb_cancel(mut self, verb_cancel: TString<'static>) -> Self { self.verb_cancel = verb_cancel; self } diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index 2b10ecc44a..efbe9880a1 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -301,7 +301,7 @@ extern "C" fn new_confirm_blob(n_args: usize, args: *const Obj, kwargs: *mut Map .with_text_mono(text_mono) .with_subtitle(subtitle) .with_verb(verb) - .with_verb_cancel(verb_cancel) + .with_verb_cancel(verb_cancel.unwrap_or(TR::buttons__cancel.into())) .with_verb_info(verb_info) .with_extra(extra) .with_info_button(info) @@ -340,7 +340,7 @@ extern "C" fn new_confirm_blob_intro(n_args: usize, args: *const Obj, kwargs: *m .with_verb_info(Some(TR::buttons__view_all_data.into())) .with_description_font(&theme::TEXT_SUB_GREEN_LIME) .with_subtitle(subtitle) - .with_verb_cancel(verb_cancel) + .with_verb_cancel(verb_cancel.unwrap_or(TR::buttons__cancel.into())) .with_footer_description(Some( TR::buttons__confirm.into(), /* or words__confirm?? */ )) @@ -777,7 +777,7 @@ extern "C" fn new_confirm_value(n_args: usize, args: *const Obj, kwargs: *mut Ma ConfirmBlobParams::new(title, value, description) .with_subtitle(subtitle) .with_verb(verb) - .with_verb_cancel(verb_cancel) + .with_verb_cancel(verb_cancel.unwrap_or(TR::buttons__cancel.into())) .with_info_button(info_button) .with_chunkify(chunkify) .with_text_mono(text_mono)