1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

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

This commit is contained in:
Ioan Bizău 2024-11-20 14:46:19 +01:00
parent d2cc6c0623
commit fc0bb63062
3 changed files with 17 additions and 21 deletions

View File

@ -69,7 +69,7 @@ impl ConfirmActionStrings {
#[derive(PartialEq)]
pub struct ConfirmActionMenuStrings {
verb_cancel: Option<TString<'static>>,
verb_cancel: TString<'static>,
has_info: bool,
verb_info: Option<TString<'static>>,
}
@ -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<TString<'static>>) -> 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,

View File

@ -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<TString<'static>>,
verb: Option<TString<'static>>,
verb_cancel: Option<TString<'static>>,
verb_cancel: TString<'static>,
verb_info: Option<TString<'static>>,
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<TString<'static>>,
) -> Self {
pub fn new(title: TString<'static>, data: Obj, description: Option<TString<'static>>) -> 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<TString<'static>>) -> Self {
pub const fn with_verb_cancel(mut self, verb_cancel: TString<'static>) -> Self {
self.verb_cancel = verb_cancel;
self
}

View File

@ -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)