1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-29 02:48:18 +00:00

fixup! fixup! fixup! feat(core/ui): add cancel button to paginated blobs

This commit is contained in:
Ioan Bizău 2024-11-20 16:17:03 +01:00
parent fc0bb63062
commit 1eff1d8e0e
3 changed files with 14 additions and 23 deletions

View File

@ -70,7 +70,6 @@ impl ConfirmActionStrings {
#[derive(PartialEq)] #[derive(PartialEq)]
pub struct ConfirmActionMenuStrings { pub struct ConfirmActionMenuStrings {
verb_cancel: TString<'static>, verb_cancel: TString<'static>,
has_info: bool,
verb_info: Option<TString<'static>>, verb_info: Option<TString<'static>>,
} }
@ -78,7 +77,6 @@ impl ConfirmActionMenuStrings {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
verb_cancel: TR::buttons__cancel.into(), verb_cancel: TR::buttons__cancel.into(),
has_info: false,
verb_info: None, verb_info: None,
} }
} }
@ -88,8 +86,7 @@ impl ConfirmActionMenuStrings {
self self
} }
pub const fn with_info(mut self, has_info: bool, verb_info: Option<TString<'static>>) -> Self { pub const fn with_verb_info(mut self, verb_info: Option<TString<'static>>) -> Self {
self.has_info = has_info;
self.verb_info = verb_info; self.verb_info = verb_info;
self self
} }
@ -343,15 +340,10 @@ fn create_menu(
let mut menu_choices = let mut menu_choices =
VerticalMenu::empty().danger(theme::ICON_CANCEL, menu_strings.verb_cancel); 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, // The Info menu item (if present) has to be the 2nd,
// because of MENU_ITEM_INFO = 1! // because of MENU_ITEM_INFO = 1!
menu_choices = menu_choices.item( menu_choices = menu_choices.item(theme::ICON_CHEVRON_RIGHT, verb_info);
theme::ICON_CHEVRON_RIGHT,
menu_strings
.verb_info
.unwrap_or(TR::words__title_information.into()),
);
} }
let content_menu = Frame::left_aligned("".into(), menu_choices) let content_menu = Frame::left_aligned("".into(), menu_choices)

View File

@ -41,7 +41,6 @@ pub struct ConfirmBlobParams {
verb: Option<TString<'static>>, verb: Option<TString<'static>>,
verb_cancel: TString<'static>, verb_cancel: TString<'static>,
verb_info: Option<TString<'static>>, verb_info: Option<TString<'static>>,
info_button: bool,
cancel_button: bool, cancel_button: bool,
menu_button: bool, menu_button: bool,
prompt: bool, prompt: bool,
@ -71,7 +70,6 @@ impl ConfirmBlobParams {
verb: None, verb: None,
verb_cancel: TR::buttons__cancel.into(), verb_cancel: TR::buttons__cancel.into(),
verb_info: None, verb_info: None,
info_button: false,
cancel_button: false, cancel_button: false,
menu_button: false, menu_button: false,
prompt: false, prompt: false,
@ -108,11 +106,6 @@ impl ConfirmBlobParams {
self 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<TString<'static>>) -> Self { pub const fn with_verb(mut self, verb: Option<TString<'static>>) -> Self {
self.verb = verb; self.verb = verb;
self self
@ -287,7 +280,7 @@ impl ConfirmBlobParams {
ConfirmActionExtra::Menu( ConfirmActionExtra::Menu(
ConfirmActionMenuStrings::new() ConfirmActionMenuStrings::new()
.with_verb_cancel(self.verb_cancel) .with_verb_cancel(self.verb_cancel)
.with_info(self.info_button, self.verb_info), .with_verb_info(self.verb_info),
) )
}; };

View File

@ -302,9 +302,12 @@ extern "C" fn new_confirm_blob(n_args: usize, args: *const Obj, kwargs: *mut Map
.with_subtitle(subtitle) .with_subtitle(subtitle)
.with_verb(verb) .with_verb(verb)
.with_verb_cancel(verb_cancel.unwrap_or(TR::buttons__cancel.into())) .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_extra(extra)
.with_info_button(info)
.with_chunkify(chunkify) .with_chunkify(chunkify)
.with_page_counter(page_counter) .with_page_counter(page_counter)
.with_cancel(cancel) .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( .with_footer_description(Some(
TR::buttons__confirm.into(), /* or words__confirm?? */ TR::buttons__confirm.into(), /* or words__confirm?? */
)) ))
.with_info_button(true)
.with_chunkify(chunkify) .with_chunkify(chunkify)
.with_page_limit(Some(1)) .with_page_limit(Some(1))
.with_frame_margin(CONFIRM_BLOB_INTRO_MARGIN) .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_subtitle(subtitle)
.with_verb(verb) .with_verb(verb)
.with_verb_cancel(verb_cancel.unwrap_or(TR::buttons__cancel.into())) .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_chunkify(chunkify)
.with_text_mono(text_mono) .with_text_mono(text_mono)
.with_prompt(hold) .with_prompt(hold)