diff --git a/core/.changelog.d/3896.added b/core/.changelog.d/3896.added new file mode 100644 index 000000000..ef241f1d5 --- /dev/null +++ b/core/.changelog.d/3896.added @@ -0,0 +1 @@ +[T3T1] Added menu entry animation diff --git a/core/embed/rust/src/ui/flow/base.rs b/core/embed/rust/src/ui/flow/base.rs index a0e29c91c..2e4657b44 100644 --- a/core/embed/rust/src/ui/flow/base.rs +++ b/core/embed/rust/src/ui/flow/base.rs @@ -1,4 +1,4 @@ -use crate::ui::component::{swipe_detect::SwipeConfig, SwipeDirection}; +use crate::ui::component::{base::AttachType, swipe_detect::SwipeConfig, SwipeDirection}; pub trait Swipable { fn get_swipe_config(&self) -> SwipeConfig; @@ -27,7 +27,7 @@ pub enum Decision { /// Initiate transition to another state, end event processing. /// NOTE: it might make sense to include Option here - Transition(SwipeDirection), + Transition(AttachType), /// Yield a message to the caller of the flow (i.e. micropython), end event /// processing. @@ -76,7 +76,7 @@ pub trait FlowState { pub trait DecisionBuilder: FlowState + Sized { #[inline] fn swipe(&'static self, direction: SwipeDirection) -> StateChange { - (self, Decision::Transition(direction)) + (self, Decision::Transition(AttachType::Swipe(direction))) } #[inline] @@ -99,6 +99,11 @@ pub trait DecisionBuilder: FlowState + Sized { self.swipe(SwipeDirection::Down) } + #[inline] + fn transit(&'static self) -> StateChange { + (self, Decision::Transition(AttachType::Initial)) + } + #[inline] fn do_nothing(&'static self) -> StateChange { (self, Decision::Nothing) diff --git a/core/embed/rust/src/ui/flow/swipe.rs b/core/embed/rust/src/ui/flow/swipe.rs index 396681911..b2a233fe9 100644 --- a/core/embed/rust/src/ui/flow/swipe.rs +++ b/core/embed/rust/src/ui/flow/swipe.rs @@ -7,8 +7,9 @@ use crate::{ }, ui::{ component::{ - base::AttachType, swipe_detect::SwipeSettings, Component, Event, EventCtx, SwipeDetect, - SwipeDetectMsg, SwipeDirection, + base::{AttachType, AttachType::Swipe}, + swipe_detect::SwipeSettings, + Component, Event, EventCtx, SwipeDetect, SwipeDetectMsg, SwipeDirection, }, display::Color, event::{SwipeEvent, TouchEvent}, @@ -147,20 +148,20 @@ impl SwipeFlow { &mut self.store[self.state.index()] } - fn goto(&mut self, ctx: &mut EventCtx, direction: SwipeDirection) { + fn goto(&mut self, ctx: &mut EventCtx, attach_type: AttachType) { self.swipe = SwipeDetect::new(); self.allow_swipe = true; self.current_page_mut() - .event(ctx, Event::Attach(AttachType::Swipe(direction))); + .event(ctx, Event::Attach(attach_type)); self.internal_pages = self.current_page_mut().get_internal_page_count() as u16; - match direction { - SwipeDirection::Up => { + match attach_type { + Swipe(SwipeDirection::Up) => { self.internal_state = 0; } - SwipeDirection::Down => { + Swipe(SwipeDirection::Down) => { self.internal_state = self.internal_pages.saturating_sub(1); } _ => {} @@ -297,7 +298,7 @@ impl SwipeFlow { let config = self.current_page().get_swipe_config(); - if let (_, Decision::Transition(direction)) = state_change { + if let (_, Decision::Transition(Swipe(direction))) = state_change { if config.is_allowed(direction) { if !animation_disabled() { self.swipe.trigger(ctx, direction, config); @@ -317,9 +318,9 @@ impl SwipeFlow { let (new_state, decision) = state_change; self.state = new_state; match decision { - Decision::Transition(direction) => { + Decision::Transition(attach) => { self.state = new_state; - self.goto(ctx, direction); + self.goto(ctx, attach); None } Decision::Return(msg) => { diff --git a/core/embed/rust/src/ui/model_mercury/component/vertical_menu.rs b/core/embed/rust/src/ui/model_mercury/component/vertical_menu.rs index 2504305f3..5480e8f4b 100644 --- a/core/embed/rust/src/ui/model_mercury/component/vertical_menu.rs +++ b/core/embed/rust/src/ui/model_mercury/component/vertical_menu.rs @@ -150,6 +150,7 @@ impl AttachAnimation { self.attach_top = true; self.duration = Duration::from_millis(350); } else { + self.attach_top = false; self.duration = Duration::from_millis(350); } self.reset(); 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 724e162b6..b31250fec 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 @@ -51,12 +51,12 @@ impl FlowState for ConfirmAction { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { - (Self::Intro, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::Intro, FlowMsg::Info) => Self::Menu.transit(), (Self::Menu, FlowMsg::Cancelled) => Self::Intro.swipe_right(), (Self::Menu, FlowMsg::Choice(0)) => self.return_msg(FlowMsg::Cancelled), (Self::Menu, FlowMsg::Choice(1)) => self.return_msg(FlowMsg::Info), (Self::Confirm, FlowMsg::Confirmed) => self.return_msg(FlowMsg::Confirmed), - (Self::Confirm, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::Confirm, FlowMsg::Info) => Self::Menu.transit(), _ => self.do_nothing(), } } @@ -87,7 +87,7 @@ impl FlowState for ConfirmActionSimple { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { - (Self::Intro, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::Intro, FlowMsg::Info) => Self::Menu.transit(), (Self::Menu, FlowMsg::Cancelled) => Self::Intro.swipe_right(), (Self::Menu, FlowMsg::Choice(0)) => self.return_msg(FlowMsg::Cancelled), (Self::Menu, FlowMsg::Choice(1)) => self.return_msg(FlowMsg::Info), diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_output.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_output.rs index a8b612364..013eb402e 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_output.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_output.rs @@ -58,12 +58,12 @@ impl FlowState for ConfirmOutput { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { - (_, FlowMsg::Info) => Self::Menu.swipe_left(), - (Self::Menu, FlowMsg::Choice(0)) => Self::AccountInfo.swipe_left(), + (_, FlowMsg::Info) => Self::Menu.transit(), + (Self::Menu, FlowMsg::Choice(0)) => Self::AccountInfo.transit(), (Self::Menu, FlowMsg::Choice(1)) => Self::CancelTap.swipe_left(), (Self::Menu, FlowMsg::Cancelled) => Self::Address.swipe_right(), (Self::CancelTap, FlowMsg::Confirmed) => self.return_msg(FlowMsg::Cancelled), - (_, FlowMsg::Cancelled) => Self::Menu.swipe_right(), + (_, FlowMsg::Cancelled) => Self::Menu.transit(), _ => self.do_nothing(), } } diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_create.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_create.rs index 513f740d3..9257f2c75 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_create.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_create.rs @@ -50,11 +50,11 @@ impl FlowState for ConfirmResetCreate { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { - (Self::Intro, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::Intro, FlowMsg::Info) => Self::Menu.transit(), (Self::Menu, FlowMsg::Cancelled) => Self::Intro.swipe_right(), (Self::Menu, FlowMsg::Choice(0)) => self.return_msg(FlowMsg::Cancelled), (Self::Confirm, FlowMsg::Confirmed) => self.return_msg(FlowMsg::Confirmed), - (Self::Confirm, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::Confirm, FlowMsg::Info) => Self::Menu.transit(), _ => self.do_nothing(), } } diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_recover.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_recover.rs index 97ce967e2..d3ee4910b 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_recover.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_recover.rs @@ -46,7 +46,7 @@ impl FlowState for ConfirmResetRecover { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { - (Self::Intro, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::Intro, FlowMsg::Info) => Self::Menu.transit(), (Self::Menu, FlowMsg::Cancelled) => Self::Intro.swipe_right(), (Self::Menu, FlowMsg::Choice(0)) => self.return_msg(FlowMsg::Cancelled), _ => self.do_nothing(), diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_pin.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_pin.rs index 8d8923ada..44b871e88 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_pin.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_pin.rs @@ -54,7 +54,7 @@ impl FlowState for SetNewPin { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { - (Self::Intro, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::Intro, FlowMsg::Info) => Self::Menu.transit(), (Self::Menu, FlowMsg::Choice(0)) => Self::CancelPinIntro.swipe_left(), (Self::Menu, FlowMsg::Cancelled) => Self::Intro.swipe_right(), (Self::CancelPinIntro, FlowMsg::Cancelled) => Self::Intro.swipe_right(), diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_summary.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_summary.rs index 6fee0ae4a..f23144302 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_summary.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_summary.rs @@ -55,14 +55,14 @@ impl FlowState for ConfirmSummary { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { - (_, FlowMsg::Info) => Self::Menu.swipe_left(), + (_, FlowMsg::Info) => Self::Menu.transit(), (Self::Hold, FlowMsg::Confirmed) => self.return_msg(FlowMsg::Confirmed), (Self::Menu, FlowMsg::Choice(0)) => Self::FeeInfo.swipe_left(), (Self::Menu, FlowMsg::Choice(1)) => Self::AccountInfo.swipe_left(), (Self::Menu, FlowMsg::Choice(2)) => Self::CancelTap.swipe_left(), (Self::Menu, FlowMsg::Cancelled) => Self::Summary.swipe_right(), (Self::CancelTap, FlowMsg::Confirmed) => self.return_msg(FlowMsg::Cancelled), - (_, FlowMsg::Cancelled) => Self::Menu.swipe_right(), + (_, FlowMsg::Cancelled) => Self::Menu.transit(), _ => self.do_nothing(), } } diff --git a/core/embed/rust/src/ui/model_mercury/flow/get_address.rs b/core/embed/rust/src/ui/model_mercury/flow/get_address.rs index 723806b8a..e545369a0 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/get_address.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/get_address.rs @@ -66,7 +66,7 @@ impl FlowState for GetAddress { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { - (Self::Address, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::Address, FlowMsg::Info) => Self::Menu.transit(), (Self::Tap, FlowMsg::Confirmed) => Self::Confirmed.swipe_up(), (Self::Tap, FlowMsg::Info) => Self::Menu.swipe_left(), (Self::Confirmed, _) => self.return_msg(FlowMsg::Confirmed), @@ -74,11 +74,11 @@ impl FlowState for GetAddress { (Self::Menu, FlowMsg::Choice(1)) => Self::AccountInfo.swipe_left(), (Self::Menu, FlowMsg::Choice(2)) => Self::Cancel.swipe_left(), (Self::Menu, FlowMsg::Cancelled) => Self::Address.swipe_right(), - (Self::QrCode, FlowMsg::Cancelled) => Self::Menu.swipe_right(), - (Self::AccountInfo, FlowMsg::Cancelled) => Self::Menu.swipe_right(), - (Self::Cancel, FlowMsg::Cancelled) => Self::Menu.swipe_right(), + (Self::QrCode, FlowMsg::Cancelled) => Self::Menu.transit(), + (Self::AccountInfo, FlowMsg::Cancelled) => Self::Menu.transit(), + (Self::Cancel, FlowMsg::Cancelled) => Self::Menu.transit(), (Self::CancelTap, FlowMsg::Confirmed) => self.return_msg(FlowMsg::Cancelled), - (Self::CancelTap, FlowMsg::Cancelled) => Self::Menu.swipe_right(), + (Self::CancelTap, FlowMsg::Cancelled) => Self::Menu.transit(), _ => self.do_nothing(), } } diff --git a/core/embed/rust/src/ui/model_mercury/flow/prompt_backup.rs b/core/embed/rust/src/ui/model_mercury/flow/prompt_backup.rs index fdf691199..5b92ecbde 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/prompt_backup.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/prompt_backup.rs @@ -56,10 +56,10 @@ impl FlowState for PromptBackup { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { - (Self::Intro, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::Intro, FlowMsg::Info) => Self::Menu.transit(), (Self::Menu, FlowMsg::Choice(0)) => Self::SkipBackupIntro.swipe_left(), (Self::Menu, FlowMsg::Cancelled) => Self::Intro.swipe_right(), - (Self::SkipBackupIntro, FlowMsg::Cancelled) => Self::Menu.swipe_right(), + (Self::SkipBackupIntro, FlowMsg::Cancelled) => Self::Menu.transit(), (Self::SkipBackupConfirm, FlowMsg::Cancelled) => Self::SkipBackupIntro.swipe_right(), (Self::SkipBackupConfirm, FlowMsg::Confirmed) => self.return_msg(FlowMsg::Cancelled), _ => self.do_nothing(), diff --git a/core/embed/rust/src/ui/model_mercury/flow/request_number.rs b/core/embed/rust/src/ui/model_mercury/flow/request_number.rs index 4aa70ce32..ebb3039ca 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/request_number.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/request_number.rs @@ -51,10 +51,10 @@ impl FlowState for RequestNumber { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { - (Self::Number, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::Number, FlowMsg::Info) => Self::Menu.transit(), (Self::Menu, FlowMsg::Choice(0)) => Self::Info.swipe_left(), (Self::Menu, FlowMsg::Cancelled) => Self::Number.swipe_right(), - (Self::Info, FlowMsg::Cancelled) => Self::Menu.swipe_right(), + (Self::Info, FlowMsg::Cancelled) => Self::Menu.transit(), (Self::Number, FlowMsg::Choice(n)) => self.return_msg(FlowMsg::Choice(n)), _ => self.do_nothing(), } diff --git a/core/embed/rust/src/ui/model_mercury/flow/show_tutorial.rs b/core/embed/rust/src/ui/model_mercury/flow/show_tutorial.rs index bd453b37d..a71b36e90 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/show_tutorial.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/show_tutorial.rs @@ -60,12 +60,12 @@ impl FlowState for ShowTutorial { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { (Self::StepWelcome, FlowMsg::Confirmed) => Self::StepBegin.swipe_up(), - (Self::StepMenu, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::StepMenu, FlowMsg::Info) => Self::Menu.transit(), (Self::Menu, FlowMsg::Choice(0)) => Self::DidYouKnow.swipe_left(), (Self::Menu, FlowMsg::Choice(1)) => Self::StepBegin.swipe_right(), (Self::Menu, FlowMsg::Choice(2)) => Self::HoldToExit.swipe_up(), (Self::Menu, FlowMsg::Cancelled) => Self::StepMenu.swipe_right(), - (Self::DidYouKnow, FlowMsg::Cancelled) => Self::Menu.swipe_right(), + (Self::DidYouKnow, FlowMsg::Cancelled) => Self::Menu.transit(), (Self::StepHold, FlowMsg::Confirmed) => Self::StepDone.swipe_up(), (Self::HoldToExit, FlowMsg::Confirmed) => Self::StepDone.swipe_up(), _ => self.do_nothing(), diff --git a/core/embed/rust/src/ui/model_mercury/flow/warning_hi_prio.rs b/core/embed/rust/src/ui/model_mercury/flow/warning_hi_prio.rs index c4bf1cbe9..45800a118 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/warning_hi_prio.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/warning_hi_prio.rs @@ -47,7 +47,7 @@ impl FlowState for WarningHiPrio { fn handle_event(&'static self, msg: FlowMsg) -> StateChange { match (self, msg) { - (Self::Message, FlowMsg::Info) => Self::Menu.swipe_left(), + (Self::Message, FlowMsg::Info) => Self::Menu.transit(), (Self::Menu, FlowMsg::Choice(1)) => self.return_msg(FlowMsg::Confirmed), (Self::Menu, FlowMsg::Choice(_)) => Self::Cancelled.swipe_up(), (Self::Menu, FlowMsg::Cancelled) => Self::Message.swipe_right(),