1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-19 12:58:13 +00:00

fix(core): tweak swipes in ETH staking flow

This commit is contained in:
Ioan Bizău 2024-09-11 11:13:23 +02:00 committed by Ioan Bizău
parent aa47f951ec
commit f6aa7cbb08
3 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1 @@
[T3T1] Fix swipe in ETH stake flow menu and address confirmation.

View File

@ -142,14 +142,17 @@ impl FlowState for ConfirmOutputWithSummary {
match (self, direction) {
(Self::Main, SwipeDirection::Left) => Self::MainMenu.swipe(direction),
(Self::Main, SwipeDirection::Up) => Self::Summary.swipe(direction),
(Self::MainMenu, SwipeDirection::Right) => Self::Main.swipe(direction),
(Self::AddressInfo, SwipeDirection::Right) => Self::MainMenu.swipe(direction),
(Self::AccountInfo, SwipeDirection::Right) => Self::MainMenu.swipe(direction),
(Self::Summary, SwipeDirection::Left) => Self::SummaryMenu.swipe(direction),
(Self::Summary, SwipeDirection::Up) => Self::Hold.swipe(direction),
(Self::Summary, SwipeDirection::Down) => Self::Main.swipe(direction),
(Self::SummaryMenu, SwipeDirection::Right) => Self::Summary.swipe(direction),
(Self::FeeInfo, SwipeDirection::Right) => Self::SummaryMenu.swipe(direction),
(Self::Hold, SwipeDirection::Left) => Self::HoldMenu.swipe(direction),
(Self::Hold, SwipeDirection::Down) => Self::Summary.swipe(direction),
(Self::HoldMenu, SwipeDirection::Right) => Self::Hold.swipe(direction),
_ => self.do_nothing(),
}
}
@ -260,6 +263,7 @@ fn new_confirm_output_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
.with_footer(TR::instructions__swipe_up.into(), None)
.with_chunkify(chunkify)
.with_text_mono(text_mono)
.with_swipe_up()
.into_layout()?
.one_button_request(ButtonRequest::from_num(br_code, br_name));
@ -307,6 +311,7 @@ fn new_confirm_output_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
.with_menu_button()
.with_footer(TR::instructions__swipe_up.into(), None)
.with_text_mono(text_mono)
.with_swipe_up()
.with_swipe_down()
.into_layout()?
.one_button_request(ButtonRequest::from_num(br_code, br_name));
@ -418,6 +423,7 @@ fn new_confirm_output_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
.with_cancel_button()
.with_chunkify(true)
.with_text_mono(true)
.with_swipe_right()
.into_layout()?;
flow = flow.with_page(&ConfirmOutputWithSummary::AddressInfo, address_content)?;
} else {

View File

@ -33,7 +33,9 @@ pub struct ConfirmBlobParams {
cancel_button: bool,
chunkify: bool,
text_mono: bool,
swipe_up: bool,
swipe_down: bool,
swipe_right: bool,
}
impl ConfirmBlobParams {
@ -54,7 +56,9 @@ impl ConfirmBlobParams {
cancel_button: false,
chunkify: false,
text_mono: true,
swipe_up: false,
swipe_down: false,
swipe_right: false,
}
}
@ -78,11 +82,21 @@ impl ConfirmBlobParams {
self
}
pub const fn with_swipe_up(mut self) -> Self {
self.swipe_up = true;
self
}
pub const fn with_swipe_down(mut self) -> Self {
self.swipe_down = true;
self
}
pub const fn with_swipe_right(mut self) -> Self {
self.swipe_right = true;
self
}
pub const fn with_footer(
mut self,
instruction: TString<'static>,
@ -143,11 +157,18 @@ impl ConfirmBlobParams {
frame = frame.with_swipe(SwipeDirection::Left, SwipeSettings::default());
}
if self.swipe_up {
frame = frame.with_swipe(SwipeDirection::Up, SwipeSettings::default());
}
if self.swipe_down {
frame = frame.with_swipe(SwipeDirection::Down, SwipeSettings::default());
}
frame = frame.with_swipe(SwipeDirection::Up, SwipeSettings::default());
if self.swipe_right {
frame = frame.with_swipe(SwipeDirection::Right, SwipeSettings::default());
}
frame = frame.with_vertical_pages();
Ok(frame.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)))