diff --git a/core/embed/rust/src/ui/component/base.rs b/core/embed/rust/src/ui/component/base.rs index 02e70acc7f..0a37b257ea 100644 --- a/core/embed/rust/src/ui/component/base.rs +++ b/core/embed/rust/src/ui/component/base.rs @@ -1,5 +1,3 @@ -use core::mem; - use heapless::Vec; use crate::{ @@ -18,11 +16,12 @@ use crate::{ use crate::ui::event::ButtonEvent; use crate::ui::event::USBEvent; #[cfg(feature = "touch")] -use crate::ui::event::{SwipeEvent, TouchEvent}; +use crate::ui::{ + event::{SwipeEvent, TouchEvent}, + geometry::Direction, +}; use super::Paginate; -#[cfg(feature = "touch")] -use super::SwipeDirection; /// Type used by components that do not return any messages. /// @@ -101,7 +100,7 @@ impl Child { where F: FnOnce(&mut EventCtx, &mut T) -> U, { - let prev_requested = mem::replace(&mut ctx.paint_requested, false); + let prev_requested = core::mem::replace(&mut ctx.paint_requested, false); let result = component_func(ctx, &mut self.component); if ctx.paint_requested { // If a paint was requested anywhere in the inner component tree, we need to @@ -355,7 +354,7 @@ pub enum AttachType { /// in the given component. Resume, #[cfg(feature = "touch")] - Swipe(SwipeDirection), + Swipe(Direction), } #[derive(Copy, Clone, PartialEq, Eq)] diff --git a/core/embed/rust/src/ui/component/mod.rs b/core/embed/rust/src/ui/component/mod.rs index 199359aed9..0d5e68d9c4 100644 --- a/core/embed/rust/src/ui/component/mod.rs +++ b/core/embed/rust/src/ui/component/mod.rs @@ -44,7 +44,7 @@ pub use paginated::{PageMsg, Paginate}; pub use placed::{FixedHeightBar, Floating, GridPlaced, Split}; pub use qr_code::Qr; #[cfg(feature = "touch")] -pub use swipe::{Swipe, SwipeDirection}; +pub use swipe::Swipe; #[cfg(feature = "touch")] pub use swipe_detect::{SwipeDetect, SwipeDetectMsg}; pub use text::{ diff --git a/core/embed/rust/src/ui/component/swipe.rs b/core/embed/rust/src/ui/component/swipe.rs index 6e697eb132..820ffeb3f1 100644 --- a/core/embed/rust/src/ui/component/swipe.rs +++ b/core/embed/rust/src/ui/component/swipe.rs @@ -1,62 +1,10 @@ use crate::ui::{ component::{Component, Event, EventCtx}, event::TouchEvent, - geometry::{Offset, Point, Rect}, + geometry::{Direction, Point, Rect}, shape::Renderer, }; -#[derive(Copy, Clone, Eq, PartialEq, ToPrimitive, FromPrimitive)] -#[cfg_attr(feature = "debug", derive(ufmt::derive::uDebug))] -pub enum SwipeDirection { - Up, - Down, - Left, - Right, -} - -impl SwipeDirection { - pub fn as_offset(self, size: Offset) -> Offset { - match self { - SwipeDirection::Up => Offset::y(-size.y), - SwipeDirection::Down => Offset::y(size.y), - SwipeDirection::Left => Offset::x(-size.x), - SwipeDirection::Right => Offset::x(size.x), - } - } - - pub fn iter() -> SwipeDirectionIterator { - SwipeDirectionIterator::new() - } -} - -pub struct SwipeDirectionIterator { - current: Option, -} - -impl SwipeDirectionIterator { - pub fn new() -> Self { - SwipeDirectionIterator { - current: Some(SwipeDirection::Up), - } - } -} - -impl Iterator for SwipeDirectionIterator { - type Item = SwipeDirection; - - fn next(&mut self) -> Option { - let next_state = match self.current { - Some(SwipeDirection::Up) => Some(SwipeDirection::Down), - Some(SwipeDirection::Down) => Some(SwipeDirection::Left), - Some(SwipeDirection::Left) => Some(SwipeDirection::Right), - Some(SwipeDirection::Right) => None, - None => None, - }; - - core::mem::replace(&mut self.current, next_state) - } -} - #[derive(Clone)] pub struct Swipe { pub allow_up: bool, @@ -119,7 +67,7 @@ impl Swipe { } impl Component for Swipe { - type Msg = SwipeDirection; + type Msg = Direction; fn place(&mut self, bounds: Rect) -> Rect { bounds @@ -163,18 +111,18 @@ impl Component for Swipe { // Horizontal direction. if self.ratio(abs.x) >= Self::THRESHOLD { if ofs.x < 0 && self.allow_left { - return Some(SwipeDirection::Left); + return Some(Direction::Left); } else if ofs.x > 0 && self.allow_right { - return Some(SwipeDirection::Right); + return Some(Direction::Right); } } } else if abs.x < abs.y && (self.allow_up || self.allow_down) { // Vertical direction. if self.ratio(abs.y) >= Self::THRESHOLD { if ofs.y < 0 && self.allow_up { - return Some(SwipeDirection::Up); + return Some(Direction::Up); } else if ofs.y > 0 && self.allow_down { - return Some(SwipeDirection::Down); + return Some(Direction::Down); } } }; diff --git a/core/embed/rust/src/ui/component/swipe_detect.rs b/core/embed/rust/src/ui/component/swipe_detect.rs index dac7a0ef60..482e832583 100644 --- a/core/embed/rust/src/ui/component/swipe_detect.rs +++ b/core/embed/rust/src/ui/component/swipe_detect.rs @@ -2,10 +2,10 @@ use crate::{ time::{Duration, Instant}, ui::{ animation::Animation, - component::{Event, EventCtx, SwipeDirection}, + component::{Event, EventCtx}, constant::screen, event::TouchEvent, - geometry::{Axis, Offset, Point}, + geometry::{Axis, Direction, Offset, Point}, util::animation_disabled, }, }; @@ -53,12 +53,12 @@ impl SwipeConfig { } } - pub fn with_swipe(mut self, dir: SwipeDirection, settings: SwipeSettings) -> Self { + pub fn with_swipe(mut self, dir: Direction, settings: SwipeSettings) -> Self { self[dir] = Some(settings); self } - pub fn is_allowed(&self, dir: SwipeDirection) -> bool { + pub fn is_allowed(&self, dir: Direction) -> bool { self[dir].is_some() } @@ -66,16 +66,16 @@ impl SwipeConfig { /// direction. /// /// If the swipe direction is not allowed, this will return 0. - pub fn progress(&self, dir: SwipeDirection, movement: Offset, threshold: u16) -> u16 { + pub fn progress(&self, dir: Direction, movement: Offset, threshold: u16) -> u16 { if !self.is_allowed(dir) { return 0; } let correct_movement = match dir { - SwipeDirection::Right => movement.x > 0, - SwipeDirection::Left => movement.x < 0, - SwipeDirection::Down => movement.y > 0, - SwipeDirection::Up => movement.y < 0, + Direction::Right => movement.x > 0, + Direction::Left => movement.x < 0, + Direction::Down => movement.y > 0, + Direction::Up => movement.y < 0, }; if !correct_movement { @@ -85,14 +85,14 @@ impl SwipeConfig { let movement = movement.abs(); match dir { - SwipeDirection::Right => (movement.x as u16).saturating_sub(threshold), - SwipeDirection::Left => (movement.x as u16).saturating_sub(threshold), - SwipeDirection::Down => (movement.y as u16).saturating_sub(threshold), - SwipeDirection::Up => (movement.y as u16).saturating_sub(threshold), + Direction::Right => (movement.x as u16).saturating_sub(threshold), + Direction::Left => (movement.x as u16).saturating_sub(threshold), + Direction::Down => (movement.y as u16).saturating_sub(threshold), + Direction::Up => (movement.y as u16).saturating_sub(threshold), } } - pub fn duration(&self, dir: SwipeDirection) -> Option { + pub fn duration(&self, dir: Direction) -> Option { self[dir].as_ref().map(|s| s.duration) } @@ -131,53 +131,53 @@ impl SwipeConfig { self } - pub fn paging_event(&self, dir: SwipeDirection, current_page: u16, total_pages: u16) -> u16 { + pub fn paging_event(&self, dir: Direction, current_page: u16, total_pages: u16) -> u16 { let prev_page = current_page.saturating_sub(1); let next_page = (current_page + 1).min(total_pages.saturating_sub(1)); match (self.page_axis, dir) { - (Some(Axis::Horizontal), SwipeDirection::Right) => prev_page, - (Some(Axis::Horizontal), SwipeDirection::Left) => next_page, - (Some(Axis::Vertical), SwipeDirection::Down) => prev_page, - (Some(Axis::Vertical), SwipeDirection::Up) => next_page, + (Some(Axis::Horizontal), Direction::Right) => prev_page, + (Some(Axis::Horizontal), Direction::Left) => next_page, + (Some(Axis::Vertical), Direction::Down) => prev_page, + (Some(Axis::Vertical), Direction::Up) => next_page, _ => current_page, } } } -impl core::ops::Index for SwipeConfig { +impl core::ops::Index for SwipeConfig { type Output = Option; - fn index(&self, index: SwipeDirection) -> &Self::Output { + fn index(&self, index: Direction) -> &Self::Output { match index { - SwipeDirection::Up => &self.up, - SwipeDirection::Down => &self.down, - SwipeDirection::Left => &self.left, - SwipeDirection::Right => &self.right, + Direction::Up => &self.up, + Direction::Down => &self.down, + Direction::Left => &self.left, + Direction::Right => &self.right, } } } -impl core::ops::IndexMut for SwipeConfig { - fn index_mut(&mut self, index: SwipeDirection) -> &mut Self::Output { +impl core::ops::IndexMut for SwipeConfig { + fn index_mut(&mut self, index: Direction) -> &mut Self::Output { match index { - SwipeDirection::Up => &mut self.up, - SwipeDirection::Down => &mut self.down, - SwipeDirection::Left => &mut self.left, - SwipeDirection::Right => &mut self.right, + Direction::Up => &mut self.up, + Direction::Down => &mut self.down, + Direction::Left => &mut self.left, + Direction::Right => &mut self.right, } } } #[derive(Copy, Clone, Eq, PartialEq)] pub enum SwipeDetectMsg { - Start(SwipeDirection), - Move(SwipeDirection, u16), - Trigger(SwipeDirection), + Start(Direction), + Move(Direction, u16), + Trigger(Direction), } pub struct SwipeDetect { origin: Option, - locked: Option, + locked: Option, final_animation: Option>, moved: u16, } @@ -204,25 +204,25 @@ impl SwipeDetect { } } - fn min_lock(&self, dir: SwipeDirection) -> u16 { + fn min_lock(&self, dir: Direction) -> u16 { match dir { - SwipeDirection::Up | SwipeDirection::Down => Self::MIN_LOCK as u16, - SwipeDirection::Left | SwipeDirection::Right => { + Direction::Up | Direction::Down => Self::MIN_LOCK as u16, + Direction::Left | Direction::Right => { (Self::MIN_LOCK * Self::VERTICAL_PREFERENCE) as u16 } } } - fn min_trigger(&self, dir: SwipeDirection) -> u16 { + fn min_trigger(&self, dir: Direction) -> u16 { match dir { - SwipeDirection::Up | SwipeDirection::Down => Self::MIN_TRIGGER as u16, - SwipeDirection::Left | SwipeDirection::Right => { + Direction::Up | Direction::Down => Self::MIN_TRIGGER as u16, + Direction::Left | Direction::Right => { (Self::MIN_TRIGGER * Self::VERTICAL_PREFERENCE) as u16 } } } - fn is_lockable(&self, dir: SwipeDirection) -> bool { + fn is_lockable(&self, dir: Direction) -> bool { let Some(origin) = self.origin else { return false; }; @@ -230,10 +230,10 @@ impl SwipeDetect { let min_distance = self.min_trigger(dir) as i16; match dir { - SwipeDirection::Up => origin.y > min_distance, - SwipeDirection::Down => origin.y < (screen().height() - min_distance), - SwipeDirection::Left => origin.x > min_distance, - SwipeDirection::Right => origin.x < (screen().width() - min_distance), + Direction::Up => origin.y > min_distance, + Direction::Down => origin.y < (screen().height() - min_distance), + Direction::Left => origin.x > min_distance, + Direction::Right => origin.x < (screen().width() - min_distance), } } @@ -281,7 +281,7 @@ impl SwipeDetect { None } - pub fn trigger(&mut self, ctx: &mut EventCtx, dir: SwipeDirection, config: SwipeConfig) { + pub fn trigger(&mut self, ctx: &mut EventCtx, dir: Direction, config: SwipeConfig) { ctx.request_anim_frame(); ctx.request_paint(); @@ -334,7 +334,7 @@ impl SwipeDetect { } None => { let mut res = None; - for dir in SwipeDirection::iter() { + for dir in Direction::iter() { let progress = config.progress(dir, ofs, self.min_lock(dir)); if progress > 0 && self.is_lockable(dir) { self.locked = Some(dir); diff --git a/core/embed/rust/src/ui/event.rs b/core/embed/rust/src/ui/event.rs index a0b7587ef9..7e629a4c26 100644 --- a/core/embed/rust/src/ui/event.rs +++ b/core/embed/rust/src/ui/event.rs @@ -2,7 +2,7 @@ use crate::{error, ui::geometry::Point}; use core::convert::TryInto; #[cfg(feature = "touch")] -use crate::ui::component::SwipeDirection; +use crate::ui::geometry::Direction; #[derive(Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "debug", derive(ufmt::derive::uDebug))] @@ -79,6 +79,6 @@ pub enum USBEvent { #[derive(Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "debug", derive(ufmt::derive::uDebug))] pub enum SwipeEvent { - Move(SwipeDirection, i16), - End(SwipeDirection), + Move(Direction, i16), + End(Direction), } diff --git a/core/embed/rust/src/ui/flow/base.rs b/core/embed/rust/src/ui/flow/base.rs index d9b1ab9b71..d16bd3ec86 100644 --- a/core/embed/rust/src/ui/flow/base.rs +++ b/core/embed/rust/src/ui/flow/base.rs @@ -1,4 +1,7 @@ -use crate::ui::component::{base::AttachType, swipe_detect::SwipeConfig, SwipeDirection}; +use crate::ui::{ + component::{base::AttachType, swipe_detect::SwipeConfig}, + geometry::Direction, +}; pub use crate::ui::component::FlowMsg; @@ -34,11 +37,12 @@ impl Decision { /// Flow state type /// -/// It is a static dyn reference to a FlowController, which, due to this, is required to -/// be a plain enum type. Its concrete values then are individual states. +/// It is a static dyn reference to a FlowController, which, due to this, is +/// required to be a plain enum type. Its concrete values then are individual +/// states. /// -/// By convention, a Decision emitted by a controller must embed a reference to the same -/// type of controller. +/// By convention, a Decision emitted by a controller must embed a reference to +/// the same type of controller. pub type FlowState = &'static dyn FlowController; /// Encodes the flow logic as a set of states, and transitions between them @@ -50,7 +54,7 @@ pub trait FlowController { /// By convention, the type of the new state inside the state change must be /// Self. This can't be enforced by the type system unfortunately, because /// this trait must remain object-safe and so can't refer to Self. - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision; + fn handle_swipe(&'static self, direction: Direction) -> Decision; /// What to do when the current component emits a message in response to an /// event. @@ -67,28 +71,28 @@ pub trait FlowController { /// Helper trait for writing nicer flow logic. pub trait DecisionBuilder: FlowController + Sized { #[inline] - fn swipe(&'static self, direction: SwipeDirection) -> Decision { + fn swipe(&'static self, direction: Direction) -> Decision { Decision::Transition(self, AttachType::Swipe(direction)) } #[inline] fn swipe_left(&'static self) -> Decision { - self.swipe(SwipeDirection::Left) + self.swipe(Direction::Left) } #[inline] fn swipe_right(&'static self) -> Decision { - self.swipe(SwipeDirection::Right) + self.swipe(Direction::Right) } #[inline] fn swipe_up(&'static self) -> Decision { - self.swipe(SwipeDirection::Up) + self.swipe(Direction::Up) } #[inline] fn swipe_down(&'static self) -> Decision { - self.swipe(SwipeDirection::Down) + self.swipe(Direction::Down) } #[inline] diff --git a/core/embed/rust/src/ui/flow/page.rs b/core/embed/rust/src/ui/flow/page.rs index b5138699c6..476ea1b72a 100644 --- a/core/embed/rust/src/ui/flow/page.rs +++ b/core/embed/rust/src/ui/flow/page.rs @@ -1,7 +1,7 @@ use crate::ui::{ - component::{Component, Event, EventCtx, Paginate, SwipeDirection}, + component::{Component, Event, EventCtx, Paginate}, event::SwipeEvent, - geometry::{Axis, Rect}, + geometry::{Axis, Direction, Rect}, shape::Renderer, }; @@ -55,22 +55,22 @@ impl Component for SwipePage { if let Event::Swipe(SwipeEvent::End(direction)) = event { match (self.axis, direction) { - (Axis::Vertical, SwipeDirection::Up) => { + (Axis::Vertical, Direction::Up) => { self.current = (self.current + 1).min(self.pages - 1); self.inner.change_page(self.current); ctx.request_paint(); } - (Axis::Vertical, SwipeDirection::Down) => { + (Axis::Vertical, Direction::Down) => { self.current = self.current.saturating_sub(1); self.inner.change_page(self.current); ctx.request_paint(); } - (Axis::Horizontal, SwipeDirection::Left) => { + (Axis::Horizontal, Direction::Left) => { self.current = (self.current + 1).min(self.pages - 1); self.inner.change_page(self.current); ctx.request_paint(); } - (Axis::Horizontal, SwipeDirection::Right) => { + (Axis::Horizontal, Direction::Right) => { self.current = self.current.saturating_sub(1); self.inner.change_page(self.current); ctx.request_paint(); diff --git a/core/embed/rust/src/ui/flow/swipe.rs b/core/embed/rust/src/ui/flow/swipe.rs index 3bc3c2a657..e702f6ea6f 100644 --- a/core/embed/rust/src/ui/flow/swipe.rs +++ b/core/embed/rust/src/ui/flow/swipe.rs @@ -8,12 +8,12 @@ use crate::{ ui::{ component::{ base::AttachType::{self, Swipe}, - Component, Event, EventCtx, FlowMsg, SwipeDetect, SwipeDetectMsg, SwipeDirection, + Component, Event, EventCtx, FlowMsg, SwipeDetect, SwipeDetectMsg, }, display::Color, event::{SwipeEvent, TouchEvent}, flow::{base::Decision, FlowController}, - geometry::Rect, + geometry::{Direction, Rect}, layout::obj::ObjComponent, shape::{render_on_display, ConcreteRenderer, Renderer, ScopedRenderer}, util::animation_disabled, @@ -157,10 +157,10 @@ impl SwipeFlow { self.internal_pages = self.current_page_mut().get_internal_page_count() as u16; match attach_type { - Swipe(SwipeDirection::Up) => { + Swipe(Direction::Up) => { self.internal_state = 0; } - Swipe(SwipeDirection::Down) => { + Swipe(Direction::Down) => { self.internal_state = self.internal_pages.saturating_sub(1); } _ => {} @@ -173,7 +173,7 @@ impl SwipeFlow { self.store[state].render(target); } - fn handle_swipe_child(&mut self, _ctx: &mut EventCtx, direction: SwipeDirection) -> Decision { + fn handle_swipe_child(&mut self, _ctx: &mut EventCtx, direction: Direction) -> Decision { self.state.handle_swipe(direction) } diff --git a/core/embed/rust/src/ui/geometry.rs b/core/embed/rust/src/ui/geometry.rs index 632b5811d0..50a9c1e275 100644 --- a/core/embed/rust/src/ui/geometry.rs +++ b/core/embed/rust/src/ui/geometry.rs @@ -804,3 +804,55 @@ pub trait Dimensions { fn fit(&mut self, bounds: Rect); fn area(&self) -> Rect; } + +#[derive(Copy, Clone, Eq, PartialEq, ToPrimitive, FromPrimitive)] +#[cfg_attr(feature = "debug", derive(ufmt::derive::uDebug))] +pub enum Direction { + Up, + Down, + Left, + Right, +} + +impl Direction { + pub fn as_offset(self, size: Offset) -> Offset { + match self { + Direction::Up => Offset::y(-size.y), + Direction::Down => Offset::y(size.y), + Direction::Left => Offset::x(-size.x), + Direction::Right => Offset::x(size.x), + } + } + + pub fn iter() -> DirectionIterator { + DirectionIterator::new() + } +} + +pub struct DirectionIterator { + current: Option, +} + +impl DirectionIterator { + pub fn new() -> Self { + DirectionIterator { + current: Some(Direction::Up), + } + } +} + +impl Iterator for DirectionIterator { + type Item = Direction; + + fn next(&mut self) -> Option { + let next_state = match self.current { + Some(Direction::Up) => Some(Direction::Down), + Some(Direction::Down) => Some(Direction::Left), + Some(Direction::Left) => Some(Direction::Right), + Some(Direction::Right) => None, + None => None, + }; + + core::mem::replace(&mut self.current, next_state) + } +} diff --git a/core/embed/rust/src/ui/layout/obj.rs b/core/embed/rust/src/ui/layout/obj.rs index dc4f4a6741..cad01cbba1 100644 --- a/core/embed/rust/src/ui/layout/obj.rs +++ b/core/embed/rust/src/ui/layout/obj.rs @@ -7,10 +7,10 @@ use num_traits::{FromPrimitive, ToPrimitive}; #[cfg(feature = "button")] use crate::ui::event::ButtonEvent; -#[cfg(feature = "touch")] -use crate::ui::{component::SwipeDirection, event::TouchEvent}; #[cfg(feature = "new_rendering")] use crate::ui::{display::Color, shape::render_on_display}; +#[cfg(feature = "touch")] +use crate::ui::{event::TouchEvent, geometry::Direction}; use crate::{ error::Error, maybe_trace::MaybeTrace, @@ -55,7 +55,7 @@ impl AttachType { 1 => Ok(Self::Resume), #[cfg(feature = "touch")] 2..=5 => Ok(Self::Swipe( - SwipeDirection::from_u8(val - 2).ok_or(Error::TypeError)?, + Direction::from_u8(val - 2).ok_or(Error::TypeError)?, )), _ => Err(Error::TypeError), } diff --git a/core/embed/rust/src/ui/model_mercury/component/address_details.rs b/core/embed/rust/src/ui/model_mercury/component/address_details.rs index d5149f4d65..928e81567e 100644 --- a/core/embed/rust/src/ui/model_mercury/component/address_details.rs +++ b/core/embed/rust/src/ui/model_mercury/component/address_details.rs @@ -8,11 +8,11 @@ use crate::{ component::{ swipe_detect::{SwipeConfig, SwipeSettings}, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt}, - Component, Event, EventCtx, Paginate, SwipeDirection, + Component, Event, EventCtx, Paginate, }, event::SwipeEvent, flow::Swipable, - geometry::Rect, + geometry::{Direction, Rect}, shape::Renderer, }, }; @@ -60,7 +60,7 @@ impl AddressDetails { let result = Self { details: Frame::left_aligned(details_title, para.into_paragraphs()) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .with_horizontal_pages(), xpub_view: Frame::left_aligned( " \n ".into(), @@ -151,11 +151,11 @@ impl Component for AddressDetails { fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option { ctx.set_page_count(self.page_count()); match event { - Event::Swipe(SwipeEvent::End(SwipeDirection::Right)) => { + Event::Swipe(SwipeEvent::End(Direction::Right)) => { let to_page = self.current_page.saturating_sub(1); self.change_page(to_page); } - Event::Swipe(SwipeEvent::End(SwipeDirection::Left)) => { + Event::Swipe(SwipeEvent::End(Direction::Left)) => { let to_page = self .current_page .saturating_add(1) diff --git a/core/embed/rust/src/ui/model_mercury/component/footer.rs b/core/embed/rust/src/ui/model_mercury/component/footer.rs index fd5836027a..dd5b45027a 100644 --- a/core/embed/rust/src/ui/model_mercury/component/footer.rs +++ b/core/embed/rust/src/ui/model_mercury/component/footer.rs @@ -1,10 +1,10 @@ use crate::{ strutil::TString, ui::{ - component::{text::TextStyle, Component, Event, EventCtx, Never, SwipeDirection}, + component::{text::TextStyle, Component, Event, EventCtx, Never}, display::{Color, Font}, event::SwipeEvent, - geometry::{Alignment, Alignment2D, Offset, Point, Rect}, + geometry::{Alignment, Alignment2D, Direction, Offset, Point, Rect}, lerp::Lerp, model_mercury::theme, shape, @@ -26,7 +26,7 @@ pub struct Footer<'a> { swipe_allow_up: bool, swipe_allow_down: bool, progress: i16, - dir: SwipeDirection, + dir: Direction, } #[derive(Clone)] @@ -53,7 +53,7 @@ impl<'a> Footer<'a> { swipe_allow_down: false, swipe_allow_up: false, progress: 0, - dir: SwipeDirection::Up, + dir: Direction::Up, } } @@ -140,13 +140,13 @@ impl<'a> Footer<'a> { self.content.height() } - pub fn with_swipe(self, swipe_direction: SwipeDirection) -> Self { + pub fn with_swipe(self, swipe_direction: Direction) -> Self { match swipe_direction { - SwipeDirection::Up => Self { + Direction::Up => Self { swipe_allow_up: true, ..self }, - SwipeDirection::Down => Self { + Direction::Down => Self { swipe_allow_down: true, ..self }, @@ -170,13 +170,13 @@ impl<'a> Component for Footer<'a> { self.progress = 0; } Event::Swipe(SwipeEvent::Move(dir, progress)) => match dir { - SwipeDirection::Up => { + Direction::Up => { if self.swipe_allow_up { self.progress = progress; self.dir = dir; } } - SwipeDirection::Down => { + Direction::Down => { if self.swipe_allow_down { self.progress = progress; self.dir = dir; @@ -209,8 +209,8 @@ impl<'a> Component for Footer<'a> { let mask = u8::lerp(0, 255, shift.eval(progress)); let offset = match self.dir { - SwipeDirection::Up => Offset::y(-offset), - SwipeDirection::Down => Offset::y(3 * offset), + Direction::Up => Offset::y(-offset), + Direction::Down => Offset::y(3 * offset), _ => Offset::zero(), }; diff --git a/core/embed/rust/src/ui/model_mercury/component/frame.rs b/core/embed/rust/src/ui/model_mercury/component/frame.rs index ecc4533a80..ad66aa587f 100644 --- a/core/embed/rust/src/ui/model_mercury/component/frame.rs +++ b/core/embed/rust/src/ui/model_mercury/component/frame.rs @@ -7,11 +7,11 @@ use crate::{ text::TextStyle, Component, Event::{self, Swipe}, - EventCtx, FlowMsg, SwipeDetect, SwipeDirection, + EventCtx, FlowMsg, SwipeDetect, }, display::{Color, Icon}, event::SwipeEvent, - geometry::{Alignment, Insets, Point, Rect}, + geometry::{Alignment, Direction, Insets, Point, Rect}, lerp::Lerp, model_mercury::theme::TITLE_HEIGHT, shape::{self, Renderer}, @@ -21,14 +21,14 @@ use crate::{ #[derive(Clone)] pub struct HorizontalSwipe { progress: i16, - dir: SwipeDirection, + dir: Direction, } impl HorizontalSwipe { const fn new() -> Self { Self { progress: 0, - dir: SwipeDirection::Up, + dir: Direction::Up, } } @@ -40,7 +40,7 @@ impl HorizontalSwipe { if let Swipe(SwipeEvent::Move(dir, progress)) = event { if swipe.is_allowed(dir) { match dir { - SwipeDirection::Left | SwipeDirection::Right => { + Direction::Left | Direction::Right => { self.progress = progress; self.dir = dir; } @@ -53,7 +53,7 @@ impl HorizontalSwipe { fn render_swipe_cover<'s>(&self, target: &mut impl Renderer<'s>, bounds: Rect) { if self.progress > 0 { match self.dir { - SwipeDirection::Left => { + Direction::Left => { let shift = pareen::constant(0.0).seq_ease_out( 0.0, easer::functions::Circ, @@ -72,7 +72,7 @@ impl HorizontalSwipe { .with_bg(theme::BLACK) .render(target); } - SwipeDirection::Right => {} + Direction::Right => {} _ => {} } } @@ -246,7 +246,7 @@ where } #[inline(never)] - pub fn with_swipe(mut self, dir: SwipeDirection, settings: SwipeSettings) -> Self { + pub fn with_swipe(mut self, dir: Direction, settings: SwipeSettings) -> Self { self.footer = self.footer.map(|f| f.with_swipe(dir)); self.swipe = self.swipe.with_swipe(dir, settings); self diff --git a/core/embed/rust/src/ui/model_mercury/component/keyboard/passphrase.rs b/core/embed/rust/src/ui/model_mercury/component/keyboard/passphrase.rs index eab5648903..afca80497e 100644 --- a/core/embed/rust/src/ui/model_mercury/component/keyboard/passphrase.rs +++ b/core/embed/rust/src/ui/model_mercury/component/keyboard/passphrase.rs @@ -4,10 +4,10 @@ use crate::{ ui::{ component::{ base::ComponentExt, swipe_detect::SwipeConfig, text::common::TextBox, Component, Event, - EventCtx, Label, Maybe, Never, Swipe, SwipeDirection, + EventCtx, Label, Maybe, Never, Swipe, }, display, - geometry::{Alignment, Grid, Insets, Offset, Rect}, + geometry::{Alignment, Direction, Grid, Insets, Offset, Rect}, model_mercury::{ component::{ button::{Button, ButtonContent, ButtonMsg}, @@ -179,11 +179,11 @@ impl PassphraseKeyboard { } } - fn on_page_change(&mut self, ctx: &mut EventCtx, swipe: SwipeDirection) { + fn on_page_change(&mut self, ctx: &mut EventCtx, swipe: Direction) { // Change the keyboard layout. self.active_layout = match swipe { - SwipeDirection::Left => self.active_layout.next(), - SwipeDirection::Right => self.active_layout.prev(), + Direction::Left => self.active_layout.next(), + Direction::Right => self.active_layout.prev(), _ => self.active_layout, }; // Clear the pending state. @@ -331,7 +331,7 @@ impl Component for PassphraseKeyboard { return None; } if let Some(ButtonMsg::Clicked) = self.next_btn.event(ctx, event) { - self.on_page_change(ctx, SwipeDirection::Left); + self.on_page_change(ctx, Direction::Left); } // Confirm button was clicked, we're done. diff --git a/core/embed/rust/src/ui/model_mercury/component/keyboard/pin.rs b/core/embed/rust/src/ui/model_mercury/component/keyboard/pin.rs index 868508d462..62c3b9137c 100644 --- a/core/embed/rust/src/ui/model_mercury/component/keyboard/pin.rs +++ b/core/embed/rust/src/ui/model_mercury/component/keyboard/pin.rs @@ -8,11 +8,11 @@ use crate::{ component::{ base::{AttachType, ComponentExt}, text::TextStyle, - Component, Event, EventCtx, Label, Never, Pad, SwipeDirection, TimerToken, + Component, Event, EventCtx, Label, Never, Pad, TimerToken, }, display::Font, event::TouchEvent, - geometry::{Alignment, Alignment2D, Grid, Insets, Offset, Rect}, + geometry::{Alignment, Alignment2D, Direction, Grid, Insets, Offset, Rect}, model_mercury::{ component::{ button::{ @@ -124,8 +124,8 @@ impl AttachAnimation { fn lazy_start(&mut self, ctx: &mut EventCtx, event: Event) { if let Event::Attach(_) = event { - if let Event::Attach(AttachType::Swipe(SwipeDirection::Up)) - | Event::Attach(AttachType::Swipe(SwipeDirection::Down)) + if let Event::Attach(AttachType::Swipe(Direction::Up)) + | Event::Attach(AttachType::Swipe(Direction::Down)) | Event::Attach(AttachType::Initial) = event { self.attach_top = true; diff --git a/core/embed/rust/src/ui/model_mercury/component/number_input.rs b/core/embed/rust/src/ui/model_mercury/component/number_input.rs index caa725ae45..4a8e449fd0 100644 --- a/core/embed/rust/src/ui/model_mercury/component/number_input.rs +++ b/core/embed/rust/src/ui/model_mercury/component/number_input.rs @@ -4,11 +4,11 @@ use crate::{ ui::{ component::{ text::paragraphs::{Paragraph, Paragraphs}, - Component, Event, EventCtx, Pad, SwipeDirection, + Component, Event, EventCtx, Pad, }, display::Font, event::SwipeEvent, - geometry::{Alignment, Grid, Insets, Offset, Rect}, + geometry::{Alignment, Direction, Grid, Insets, Offset, Rect}, shape::{self, Renderer}, }, }; @@ -66,7 +66,7 @@ impl Component for NumberInputDialog { return Some(NumberInputDialogMsg::Changed(i)); } - if let Event::Swipe(SwipeEvent::End(SwipeDirection::Up)) = event { + if let Event::Swipe(SwipeEvent::End(Direction::Up)) = event { return Some(NumberInputDialogMsg::Confirmed(self.input.value)); } self.paragraphs.event(ctx, event); diff --git a/core/embed/rust/src/ui/model_mercury/component/share_words.rs b/core/embed/rust/src/ui/model_mercury/component/share_words.rs index bb8dac64de..51061ce0a2 100644 --- a/core/embed/rust/src/ui/model_mercury/component/share_words.rs +++ b/core/embed/rust/src/ui/model_mercury/component/share_words.rs @@ -3,11 +3,9 @@ use crate::{ strutil::TString, translations::TR, ui::{ - component::{ - base::AttachType, text::TextStyle, Component, Event, EventCtx, Never, SwipeDirection, - }, + component::{base::AttachType, text::TextStyle, Component, Event, EventCtx, Never}, event::SwipeEvent, - geometry::{Alignment, Alignment2D, Insets, Offset, Rect}, + geometry::{Alignment, Alignment2D, Direction, Insets, Offset, Rect}, model_mercury::component::{swipe_content::SwipeAttachAnimation, InternallySwipable}, shape::{self, Renderer}, }, @@ -99,24 +97,24 @@ impl<'a> ShareWords<'a> { }); } - fn should_animate_progress(&self) -> (SwipeDirection, bool) { + fn should_animate_progress(&self) -> (Direction, bool) { let (dir, should_animate) = if self.page_index < self.next_index { - (SwipeDirection::Up, !self.is_final_page()) + (Direction::Up, !self.is_final_page()) } else { - (SwipeDirection::Down, !self.is_first_page()) + (Direction::Down, !self.is_first_page()) }; (dir, should_animate) } - fn should_animate_attach(&self, event: Event) -> (SwipeDirection, bool) { + fn should_animate_attach(&self, event: Event) -> (Direction, bool) { match event { - Event::Attach(AttachType::Swipe(SwipeDirection::Up)) => { - (SwipeDirection::Up, !self.is_first_page()) + Event::Attach(AttachType::Swipe(Direction::Up)) => { + (Direction::Up, !self.is_first_page()) } - Event::Attach(AttachType::Swipe(SwipeDirection::Down)) => { - (SwipeDirection::Down, !self.is_final_page()) + Event::Attach(AttachType::Swipe(Direction::Down)) => { + (Direction::Down, !self.is_final_page()) } - _ => (SwipeDirection::Up, false), + _ => (Direction::Up, false), } } } @@ -154,13 +152,13 @@ impl<'a> Component for ShareWords<'a> { } } Event::Swipe(SwipeEvent::End(dir)) => match dir { - SwipeDirection::Up if !self.is_final_page() => { + Direction::Up if !self.is_final_page() => { self.progress = 0; self.page_index = (self.page_index + 1).min(self.share_words.len() as i16 - 1); self.wait_for_attach = true; ctx.request_paint(); } - SwipeDirection::Down if !self.is_first_page() => { + Direction::Down if !self.is_first_page() => { self.progress = 0; self.page_index = self.page_index.saturating_sub(1); self.wait_for_attach = true; @@ -170,11 +168,11 @@ impl<'a> Component for ShareWords<'a> { }, Event::Swipe(SwipeEvent::Move(dir, progress)) => { match dir { - SwipeDirection::Up => { + Direction::Up => { self.next_index = self.page_index + 1; self.progress = progress; } - SwipeDirection::Down => { + Direction::Down => { self.next_index = self.page_index - 1; self.progress = progress; } diff --git a/core/embed/rust/src/ui/model_mercury/component/swipe_content.rs b/core/embed/rust/src/ui/model_mercury/component/swipe_content.rs index 8e484f084d..5d8e3bee99 100644 --- a/core/embed/rust/src/ui/model_mercury/component/swipe_content.rs +++ b/core/embed/rust/src/ui/model_mercury/component/swipe_content.rs @@ -1,11 +1,11 @@ use crate::{ time::{Duration, Stopwatch}, ui::{ - component::{base::AttachType, Component, Event, EventCtx, SwipeDirection}, + component::{base::AttachType, Component, Event, EventCtx}, constant::screen, display::Color, event::SwipeEvent, - geometry::{Offset, Rect}, + geometry::{Direction, Offset, Rect}, lerp::Lerp, shape::{self, Renderer}, util::animation_disabled, @@ -60,10 +60,10 @@ impl SwipeAttachAnimation { Offset::lerp(Offset::new(0, -max_offset), Offset::zero(), value.eval(t)) } Some(AttachType::Swipe(dir)) => match dir { - SwipeDirection::Up => { + Direction::Up => { Offset::lerp(Offset::new(0, max_offset), Offset::zero(), value.eval(t)) } - SwipeDirection::Down => { + Direction::Down => { Offset::lerp(Offset::new(0, -max_offset), Offset::zero(), value.eval(t)) } _ => Offset::zero(), @@ -81,8 +81,8 @@ impl SwipeAttachAnimation { ); match self.attach_type { Some(AttachType::Initial) - | Some(AttachType::Swipe(SwipeDirection::Up)) - | Some(AttachType::Swipe(SwipeDirection::Down)) => {} + | Some(AttachType::Swipe(Direction::Up)) + | Some(AttachType::Swipe(Direction::Down)) => {} _ => { return 255; } @@ -128,7 +128,7 @@ impl SwipeAttachAnimation { struct SwipeContext { progress: i16, - dir: SwipeDirection, + dir: Direction, attach_animation: SwipeAttachAnimation, } @@ -136,7 +136,7 @@ impl SwipeContext { fn new() -> Self { Self { progress: 0, - dir: SwipeDirection::Up, + dir: Direction::Up, attach_animation: SwipeAttachAnimation::new(), } } @@ -159,11 +159,11 @@ impl SwipeContext { if self.progress > 0 { match self.dir { - SwipeDirection::Up => { + Direction::Up => { offset = Offset::y(-y_offset); mask = u8::lerp(0, 255, shift.eval(progress)); } - SwipeDirection::Down => { + Direction::Down => { offset = Offset::y(y_offset); clip = screen(); mask = u8::lerp(0, 255, shift.eval(progress)); @@ -193,7 +193,7 @@ impl SwipeContext { if let Event::Swipe(SwipeEvent::Move(dir, progress)) = event { match dir { - SwipeDirection::Up | SwipeDirection::Down => { + Direction::Up | Direction::Down => { if animate { self.dir = dir; self.progress = progress; @@ -320,8 +320,8 @@ where let is_last_page = self.content.inner.current_page() == (self.content.inner.num_pages() - 1); - let is_swipe_up = matches!(attach_type, AttachType::Swipe(SwipeDirection::Up)); - let is_swipe_down = matches!(attach_type, AttachType::Swipe(SwipeDirection::Down)); + let is_swipe_up = matches!(attach_type, AttachType::Swipe(Direction::Up)); + let is_swipe_down = matches!(attach_type, AttachType::Swipe(Direction::Down)); if !self.content.swipe_context.attach_animation.show_attach_anim { return false; @@ -338,13 +338,13 @@ where false } - fn should_animate_swipe(&self, swipe_direction: SwipeDirection) -> bool { + fn should_animate_swipe(&self, swipe_direction: Direction) -> bool { let is_first_page = self.content.inner.current_page() == 0; let is_last_page = self.content.inner.current_page() == (self.content.inner.num_pages() - 1); - let is_swipe_up = matches!(swipe_direction, SwipeDirection::Up); - let is_swipe_down = matches!(swipe_direction, SwipeDirection::Down); + let is_swipe_up = matches!(swipe_direction, Direction::Up); + let is_swipe_down = matches!(swipe_direction, Direction::Down); if is_last_page && is_swipe_up { return true; 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 11c3ae18c2..bc82d304a3 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 @@ -7,11 +7,11 @@ use crate::{ ui::{ component::{ base::{AttachType, Component}, - Event, EventCtx, Paginate, SwipeDirection, + Event, EventCtx, Paginate, }, constant::screen, display::{Color, Icon}, - geometry::{Offset, Rect}, + geometry::{Direction, Offset, Rect}, lerp::Lerp, model_mercury::component::button::{Button, ButtonContent, ButtonMsg, IconText}, shape::{Bar, Renderer}, @@ -138,8 +138,8 @@ impl AttachAnimation { fn lazy_start(&mut self, ctx: &mut EventCtx, event: Event) { if let Event::Attach(_) = event { - if let Event::Attach(AttachType::Swipe(SwipeDirection::Up)) - | Event::Attach(AttachType::Swipe(SwipeDirection::Down)) + if let Event::Attach(AttachType::Swipe(Direction::Up)) + | Event::Attach(AttachType::Swipe(Direction::Down)) | Event::Attach(AttachType::Initial) = event { self.attach_top = true; 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 b688e4603c..0e2913f320 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 @@ -8,12 +8,13 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, VecExt}, - Component, ComponentExt, Paginate, SwipeDirection, + Component, ComponentExt, Paginate, }, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, SwipePage, }, + geometry::Direction, layout::obj::LayoutObj, }, }; @@ -37,13 +38,13 @@ impl FlowController for ConfirmAction { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Intro, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Intro.swipe(direction), - (Self::Intro, SwipeDirection::Up) => Self::Confirm.swipe(direction), - (Self::Confirm, SwipeDirection::Down) => Self::Intro.swipe(direction), - (Self::Confirm, SwipeDirection::Left) => Self::Menu.swipe(direction), + (Self::Intro, Direction::Left) => Self::Menu.swipe(direction), + (Self::Menu, Direction::Right) => Self::Intro.swipe(direction), + (Self::Intro, Direction::Up) => Self::Confirm.swipe(direction), + (Self::Confirm, Direction::Down) => Self::Intro.swipe(direction), + (Self::Confirm, Direction::Left) => Self::Menu.swipe(direction), _ => self.do_nothing(), } } @@ -75,11 +76,11 @@ impl FlowController for ConfirmActionSimple { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Intro, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Intro.swipe(direction), - (Self::Intro, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::Intro, Direction::Left) => Self::Menu.swipe(direction), + (Self::Menu, Direction::Right) => Self::Intro.swipe(direction), + (Self::Intro, Direction::Up) => self.return_msg(FlowMsg::Confirmed), _ => self.do_nothing(), } } @@ -164,8 +165,8 @@ pub fn new_confirm_action_uni( let mut content_intro = Frame::left_aligned(title, content) .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .with_vertical_pages(); if let Some(subtitle) = subtitle { @@ -245,7 +246,7 @@ fn create_menu( } let content_menu = Frame::left_aligned("".into(), menu_choices) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()); + .with_swipe(Direction::Right, SwipeSettings::immediate()); let content_menu = content_menu.map(move |msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), @@ -281,8 +282,8 @@ fn create_confirm( let mut content_confirm = Frame::left_aligned(prompt_title, SwipeContent::new(prompt)) .with_footer(prompt_action, None) .with_menu_button() - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()); + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()); if let Some(subtitle) = subtitle { content_confirm = content_confirm.with_subtitle(subtitle); diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_fido.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_fido.rs index 872a55292d..24a5991c61 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_fido.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_fido.rs @@ -7,12 +7,13 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, Paragraphs}, - ComponentExt, EventCtx, SwipeDirection, + ComponentExt, EventCtx, }, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, SwipePage, }, + geometry::Direction, layout::obj::LayoutObj, }, }; @@ -45,13 +46,13 @@ impl FlowController for ConfirmFido { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Intro, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Intro, SwipeDirection::Up) => Self::ChooseCredential.swipe(direction), - (Self::ChooseCredential, SwipeDirection::Down) => Self::Intro.swipe(direction), - (Self::Details, SwipeDirection::Up) => Self::Tap.swipe(direction), - (Self::Tap, SwipeDirection::Down) => Self::Details.swipe(direction), + (Self::Intro, Direction::Left) => Self::Menu.swipe(direction), + (Self::Intro, Direction::Up) => Self::ChooseCredential.swipe(direction), + (Self::ChooseCredential, Direction::Down) => Self::Intro.swipe(direction), + (Self::Details, Direction::Up) => Self::Tap.swipe(direction), + (Self::Tap, Direction::Down) => Self::Details.swipe(direction), _ => self.do_nothing(), } } @@ -120,8 +121,8 @@ impl ConfirmFido { ) .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)); // Closure to lazy-load the information on given page index. @@ -150,8 +151,8 @@ impl ConfirmFido { TR::instructions__swipe_down.into(), ) .register_footer_update_fn(footer_update_fn) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .with_vertical_pages() .map(|msg| match msg { FrameMsg::Button(_) => Some(FlowMsg::Info), @@ -168,8 +169,8 @@ impl ConfirmFido { SwipeContent::new(FidoCredential::new(icon_name, app_name, get_account)), ) .with_footer(TR::instructions__swipe_up.into(), Some(title)) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()); + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()); let content_details = if Self::single_cred() { content_details.with_menu_button() } else { @@ -183,8 +184,8 @@ impl ConfirmFido { let content_tap = Frame::left_aligned(title, PromptScreen::new_tap_to_confirm()) .with_menu_button() .with_footer(TR::instructions__tap_to_confirm.into(), None) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Button(_) => Some(FlowMsg::Info), @@ -196,7 +197,7 @@ impl ConfirmFido { VerticalMenu::empty().danger(theme::ICON_CANCEL, TR::buttons__cancel.into()), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_firmware_update.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_firmware_update.rs index 84027dcb94..0beb2484a9 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_firmware_update.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_firmware_update.rs @@ -7,12 +7,13 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, Paragraphs}, - ComponentExt, SwipeDirection, + ComponentExt, }, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, }, }; @@ -38,14 +39,14 @@ impl FlowController for ConfirmFirmwareUpdate { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Intro, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Intro, SwipeDirection::Up) => Self::Confirm.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Intro.swipe(direction), - (Self::Fingerprint, SwipeDirection::Right) => Self::Menu.swipe(direction), - (Self::Confirm, SwipeDirection::Down) => Self::Intro.swipe(direction), - (Self::Confirm, SwipeDirection::Left) => Self::Menu.swipe(direction), + (Self::Intro, Direction::Left) => Self::Menu.swipe(direction), + (Self::Intro, Direction::Up) => Self::Confirm.swipe(direction), + (Self::Menu, Direction::Right) => Self::Intro.swipe(direction), + (Self::Fingerprint, Direction::Right) => Self::Menu.swipe(direction), + (Self::Confirm, Direction::Down) => Self::Intro.swipe(direction), + (Self::Confirm, Direction::Left) => Self::Menu.swipe(direction), _ => self.do_nothing(), } } @@ -85,8 +86,8 @@ impl ConfirmFirmwareUpdate { ) .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| matches!(msg, FrameMsg::Button(FlowMsg::Info)).then_some(FlowMsg::Info)); let content_menu = Frame::left_aligned( @@ -99,7 +100,7 @@ impl ConfirmFirmwareUpdate { .danger(theme::ICON_CANCEL, TR::buttons__cancel.into()), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), @@ -112,7 +113,7 @@ impl ConfirmFirmwareUpdate { SwipeContent::new(paragraphs_fingerprint), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::default()) .map(|msg| { matches!(msg, FrameMsg::Button(FlowMsg::Cancelled)).then_some(FlowMsg::Cancelled) }); @@ -123,8 +124,8 @@ impl ConfirmFirmwareUpdate { ) .with_menu_button() .with_footer(TR::instructions__hold_to_confirm.into(), None) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| match msg { FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Button(_) => Some(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 a917f7566d..5aa3b2a8f8 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 @@ -7,13 +7,12 @@ use crate::{ translations::TR, ui::{ button_request::ButtonRequest, - component::{ - swipe_detect::SwipeSettings, ButtonRequestExt, ComponentExt, MsgMap, SwipeDirection, - }, + component::{swipe_detect::SwipeSettings, ButtonRequestExt, ComponentExt, MsgMap}, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, }, }; @@ -48,15 +47,13 @@ impl FlowController for ConfirmOutput { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Address, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Address, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), - (Self::Menu, SwipeDirection::Right) => Self::Address.swipe(direction), - (Self::Menu, SwipeDirection::Left) => Self::AccountInfo.swipe(direction), - (Self::AccountInfo | Self::CancelTap, SwipeDirection::Right) => { - Self::Menu.swipe(direction) - } + (Self::Address, Direction::Left) => Self::Menu.swipe(direction), + (Self::Address, Direction::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::Menu, Direction::Right) => Self::Address.swipe(direction), + (Self::Menu, Direction::Left) => Self::AccountInfo.swipe(direction), + (Self::AccountInfo | Self::CancelTap, Direction::Right) => Self::Menu.swipe(direction), _ => self.do_nothing(), } } @@ -89,16 +86,14 @@ impl FlowController for ConfirmOutputWithAmount { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Address | Self::Amount, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Address, SwipeDirection::Up) => Self::Amount.swipe(direction), - (Self::Amount, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), - (Self::Amount, SwipeDirection::Down) => Self::Address.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Address.swipe(direction), - (Self::AccountInfo | Self::CancelTap, SwipeDirection::Right) => { - Self::Menu.swipe(direction) - } + (Self::Address | Self::Amount, Direction::Left) => Self::Menu.swipe(direction), + (Self::Address, Direction::Up) => Self::Amount.swipe(direction), + (Self::Amount, Direction::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::Amount, Direction::Down) => Self::Address.swipe(direction), + (Self::Menu, Direction::Right) => Self::Address.swipe(direction), + (Self::AccountInfo | Self::CancelTap, Direction::Right) => Self::Menu.swipe(direction), _ => self.do_nothing(), } } @@ -138,21 +133,21 @@ impl FlowController for ConfirmOutputWithSummary { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { 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::Main, Direction::Left) => Self::MainMenu.swipe(direction), + (Self::Main, Direction::Up) => Self::Summary.swipe(direction), + (Self::MainMenu, Direction::Right) => Self::Main.swipe(direction), + (Self::AddressInfo, Direction::Right) => Self::MainMenu.swipe(direction), + (Self::AccountInfo, Direction::Right) => Self::MainMenu.swipe(direction), + (Self::Summary, Direction::Left) => Self::SummaryMenu.swipe(direction), + (Self::Summary, Direction::Up) => Self::Hold.swipe(direction), + (Self::Summary, Direction::Down) => Self::Main.swipe(direction), + (Self::SummaryMenu, Direction::Right) => Self::Summary.swipe(direction), + (Self::FeeInfo, Direction::Right) => Self::SummaryMenu.swipe(direction), + (Self::Hold, Direction::Left) => Self::HoldMenu.swipe(direction), + (Self::Hold, Direction::Down) => Self::Summary.swipe(direction), + (Self::HoldMenu, Direction::Right) => Self::Hold.swipe(direction), _ => self.do_nothing(), } } @@ -208,8 +203,8 @@ fn get_cancel_page( ) .with_cancel_button() .with_footer(TR::instructions__tap_to_confirm.into(), None) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| match msg { FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), @@ -292,7 +287,7 @@ fn new_confirm_output_obj(_args: &[Obj], kwargs: &Map) -> Result { let selected_item = main_menu_items[i]; @@ -350,8 +345,8 @@ fn new_confirm_output_obj(_args: &[Obj], kwargs: &Map) -> Result Some(FlowMsg::Confirmed), FrameMsg::Button(_) => Some(FlowMsg::Info), @@ -387,7 +382,7 @@ fn new_confirm_output_obj(_args: &[Obj], kwargs: &Map) -> Result { let selected_item = summary_menu_items[i]; @@ -403,7 +398,7 @@ fn new_confirm_output_obj(_args: &[Obj], kwargs: &Map) -> Result { Some(FlowMsg::Choice(MENU_ITEM_CANCEL)) diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_reset.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_reset.rs index 4be7adc663..b3d763c1a0 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_reset.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_reset.rs @@ -8,12 +8,13 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort}, - ButtonRequestExt, ComponentExt, SwipeDirection, + ButtonRequestExt, ComponentExt, }, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, }, }; @@ -38,13 +39,13 @@ impl FlowController for ConfirmResetCreate { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Intro, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Intro, SwipeDirection::Up) => Self::Confirm.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Intro.swipe(direction), - (Self::Confirm, SwipeDirection::Down) => Self::Intro.swipe(direction), - (Self::Confirm, SwipeDirection::Left) => Self::Menu.swipe(direction), + (Self::Intro, Direction::Left) => Self::Menu.swipe(direction), + (Self::Intro, Direction::Up) => Self::Confirm.swipe(direction), + (Self::Menu, Direction::Right) => Self::Intro.swipe(direction), + (Self::Confirm, Direction::Down) => Self::Intro.swipe(direction), + (Self::Confirm, Direction::Left) => Self::Menu.swipe(direction), _ => self.do_nothing(), } } @@ -73,11 +74,11 @@ impl FlowController for ConfirmResetRecover { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Intro, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Intro.swipe(direction), - (Self::Intro, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::Intro, Direction::Left) => Self::Menu.swipe(direction), + (Self::Menu, Direction::Right) => Self::Intro.swipe(direction), + (Self::Intro, Direction::Up) => self.return_msg(FlowMsg::Confirmed), _ => self.do_nothing(), } } @@ -126,8 +127,8 @@ fn new_confirm_reset_obj(_args: &[Obj], kwargs: &Map) -> Result Result Some(FlowMsg::Choice(i)), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), @@ -153,8 +154,8 @@ fn new_confirm_reset_obj(_args: &[Obj], kwargs: &Map) -> Result Some(FlowMsg::Confirmed), FrameMsg::Button(_) => Some(FlowMsg::Info), 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 ec5d68ec61..5eb55da026 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 @@ -7,12 +7,13 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs}, - ComponentExt, SwipeDirection, + ComponentExt, }, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, model_mercury::component::SwipeContent, }, @@ -37,15 +38,15 @@ impl FlowController for SetNewPin { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Intro, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Intro, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), - (Self::Menu, SwipeDirection::Right) => Self::Intro.swipe(direction), - (Self::CancelPinIntro, SwipeDirection::Up) => Self::CancelPinConfirm.swipe(direction), - (Self::CancelPinIntro, SwipeDirection::Right) => Self::Intro.swipe(direction), - (Self::CancelPinConfirm, SwipeDirection::Down) => Self::CancelPinIntro.swipe(direction), - (Self::CancelPinConfirm, SwipeDirection::Right) => Self::Intro.swipe(direction), + (Self::Intro, Direction::Left) => Self::Menu.swipe(direction), + (Self::Intro, Direction::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::Menu, Direction::Right) => Self::Intro.swipe(direction), + (Self::CancelPinIntro, Direction::Up) => Self::CancelPinConfirm.swipe(direction), + (Self::CancelPinIntro, Direction::Right) => Self::Intro.swipe(direction), + (Self::CancelPinConfirm, Direction::Down) => Self::CancelPinIntro.swipe(direction), + (Self::CancelPinConfirm, Direction::Right) => Self::Intro.swipe(direction), _ => self.do_nothing(), } } @@ -78,8 +79,8 @@ impl SetNewPin { let content_intro = Frame::left_aligned(title, SwipeContent::new(paragraphs)) .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| match msg { FrameMsg::Button(bm) => Some(bm), _ => None, @@ -90,7 +91,7 @@ impl SetNewPin { VerticalMenu::empty().danger(theme::ICON_CANCEL, TR::pin__cancel_setup.into()), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), @@ -111,8 +112,8 @@ impl SetNewPin { TR::instructions__swipe_up.into(), Some(TR::pin__cancel_description.into()), ) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Button(bm) => Some(bm), _ => None, @@ -124,8 +125,8 @@ impl SetNewPin { ) .with_cancel_button() .with_footer(TR::instructions__tap_to_confirm.into(), None) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), 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 715220fa52..8df9baa749 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 @@ -7,11 +7,12 @@ use crate::{ translations::TR, ui::{ button_request::ButtonRequest, - component::{swipe_detect::SwipeSettings, ButtonRequestExt, ComponentExt, SwipeDirection}, + component::{swipe_detect::SwipeSettings, ButtonRequestExt, ComponentExt}, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, model_mercury::component::SwipeContent, }, @@ -47,13 +48,13 @@ impl FlowController for ConfirmSummary { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Summary | Self::Hold, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Summary, SwipeDirection::Up) => Self::Hold.swipe(direction), - (Self::Hold, SwipeDirection::Down) => Self::Summary.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Summary.swipe(direction), - (Self::AccountInfo | Self::FeeInfo | Self::CancelTap, SwipeDirection::Right) => { + (Self::Summary | Self::Hold, Direction::Left) => Self::Menu.swipe(direction), + (Self::Summary, Direction::Up) => Self::Hold.swipe(direction), + (Self::Hold, Direction::Down) => Self::Summary.swipe(direction), + (Self::Menu, Direction::Right) => Self::Summary.swipe(direction), + (Self::AccountInfo | Self::FeeInfo | Self::CancelTap, Direction::Right) => { Self::Menu.swipe(direction) } _ => self.do_nothing(), @@ -113,8 +114,8 @@ impl ConfirmSummary { ) .with_menu_button() .with_footer(TR::instructions__hold_to_sign.into(), None) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| match msg { FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Button(_) => Some(FlowMsg::Info), @@ -165,7 +166,7 @@ impl ConfirmSummary { unwrap!(menu_items.push(MENU_ITEM_CANCEL)); let content_menu = Frame::left_aligned(TString::empty(), menu) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(move |msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => { let selected_item = menu_items[i]; @@ -181,7 +182,7 @@ impl ConfirmSummary { ) .with_cancel_button() .with_footer(TR::instructions__tap_to_confirm.into(), None) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), diff --git a/core/embed/rust/src/ui/model_mercury/flow/continue_recovery.rs b/core/embed/rust/src/ui/model_mercury/flow/continue_recovery.rs index dcd7b3705c..d8b2218018 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/continue_recovery.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/continue_recovery.rs @@ -11,12 +11,13 @@ use crate::{ text::paragraphs::{ Paragraph, ParagraphSource, ParagraphVecLong, ParagraphVecShort, Paragraphs, VecExt, }, - ComponentExt, EventCtx, SwipeDirection, + ComponentExt, EventCtx, }, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, SwipePage, }, + geometry::Direction, layout::{obj::LayoutObj, util::RecoveryType}, }, }; @@ -58,11 +59,11 @@ impl FlowController for ContinueRecoveryBeforeShares { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Main, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Main.swipe(direction), - (Self::Main, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::Main, Direction::Left) => Self::Menu.swipe(direction), + (Self::Menu, Direction::Right) => Self::Main.swipe(direction), + (Self::Main, Direction::Up) => self.return_msg(FlowMsg::Confirmed), _ => self.do_nothing(), } } @@ -83,14 +84,14 @@ impl FlowController for ContinueRecoveryBetweenShares { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Main, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Main.swipe(direction), - (Self::Main, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), - (Self::CancelIntro, SwipeDirection::Up) => Self::CancelConfirm.swipe(direction), - (Self::CancelIntro, SwipeDirection::Right) => Self::Menu.swipe(direction), - (Self::CancelConfirm, SwipeDirection::Down) => Self::CancelIntro.swipe(direction), + (Self::Main, Direction::Left) => Self::Menu.swipe(direction), + (Self::Menu, Direction::Right) => Self::Main.swipe(direction), + (Self::Main, Direction::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::CancelIntro, Direction::Up) => Self::CancelConfirm.swipe(direction), + (Self::CancelIntro, Direction::Right) => Self::Menu.swipe(direction), + (Self::CancelConfirm, Direction::Down) => Self::CancelIntro.swipe(direction), _ => self.do_nothing(), } } @@ -114,15 +115,15 @@ impl FlowController for ContinueRecoveryBetweenSharesAdvanced { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Main, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Main.swipe(direction), - (Self::Main, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), - (Self::CancelIntro, SwipeDirection::Up) => Self::CancelConfirm.swipe(direction), - (Self::CancelIntro, SwipeDirection::Right) => Self::Menu.swipe(direction), - (Self::CancelConfirm, SwipeDirection::Down) => Self::CancelIntro.swipe(direction), - (Self::RemainingShares, SwipeDirection::Right) => Self::Menu.swipe(direction), + (Self::Main, Direction::Left) => Self::Menu.swipe(direction), + (Self::Menu, Direction::Right) => Self::Main.swipe(direction), + (Self::Main, Direction::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::CancelIntro, Direction::Up) => Self::CancelConfirm.swipe(direction), + (Self::CancelIntro, Direction::Right) => Self::Menu.swipe(direction), + (Self::CancelConfirm, Direction::Down) => Self::CancelIntro.swipe(direction), + (Self::RemainingShares, Direction::Right) => Self::Menu.swipe(direction), _ => self.do_nothing(), } } @@ -215,8 +216,8 @@ fn new_obj(_args: &[Obj], kwargs: &Map) -> Result { .with_subtitle(TR::words__instructions.into()) .with_menu_button() .with_footer(footer_instruction, footer_description) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)) .repeated_button_request(ButtonRequest::new( ButtonRequestCode::RecoveryHomepage, @@ -236,8 +237,8 @@ fn new_obj(_args: &[Obj], kwargs: &Map) -> Result { TR::instructions__swipe_up.into(), Some(TR::words__continue_anyway.into()), ) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), _ => None, @@ -253,8 +254,8 @@ fn new_obj(_args: &[Obj], kwargs: &Map) -> Result { ) .with_cancel_button() .with_footer(TR::instructions__tap_to_confirm.into(), None) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), @@ -267,7 +268,7 @@ fn new_obj(_args: &[Obj], kwargs: &Map) -> Result { VerticalMenu::empty().danger(theme::ICON_CANCEL, cancel_btn.into()), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), @@ -282,7 +283,7 @@ fn new_obj(_args: &[Obj], kwargs: &Map) -> Result { VerticalMenu::empty().danger(theme::ICON_CANCEL, cancel_btn.into()), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), @@ -310,7 +311,7 @@ fn new_obj(_args: &[Obj], kwargs: &Map) -> Result { .danger(theme::ICON_CANCEL, cancel_btn.into()), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), @@ -333,8 +334,8 @@ fn new_obj(_args: &[Obj], kwargs: &Map) -> Result { TR::instructions__swipe_down.into(), ) .register_footer_update_fn(footer_update_fn) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .with_vertical_pages() .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled)) .repeated_button_request(ButtonRequest::new( 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 0eb0532804..eda7695ae4 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 @@ -8,12 +8,13 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, Paragraphs}, - ButtonRequestExt, ComponentExt, Qr, SwipeDirection, + ButtonRequestExt, ComponentExt, Qr, }, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, SwipePage, }, + geometry::Direction, layout::{obj::LayoutObj, util::ConfirmBlob}, }, }; @@ -46,19 +47,19 @@ impl FlowController for GetAddress { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Address, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Address, SwipeDirection::Up) => Self::Tap.swipe(direction), - (Self::Tap, SwipeDirection::Down) => Self::Address.swipe(direction), - (Self::Tap, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Address.swipe(direction), - (Self::QrCode, SwipeDirection::Right) => Self::Menu.swipe(direction), - (Self::AccountInfo, SwipeDirection::Right) => Self::Menu.swipe_right(), - (Self::Cancel, SwipeDirection::Up) => Self::CancelTap.swipe(direction), - (Self::Cancel, SwipeDirection::Right) => Self::Menu.swipe(direction), - (Self::CancelTap, SwipeDirection::Down) => Self::Cancel.swipe(direction), - (Self::CancelTap, SwipeDirection::Right) => Self::Menu.swipe(direction), + (Self::Address, Direction::Left) => Self::Menu.swipe(direction), + (Self::Address, Direction::Up) => Self::Tap.swipe(direction), + (Self::Tap, Direction::Down) => Self::Address.swipe(direction), + (Self::Tap, Direction::Left) => Self::Menu.swipe(direction), + (Self::Menu, Direction::Right) => Self::Address.swipe(direction), + (Self::QrCode, Direction::Right) => Self::Menu.swipe(direction), + (Self::AccountInfo, Direction::Right) => Self::Menu.swipe_right(), + (Self::Cancel, Direction::Up) => Self::CancelTap.swipe(direction), + (Self::Cancel, Direction::Right) => Self::Menu.swipe(direction), + (Self::CancelTap, Direction::Down) => Self::Cancel.swipe(direction), + (Self::CancelTap, Direction::Right) => Self::Menu.swipe(direction), _ => self.do_nothing(), } } @@ -127,8 +128,8 @@ impl GetAddress { Frame::left_aligned(title, SwipeContent::new(SwipePage::vertical(paragraphs))) .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .with_vertical_pages() .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)) .one_button_request(ButtonRequest::from_num(br_code, br_name)) @@ -139,8 +140,8 @@ impl GetAddress { let content_tap = Frame::left_aligned(title, SwipeContent::new(PromptScreen::new_tap_to_confirm())) .with_footer(TR::instructions__tap_to_confirm.into(), None) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| match msg { FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Button(_) => Some(FlowMsg::Info), @@ -167,7 +168,7 @@ impl GetAddress { .danger(theme::ICON_CANCEL, TR::address__cancel_receive.into()), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), @@ -181,7 +182,7 @@ impl GetAddress { .with_border(QR_BORDER), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled)); // AccountInfo @@ -202,8 +203,8 @@ impl GetAddress { ) .with_cancel_button() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled)); // CancelTap @@ -213,8 +214,8 @@ impl GetAddress { ) .with_cancel_button() .with_footer(TR::instructions__tap_to_confirm.into(), None) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), 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 29f84301f5..4ffc88ac45 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 @@ -7,12 +7,13 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs}, - ComponentExt, SwipeDirection, + ComponentExt, }, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, }, }; @@ -38,17 +39,15 @@ impl FlowController for PromptBackup { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Intro, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Intro, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), - (Self::Menu, SwipeDirection::Right) => Self::Intro.swipe(direction), - (Self::SkipBackupIntro, SwipeDirection::Up) => Self::SkipBackupConfirm.swipe(direction), - (Self::SkipBackupIntro, SwipeDirection::Right) => Self::Intro.swipe(direction), - (Self::SkipBackupConfirm, SwipeDirection::Down) => { - Self::SkipBackupIntro.swipe(direction) - } - (Self::SkipBackupConfirm, SwipeDirection::Right) => Self::Intro.swipe(direction), + (Self::Intro, Direction::Left) => Self::Menu.swipe(direction), + (Self::Intro, Direction::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::Menu, Direction::Right) => Self::Intro.swipe(direction), + (Self::SkipBackupIntro, Direction::Up) => Self::SkipBackupConfirm.swipe(direction), + (Self::SkipBackupIntro, Direction::Right) => Self::Intro.swipe(direction), + (Self::SkipBackupConfirm, Direction::Down) => Self::SkipBackupIntro.swipe(direction), + (Self::SkipBackupConfirm, Direction::Right) => Self::Intro.swipe(direction), _ => self.do_nothing(), } } @@ -80,8 +79,8 @@ impl PromptBackup { let content_intro = Frame::left_aligned(title, SwipeContent::new(paragraphs)) .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| match msg { FrameMsg::Button(bm) => Some(bm), _ => None, @@ -92,7 +91,7 @@ impl PromptBackup { VerticalMenu::empty().danger(theme::ICON_CANCEL, TR::backup__title_skip.into()), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), @@ -116,8 +115,8 @@ impl PromptBackup { TR::instructions__swipe_up.into(), Some(TR::words__continue_anyway.into()), ) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), _ => None, @@ -129,8 +128,8 @@ impl PromptBackup { ) .with_cancel_button() .with_footer(TR::instructions__tap_to_confirm.into(), None) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), 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 8f49fa4d29..b12b3dd93a 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 @@ -5,11 +5,12 @@ use crate::{ translations::TR, ui::{ button_request::ButtonRequest, - component::{swipe_detect::SwipeSettings, ButtonRequestExt, ComponentExt, SwipeDirection}, + component::{swipe_detect::SwipeSettings, ButtonRequestExt, ComponentExt}, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, }, }; @@ -37,11 +38,11 @@ impl FlowController for RequestNumber { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Number, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Number.swipe(direction), - (Self::Info, SwipeDirection::Right) => Self::Menu.swipe(direction), + (Self::Number, Direction::Left) => Self::Menu.swipe(direction), + (Self::Menu, Direction::Right) => Self::Number.swipe(direction), + (Self::Info, Direction::Right) => Self::Menu.swipe(direction), _ => self.do_nothing(), } } @@ -91,8 +92,8 @@ impl RequestNumber { Frame::left_aligned(title, SwipeContent::new(number_input_dialog)) .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| match msg { FrameMsg::Button(_) => Some(FlowMsg::Info), FrameMsg::Content(NumberInputDialogMsg::Changed(n)) => { @@ -111,7 +112,7 @@ impl RequestNumber { VerticalMenu::empty().item(theme::ICON_CHEVRON_RIGHT, TR::buttons__more_info.into()), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), @@ -121,7 +122,7 @@ impl RequestNumber { let updatable_info = UpdatableMoreInfo::new(info_cb); let content_info = Frame::left_aligned(TString::empty(), SwipeContent::new(updatable_info)) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), _ => None, diff --git a/core/embed/rust/src/ui/model_mercury/flow/request_passphrase.rs b/core/embed/rust/src/ui/model_mercury/flow/request_passphrase.rs index 892583dea5..7a01f0a0e3 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/request_passphrase.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/request_passphrase.rs @@ -4,11 +4,12 @@ use crate::{ strutil::{ShortString, TString}, translations::TR, ui::{ - component::{ComponentExt, SwipeDirection}, + component::ComponentExt, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, }, }; @@ -29,7 +30,7 @@ impl FlowController for RequestPassphrase { *self as usize } - fn handle_swipe(&'static self, _direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, _direction: Direction) -> Decision { self.do_nothing() } diff --git a/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs b/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs index 77f8cd9875..c194dcd95e 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs @@ -7,11 +7,12 @@ use crate::{ translations::TR, trezorhal::display, ui::{ - component::{base::ComponentExt, swipe_detect::SwipeSettings, FlowMsg, SwipeDirection}, + component::{base::ComponentExt, swipe_detect::SwipeSettings, FlowMsg}, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, }, }; @@ -39,13 +40,13 @@ impl FlowController for SetBrightness { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Menu, SwipeDirection::Right) => Self::Slider.swipe(direction), - (Self::Slider, SwipeDirection::Up) => Self::Confirm.swipe(direction), - (Self::Confirm, SwipeDirection::Down) => Self::Slider.swipe(direction), - (Self::Confirm, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Confirmed, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::Menu, Direction::Right) => Self::Slider.swipe(direction), + (Self::Slider, Direction::Up) => Self::Confirm.swipe(direction), + (Self::Confirm, Direction::Down) => Self::Slider.swipe(direction), + (Self::Confirm, Direction::Left) => Self::Menu.swipe(direction), + (Self::Confirmed, Direction::Up) => self.return_msg(FlowMsg::Confirmed), _ => self.do_nothing(), } } @@ -83,7 +84,7 @@ impl SetBrightness { ) .with_subtitle(TR::homescreen__settings_subtitle.into()) .with_menu_button() - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) .map(|msg| match msg { FrameMsg::Content(NumberInputSliderDialogMsg::Changed(n)) => { display::backlight(n as _); @@ -98,7 +99,7 @@ impl SetBrightness { VerticalMenu::empty().danger(theme::ICON_CANCEL, TR::buttons__cancel.into()), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(move |msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), @@ -110,8 +111,8 @@ impl SetBrightness { ) .with_footer(TR::instructions__tap_to_confirm.into(), None) .with_menu_button() - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Down, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .map(move |msg| match msg { FrameMsg::Content(PromptMsg::Confirmed) => { let _ = storage::set_brightness(BRIGHTNESS.load(Ordering::Relaxed)); @@ -129,7 +130,7 @@ impl SetBrightness { .with_no_attach_anim(), ) .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) .map(move |_msg| Some(FlowMsg::Confirmed)); let res = SwipeFlow::new(&SetBrightness::Slider)? diff --git a/core/embed/rust/src/ui/model_mercury/flow/show_share_words.rs b/core/embed/rust/src/ui/model_mercury/flow/show_share_words.rs index b46464ae38..e23010c38d 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/show_share_words.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/show_share_words.rs @@ -8,12 +8,13 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt}, - ButtonRequestExt, ComponentExt, EventCtx, SwipeDirection, + ButtonRequestExt, ComponentExt, EventCtx, }, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, model_mercury::component::{InternallySwipable, InternallySwipableContent, SwipeContent}, }, @@ -39,13 +40,13 @@ impl FlowController for ShowShareWords { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Instruction, SwipeDirection::Up) => Self::Words.swipe(direction), - (Self::Confirm, SwipeDirection::Down) => Self::Words.swipe(direction), - (Self::Words, SwipeDirection::Up) => Self::Confirm.swipe(direction), - (Self::Words, SwipeDirection::Down) => Self::Instruction.swipe(direction), - (Self::CheckBackupIntro, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::Instruction, Direction::Up) => Self::Words.swipe(direction), + (Self::Confirm, Direction::Down) => Self::Words.swipe(direction), + (Self::Words, Direction::Up) => Self::Confirm.swipe(direction), + (Self::Words, Direction::Down) => Self::Instruction.swipe(direction), + (Self::CheckBackupIntro, Direction::Up) => self.return_msg(FlowMsg::Confirmed), _ => self.do_nothing(), } } @@ -113,7 +114,7 @@ impl ShowShareWords { ) .with_subtitle(TR::words__instructions.into()) .with_footer(TR::instructions__swipe_up.into(), description) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) .map(|msg| matches!(msg, FrameMsg::Content(_)).then_some(FlowMsg::Confirmed)) .one_button_request(ButtonRequestCode::ResetDevice.with_name("share_words")) .with_pages(move |_| nwords + 2); @@ -123,8 +124,8 @@ impl ShowShareWords { title, InternallySwipableContent::new(ShareWords::new(share_words_vec, subtitle)), ) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Down, SwipeSettings::default()) .with_vertical_pages() .with_subtitle(subtitle) .register_header_update_fn(header_updating_func) @@ -137,7 +138,7 @@ impl ShowShareWords { SwipeContent::new(PromptScreen::new_hold_to_confirm()), ) .with_footer(TR::instructions__hold_to_confirm.into(), None) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) + .with_swipe(Direction::Down, SwipeSettings::default()) .map(|_| Some(FlowMsg::Confirmed)); let content_check_backup_intro = Frame::left_aligned( @@ -148,7 +149,7 @@ impl ShowShareWords { ))), ) .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) .map(|_| Some(FlowMsg::Confirmed)); let res = SwipeFlow::new(&ShowShareWords::Instruction)? 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 1a98c9de8f..8e9c9f722a 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 @@ -6,12 +6,13 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, Paragraphs}, - ComponentExt, SwipeDirection, + ComponentExt, }, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, }, }; @@ -42,18 +43,18 @@ impl FlowController for ShowTutorial { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::StepBegin, SwipeDirection::Up) => Self::StepNavigation.swipe(direction), - (Self::StepNavigation, SwipeDirection::Up) => Self::StepMenu.swipe(direction), - (Self::StepNavigation, SwipeDirection::Down) => Self::StepBegin.swipe(direction), - (Self::StepMenu, SwipeDirection::Up) => Self::StepHold.swipe(direction), - (Self::StepMenu, SwipeDirection::Down) => Self::StepNavigation.swipe(direction), - (Self::StepMenu, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Menu, SwipeDirection::Left) => Self::DidYouKnow.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::StepBegin.swipe(direction), - (Self::DidYouKnow, SwipeDirection::Right) => Self::Menu.swipe(direction), - (Self::StepDone, SwipeDirection::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::StepBegin, Direction::Up) => Self::StepNavigation.swipe(direction), + (Self::StepNavigation, Direction::Up) => Self::StepMenu.swipe(direction), + (Self::StepNavigation, Direction::Down) => Self::StepBegin.swipe(direction), + (Self::StepMenu, Direction::Up) => Self::StepHold.swipe(direction), + (Self::StepMenu, Direction::Down) => Self::StepNavigation.swipe(direction), + (Self::StepMenu, Direction::Left) => Self::Menu.swipe(direction), + (Self::Menu, Direction::Left) => Self::DidYouKnow.swipe(direction), + (Self::Menu, Direction::Right) => Self::StepBegin.swipe(direction), + (Self::DidYouKnow, Direction::Right) => Self::Menu.swipe(direction), + (Self::StepDone, Direction::Up) => self.return_msg(FlowMsg::Confirmed), _ => self.do_nothing(), } } @@ -101,7 +102,7 @@ impl ShowTutorial { TR::instructions__swipe_up.into(), Some(TR::tutorial__get_started.into()), ) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) .map(|_| None); let content_step_navigation = Frame::left_aligned( @@ -115,8 +116,8 @@ impl ShowTutorial { TR::instructions__swipe_up.into(), Some(TR::tutorial__continue.into()), ) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Down, SwipeSettings::default()) .map(|_| None); let content_step_menu = Frame::left_aligned( @@ -132,8 +133,8 @@ impl ShowTutorial { TR::instructions__swipe_up.into(), Some(TR::buttons__continue.into()), ) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Down, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Down, SwipeSettings::default()) .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)); let content_step_hold = Frame::left_aligned( @@ -153,7 +154,7 @@ impl ShowTutorial { ))), ) .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) .map(|_| None); let content_menu = Frame::left_aligned( @@ -164,8 +165,8 @@ impl ShowTutorial { .danger(theme::ICON_CANCEL, TR::tutorial__exit.into()), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) - .with_swipe(SwipeDirection::Left, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Left, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), @@ -179,7 +180,7 @@ impl ShowTutorial { ))), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled)); let content_hold_to_exit = Frame::left_aligned( diff --git a/core/embed/rust/src/ui/model_mercury/flow/util.rs b/core/embed/rust/src/ui/model_mercury/flow/util.rs index 39e42b5d08..21cd83fe30 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/util.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/util.rs @@ -12,9 +12,10 @@ use crate::{ base::ComponentExt, swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, VecExt}, - Component, SwipeDirection, + Component, }, flow::{FlowMsg, Swipable, SwipePage}, + geometry::Direction, layout::util::{ConfirmBlob, StrOrBytes}, model_mercury::component::SwipeContent, }, @@ -154,19 +155,19 @@ impl ConfirmBlobParams { } if let Some(instruction) = self.footer_instruction { frame = frame.with_footer(instruction, self.footer_description); - frame = frame.with_swipe(SwipeDirection::Left, SwipeSettings::default()); + frame = frame.with_swipe(Direction::Left, SwipeSettings::default()); } if self.swipe_up { - frame = frame.with_swipe(SwipeDirection::Up, SwipeSettings::default()); + frame = frame.with_swipe(Direction::Up, SwipeSettings::default()); } if self.swipe_down { - frame = frame.with_swipe(SwipeDirection::Down, SwipeSettings::default()); + frame = frame.with_swipe(Direction::Down, SwipeSettings::default()); } if self.swipe_right { - frame = frame.with_swipe(SwipeDirection::Right, SwipeSettings::default()); + frame = frame.with_swipe(Direction::Right, SwipeSettings::default()); } frame = frame.with_vertical_pages(); @@ -292,22 +293,22 @@ impl ShowInfoParams { if self.cancel_button { frame = frame .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()); + .with_swipe(Direction::Right, SwipeSettings::immediate()); } else if self.menu_button { frame = frame .with_menu_button() - .with_swipe(SwipeDirection::Left, SwipeSettings::default()); + .with_swipe(Direction::Left, SwipeSettings::default()); } if let Some(instruction) = self.footer_instruction { frame = frame.with_footer(instruction, self.footer_description); } if self.swipe_up { - frame = frame.with_swipe(SwipeDirection::Up, SwipeSettings::default()); + frame = frame.with_swipe(Direction::Up, SwipeSettings::default()); } if self.swipe_down { - frame = frame.with_swipe(SwipeDirection::Down, SwipeSettings::default()); + frame = frame.with_swipe(Direction::Down, SwipeSettings::default()); } frame = frame.with_vertical_pages(); 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 a26a8ab982..fd357c0748 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 @@ -7,12 +7,13 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource}, - ComponentExt, SwipeDirection, + ComponentExt, }, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, }, + geometry::Direction, layout::obj::LayoutObj, model_mercury::component::SwipeContent, }, @@ -36,11 +37,11 @@ impl FlowController for WarningHiPrio { *self as usize } - fn handle_swipe(&'static self, direction: SwipeDirection) -> Decision { + fn handle_swipe(&'static self, direction: Direction) -> Decision { match (self, direction) { - (Self::Message, SwipeDirection::Left) => Self::Menu.swipe(direction), - (Self::Message, SwipeDirection::Up) => Self::Cancelled.swipe(direction), - (Self::Menu, SwipeDirection::Right) => Self::Message.swipe(direction), + (Self::Message, Direction::Left) => Self::Menu.swipe(direction), + (Self::Message, Direction::Up) => Self::Cancelled.swipe(direction), + (Self::Menu, Direction::Right) => Self::Message.swipe(direction), _ => self.do_nothing(), } } @@ -84,8 +85,8 @@ impl WarningHiPrio { .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), Some(cancel)) .with_danger() - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) - .with_swipe(SwipeDirection::Left, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)); // .one_button_request(ButtonRequestCode::Warning, br_name); @@ -97,7 +98,7 @@ impl WarningHiPrio { .danger(theme::ICON_CHEVRON_RIGHT, confirm), ) .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(|msg| match msg { FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Button(_) => Some(FlowMsg::Cancelled), diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index dd0478406d..6b2176a187 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -38,10 +38,10 @@ use crate::{ }, TextStyle, }, - Border, CachedJpeg, Component, FormattedText, Never, SwipeDirection, Timeout, + Border, CachedJpeg, Component, FormattedText, Never, Timeout, }, flow::Swipable, - geometry, + geometry::{self, Direction}, layout::{ obj::{ComponentMsgObj, LayoutObj, ATTACH_TYPE_OBJ}, result::{CANCELLED, CONFIRMED, INFO}, @@ -475,7 +475,7 @@ extern "C" fn new_confirm_homescreen(n_args: usize, args: *const Obj, kwargs: *m TR::instructions__swipe_up.into(), Some(TR::buttons__change.into()), ) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()), + .with_swipe(Direction::Up, SwipeSettings::default()), )); Ok(obj?.into()) }; @@ -599,7 +599,7 @@ extern "C" fn new_confirm_modify_output(n_args: usize, args: *const Obj, kwargs: Frame::left_aligned(TR::modify_amount__title.into(), paragraphs) .with_cancel_button() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()), + .with_swipe(Direction::Up, SwipeSettings::default()), ))?; Ok(obj.into()) }; @@ -643,7 +643,7 @@ extern "C" fn new_confirm_modify_fee(n_args: usize, args: *const Obj, kwargs: *m Frame::left_aligned(title, paragraphs) .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()), + .with_swipe(Direction::Up, SwipeSettings::default()), ))?; Ok(obj.into()) }; @@ -662,12 +662,12 @@ extern "C" fn new_show_error(n_args: usize, args: *const Obj, kwargs: *mut Map) .with_cancel_button() .with_danger() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) } else { Frame::left_aligned(title, SwipeContent::new(content)) .with_danger() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()) + .with_swipe(Direction::Up, SwipeSettings::default()) }; let frame = SwipeUpScreen::new(frame); @@ -693,7 +693,7 @@ extern "C" fn new_show_warning(n_args: usize, args: *const Obj, kwargs: *mut Map let frame = Frame::left_aligned(title, SwipeContent::new(content)) .with_footer(TR::instructions__swipe_up.into(), action) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()); + .with_swipe(Direction::Up, SwipeSettings::default()); let frame_with_icon = if danger { frame.with_danger_icon() @@ -723,7 +723,7 @@ extern "C" fn new_show_success(n_args: usize, args: *const Obj, kwargs: *mut Map ) .with_footer(TR::instructions__swipe_up.into(), description) .with_result_icon(ICON_BULLET_CHECKMARK, theme::GREEN_LIGHT) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()), + .with_swipe(Direction::Up, SwipeSettings::default()), ))?; Ok(obj.into()) }; @@ -738,7 +738,7 @@ extern "C" fn new_show_info(n_args: usize, args: *const Obj, kwargs: *mut Map) - let obj = LayoutObj::new(SwipeUpScreen::new( Frame::left_aligned(title, SwipeContent::new(content)) .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()), + .with_swipe(Direction::Up, SwipeSettings::default()), ))?; Ok(obj.into()) }; @@ -762,7 +762,7 @@ extern "C" fn new_show_mismatch(n_args: usize, args: *const Obj, kwargs: *mut Ma Frame::left_aligned(title, SwipeContent::new(paragraphs)) .with_cancel_button() .with_footer(TR::instructions__swipe_up.into(), Some(button)) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()), + .with_swipe(Direction::Up, SwipeSettings::default()), ))?; Ok(obj.into()) @@ -806,7 +806,7 @@ extern "C" fn new_confirm_with_info(n_args: usize, args: *const Obj, kwargs: *mu Frame::left_aligned(title, SwipeContent::new(paragraphs.into_paragraphs())) .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), Some(button)) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()), + .with_swipe(Direction::Up, SwipeSettings::default()), ))?; Ok(obj.into()) }; @@ -831,7 +831,7 @@ extern "C" fn new_confirm_more(n_args: usize, args: *const Obj, kwargs: *mut Map Frame::left_aligned(title, SwipeContent::new(paragraphs.into_paragraphs())) .with_cancel_button() .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()), + .with_swipe(Direction::Up, SwipeSettings::default()), ))?; Ok(obj.into()) }; @@ -960,7 +960,7 @@ extern "C" fn new_show_checklist(n_args: usize, args: *const Obj, kwargs: *mut M let obj = LayoutObj::new(SwipeUpScreen::new( Frame::left_aligned(title, SwipeContent::new(checklist_content)) .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()), + .with_swipe(Direction::Up, SwipeSettings::default()), ))?; Ok(obj.into()) }; @@ -1005,7 +1005,7 @@ extern "C" fn new_show_group_share_success( let obj = LayoutObj::new(SwipeUpScreen::new( Frame::left_aligned("".into(), SwipeContent::new(paragraphs)) .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()), + .with_swipe(Direction::Up, SwipeSettings::default()), ))?; Ok(obj.into())