mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-09 06:50:58 +00:00
fixup! feat(core/ui): add cancel button to paginated blobs
This commit is contained in:
parent
2bc787a652
commit
33d1def00d
@ -32,11 +32,7 @@ const MENU_ITEM_INFO: usize = 1;
|
|||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub enum ConfirmActionExtra {
|
pub enum ConfirmActionExtra {
|
||||||
// Opens a menu which can (optionally) lead to an extra Info screen, or cancel the action
|
// Opens a menu which can (optionally) lead to an extra Info screen, or cancel the action
|
||||||
Menu {
|
Menu(ConfirmActionMenuStrings),
|
||||||
verb_cancel: Option<TString<'static>>,
|
|
||||||
has_info: bool,
|
|
||||||
verb_info: Option<TString<'static>>,
|
|
||||||
},
|
|
||||||
// Shows a cancel button directly
|
// Shows a cancel button directly
|
||||||
Cancel,
|
Cancel,
|
||||||
}
|
}
|
||||||
@ -64,6 +60,34 @@ impl ConfirmActionStrings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq)]
|
||||||
|
pub struct ConfirmActionMenuStrings {
|
||||||
|
verb_cancel: Option<TString<'static>>,
|
||||||
|
has_info: bool,
|
||||||
|
verb_info: Option<TString<'static>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ConfirmActionMenuStrings {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
verb_cancel: None,
|
||||||
|
has_info: false,
|
||||||
|
verb_info: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn with_verb_cancel(mut self, verb_cancel: Option<TString<'static>>) -> Self {
|
||||||
|
self.verb_cancel = verb_cancel;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn with_info(mut self, has_info: bool, verb_info: Option<TString<'static>>) -> Self {
|
||||||
|
self.has_info = has_info;
|
||||||
|
self.verb_info = verb_info;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The simplest form of the ConfirmAction flow:
|
/// The simplest form of the ConfirmAction flow:
|
||||||
/// no menu, nor a separate "Tap to confirm" or "Hold to confirm".
|
/// no menu, nor a separate "Tap to confirm" or "Hold to confirm".
|
||||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
@ -194,11 +218,7 @@ pub fn new_confirm_action(
|
|||||||
|
|
||||||
new_confirm_action_simple(
|
new_confirm_action_simple(
|
||||||
paragraphs,
|
paragraphs,
|
||||||
ConfirmActionExtra::Menu {
|
ConfirmActionExtra::Menu(ConfirmActionMenuStrings::new().with_verb_cancel(verb_cancel)),
|
||||||
verb_cancel,
|
|
||||||
has_info: false,
|
|
||||||
verb_info: None,
|
|
||||||
},
|
|
||||||
ConfirmActionStrings::new(title, subtitle, None, prompt_screen.then_some(prompt_title)),
|
ConfirmActionStrings::new(title, subtitle, None, prompt_screen.then_some(prompt_title)),
|
||||||
hold,
|
hold,
|
||||||
None,
|
None,
|
||||||
@ -299,27 +319,26 @@ fn create_menu(
|
|||||||
extra: ConfirmActionExtra,
|
extra: ConfirmActionExtra,
|
||||||
prompt_screen: Option<TString<'static>>,
|
prompt_screen: Option<TString<'static>>,
|
||||||
) -> Result<SwipeFlow, Error> {
|
) -> Result<SwipeFlow, Error> {
|
||||||
if let ConfirmActionExtra::Menu {
|
if let ConfirmActionExtra::Menu(menu_strings) = extra {
|
||||||
verb_cancel,
|
|
||||||
has_info,
|
|
||||||
verb_info,
|
|
||||||
} = extra
|
|
||||||
{
|
|
||||||
// NB: The Cancel menu item is always the first,
|
// NB: The Cancel menu item is always the first,
|
||||||
// because of the MENU_ITEM_CANCEL = 0.
|
// because of the MENU_ITEM_CANCEL = 0.
|
||||||
// If we want the cancel item to be somewhere else,
|
// If we want the cancel item to be somewhere else,
|
||||||
// we would need to account for that and we could not use a constant.
|
// we would need to account for that and we could not use a constant.
|
||||||
let mut menu_choices = VerticalMenu::empty().danger(
|
let mut menu_choices = VerticalMenu::empty().danger(
|
||||||
theme::ICON_CANCEL,
|
theme::ICON_CANCEL,
|
||||||
verb_cancel.unwrap_or(TR::buttons__cancel.into()),
|
menu_strings
|
||||||
|
.verb_cancel
|
||||||
|
.unwrap_or(TR::buttons__cancel.into()),
|
||||||
);
|
);
|
||||||
|
|
||||||
if has_info {
|
if menu_strings.has_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,
|
theme::ICON_CHEVRON_RIGHT,
|
||||||
verb_info.unwrap_or(TR::words__title_information.into()),
|
menu_strings
|
||||||
|
.verb_info
|
||||||
|
.unwrap_or(TR::words__title_information.into()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@ pub mod util;
|
|||||||
pub mod warning_hi_prio;
|
pub mod warning_hi_prio;
|
||||||
|
|
||||||
pub use confirm_action::{
|
pub use confirm_action::{
|
||||||
new_confirm_action, new_confirm_action_simple, ConfirmActionExtra, ConfirmActionStrings,
|
new_confirm_action, new_confirm_action_simple, ConfirmActionExtra, ConfirmActionMenuStrings,
|
||||||
|
ConfirmActionStrings,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "universal_fw")]
|
#[cfg(feature = "universal_fw")]
|
||||||
pub use confirm_fido::new_confirm_fido;
|
pub use confirm_fido::new_confirm_fido;
|
||||||
|
@ -3,7 +3,7 @@ use super::{
|
|||||||
component::{Frame, FrameMsg},
|
component::{Frame, FrameMsg},
|
||||||
theme,
|
theme,
|
||||||
},
|
},
|
||||||
ConfirmActionExtra, ConfirmActionStrings,
|
ConfirmActionExtra, ConfirmActionMenuStrings, ConfirmActionStrings,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
error::Error,
|
error::Error,
|
||||||
@ -272,11 +272,11 @@ impl ConfirmBlobParams {
|
|||||||
let confirm_extra = if self.cancel {
|
let confirm_extra = if self.cancel {
|
||||||
ConfirmActionExtra::Cancel
|
ConfirmActionExtra::Cancel
|
||||||
} else {
|
} else {
|
||||||
ConfirmActionExtra::Menu {
|
ConfirmActionExtra::Menu(
|
||||||
verb_cancel: self.verb_cancel,
|
ConfirmActionMenuStrings::new()
|
||||||
has_info: self.info_button,
|
.with_verb_cancel(self.verb_cancel)
|
||||||
verb_info: self.verb_info,
|
.with_info(self.info_button, self.verb_info),
|
||||||
}
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
flow::new_confirm_action_simple(
|
flow::new_confirm_action_simple(
|
||||||
|
@ -55,7 +55,7 @@ use crate::{
|
|||||||
flow::{
|
flow::{
|
||||||
new_confirm_action_simple,
|
new_confirm_action_simple,
|
||||||
util::{ConfirmBlobParams, ShowInfoParams},
|
util::{ConfirmBlobParams, ShowInfoParams},
|
||||||
ConfirmActionExtra, ConfirmActionStrings,
|
ConfirmActionExtra, ConfirmActionMenuStrings, ConfirmActionStrings,
|
||||||
},
|
},
|
||||||
theme::ICON_BULLET_CHECKMARK,
|
theme::ICON_BULLET_CHECKMARK,
|
||||||
},
|
},
|
||||||
@ -246,11 +246,7 @@ extern "C" fn new_confirm_emphasized(n_args: usize, args: *const Obj, kwargs: *m
|
|||||||
|
|
||||||
new_confirm_action_simple(
|
new_confirm_action_simple(
|
||||||
FormattedText::new(ops).vertically_centered(),
|
FormattedText::new(ops).vertically_centered(),
|
||||||
ConfirmActionExtra::Menu {
|
ConfirmActionExtra::Menu(ConfirmActionMenuStrings::new()),
|
||||||
verb_cancel: None,
|
|
||||||
has_info: false,
|
|
||||||
verb_info: None,
|
|
||||||
},
|
|
||||||
ConfirmActionStrings::new(title, None, None, Some(title)),
|
ConfirmActionStrings::new(title, None, None, Some(title)),
|
||||||
false,
|
false,
|
||||||
None,
|
None,
|
||||||
@ -395,11 +391,7 @@ extern "C" fn new_confirm_address(n_args: usize, args: *const Obj, kwargs: *mut
|
|||||||
|
|
||||||
flow::new_confirm_action_simple(
|
flow::new_confirm_action_simple(
|
||||||
paragraphs,
|
paragraphs,
|
||||||
ConfirmActionExtra::Menu {
|
ConfirmActionExtra::Menu(ConfirmActionMenuStrings::new()),
|
||||||
verb_cancel: None,
|
|
||||||
has_info: false,
|
|
||||||
verb_info: None,
|
|
||||||
},
|
|
||||||
ConfirmActionStrings::new(title, None, None, None),
|
ConfirmActionStrings::new(title, None, None, None),
|
||||||
false,
|
false,
|
||||||
None,
|
None,
|
||||||
@ -442,11 +434,7 @@ extern "C" fn new_confirm_properties(n_args: usize, args: *const Obj, kwargs: *m
|
|||||||
|
|
||||||
new_confirm_action_simple(
|
new_confirm_action_simple(
|
||||||
paragraphs.into_paragraphs(),
|
paragraphs.into_paragraphs(),
|
||||||
ConfirmActionExtra::Menu {
|
ConfirmActionExtra::Menu(ConfirmActionMenuStrings::new()),
|
||||||
verb_cancel: None,
|
|
||||||
has_info: false,
|
|
||||||
verb_info: None,
|
|
||||||
},
|
|
||||||
ConfirmActionStrings::new(title, None, None, hold.then_some(title)),
|
ConfirmActionStrings::new(title, None, None, hold.then_some(title)),
|
||||||
hold,
|
hold,
|
||||||
None,
|
None,
|
||||||
@ -476,11 +464,7 @@ extern "C" fn new_confirm_homescreen(n_args: usize, args: *const Obj, kwargs: *m
|
|||||||
|
|
||||||
new_confirm_action_simple(
|
new_confirm_action_simple(
|
||||||
paragraphs,
|
paragraphs,
|
||||||
ConfirmActionExtra::Menu {
|
ConfirmActionExtra::Menu(ConfirmActionMenuStrings::new()),
|
||||||
verb_cancel: None,
|
|
||||||
has_info: false,
|
|
||||||
verb_info: None,
|
|
||||||
},
|
|
||||||
ConfirmActionStrings::new(
|
ConfirmActionStrings::new(
|
||||||
TR::homescreen__settings_title.into(),
|
TR::homescreen__settings_title.into(),
|
||||||
Some(TR::homescreen__settings_subtitle.into()),
|
Some(TR::homescreen__settings_subtitle.into()),
|
||||||
@ -792,11 +776,7 @@ extern "C" fn new_confirm_total(n_args: usize, args: *const Obj, kwargs: *mut Ma
|
|||||||
|
|
||||||
new_confirm_action_simple(
|
new_confirm_action_simple(
|
||||||
paragraphs.into_paragraphs(),
|
paragraphs.into_paragraphs(),
|
||||||
ConfirmActionExtra::Menu {
|
ConfirmActionExtra::Menu(ConfirmActionMenuStrings::new()),
|
||||||
verb_cancel: None,
|
|
||||||
has_info: true,
|
|
||||||
verb_info: None,
|
|
||||||
},
|
|
||||||
ConfirmActionStrings::new(title, None, None, Some(title)),
|
ConfirmActionStrings::new(title, None, None, Some(title)),
|
||||||
true,
|
true,
|
||||||
None,
|
None,
|
||||||
@ -1113,11 +1093,7 @@ extern "C" fn new_confirm_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut
|
|||||||
|
|
||||||
new_confirm_action_simple(
|
new_confirm_action_simple(
|
||||||
paragraphs,
|
paragraphs,
|
||||||
ConfirmActionExtra::Menu {
|
ConfirmActionExtra::Menu(ConfirmActionMenuStrings::new()),
|
||||||
verb_cancel: None,
|
|
||||||
has_info: false,
|
|
||||||
verb_info: None,
|
|
||||||
},
|
|
||||||
ConfirmActionStrings::new(
|
ConfirmActionStrings::new(
|
||||||
TR::coinjoin__title.into(),
|
TR::coinjoin__title.into(),
|
||||||
None,
|
None,
|
||||||
|
Loading…
Reference in New Issue
Block a user