diff --git a/core/embed/rust/src/ui/component/mod.rs b/core/embed/rust/src/ui/component/mod.rs index 0859d6858..bc1e36dbb 100644 --- a/core/embed/rust/src/ui/component/mod.rs +++ b/core/embed/rust/src/ui/component/mod.rs @@ -16,6 +16,8 @@ pub mod pad; pub mod paginated; pub mod placed; pub mod qr_code; +#[cfg(feature = "touch")] +pub mod swipe; pub mod text; pub mod timeout; @@ -33,6 +35,8 @@ pub use pad::Pad; 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 text::{ formatted::FormattedText, layout::{LineBreaking, PageBreaking, TextLayout}, diff --git a/core/embed/rust/src/ui/flow/swipe.rs b/core/embed/rust/src/ui/component/swipe.rs similarity index 98% rename from core/embed/rust/src/ui/flow/swipe.rs rename to core/embed/rust/src/ui/component/swipe.rs index 1d4d6989c..876d6209e 100644 --- a/core/embed/rust/src/ui/flow/swipe.rs +++ b/core/embed/rust/src/ui/component/swipe.rs @@ -1,11 +1,18 @@ use crate::ui::{ component::{Component, Event, EventCtx}, event::TouchEvent, - flow::base::SwipeDirection, geometry::{Point, Rect}, shape::Renderer, }; +#[derive(Copy, Clone)] +pub enum SwipeDirection { + Up, + Down, + Left, + Right, +} + /// Copy of `model_tt/component/swipe.rs` but without the backlight handling. pub struct Swipe { pub area: Rect, diff --git a/core/embed/rust/src/ui/flow/base.rs b/core/embed/rust/src/ui/flow/base.rs index a01f8f0bc..c7c827d5d 100644 --- a/core/embed/rust/src/ui/flow/base.rs +++ b/core/embed/rust/src/ui/flow/base.rs @@ -1,14 +1,9 @@ -use crate::ui::{component::EventCtx, geometry::Offset}; +use crate::ui::{ + component::{EventCtx, SwipeDirection}, + geometry::Offset, +}; use num_traits::ToPrimitive; -#[derive(Copy, Clone)] -pub enum SwipeDirection { - Up, - Down, - Left, - Right, -} - impl SwipeDirection { pub fn as_offset(self, size: Offset) -> Offset { match self { diff --git a/core/embed/rust/src/ui/flow/flow.rs b/core/embed/rust/src/ui/flow/flow.rs index 2bb622786..7553771b2 100644 --- a/core/embed/rust/src/ui/flow/flow.rs +++ b/core/embed/rust/src/ui/flow/flow.rs @@ -3,8 +3,8 @@ use crate::{ time::{Duration, Instant}, ui::{ animation::Animation, - component::{Component, Event, EventCtx}, - flow::{base::Decision, swipe::Swipe, FlowMsg, FlowState, FlowStore, SwipeDirection}, + component::{Component, Event, EventCtx, Swipe, SwipeDirection}, + flow::{base::Decision, FlowMsg, FlowState, FlowStore}, geometry::{Offset, Rect}, shape::Renderer, }, diff --git a/core/embed/rust/src/ui/flow/mod.rs b/core/embed/rust/src/ui/flow/mod.rs index 6f3d1f45a..4c4ddcb5b 100644 --- a/core/embed/rust/src/ui/flow/mod.rs +++ b/core/embed/rust/src/ui/flow/mod.rs @@ -2,9 +2,8 @@ pub mod base; mod flow; pub mod page; mod store; -mod swipe; -pub use base::{FlowMsg, FlowState, Swipable, SwipeDirection}; +pub use base::{FlowMsg, FlowState, Swipable}; pub use flow::SwipeFlow; pub use page::{IgnoreSwipe, SwipePage}; pub use store::{flow_store, FlowStore}; diff --git a/core/embed/rust/src/ui/flow/page.rs b/core/embed/rust/src/ui/flow/page.rs index 8d5ac3598..8c986975b 100644 --- a/core/embed/rust/src/ui/flow/page.rs +++ b/core/embed/rust/src/ui/flow/page.rs @@ -1,6 +1,6 @@ use crate::ui::{ - component::{Component, Event, EventCtx, Paginate}, - flow::base::{Swipable, SwipeDirection}, + component::{Component, Event, EventCtx, Paginate, SwipeDirection}, + flow::base::Swipable, geometry::{Axis, Rect}, shape::Renderer, }; diff --git a/core/embed/rust/src/ui/mod.rs b/core/embed/rust/src/ui/mod.rs index 22501c6e9..75c14bbf7 100644 --- a/core/embed/rust/src/ui/mod.rs +++ b/core/embed/rust/src/ui/mod.rs @@ -6,7 +6,7 @@ pub mod component; pub mod constant; pub mod display; pub mod event; -#[cfg(all(feature = "micropython", feature = "model_mercury"))] +#[cfg(all(feature = "micropython", feature = "touch"))] pub mod flow; pub mod geometry; pub mod lerp; diff --git a/core/embed/rust/src/ui/model_mercury/component/dialog.rs b/core/embed/rust/src/ui/model_mercury/component/dialog.rs index 3766da6c4..68cee9a3a 100644 --- a/core/embed/rust/src/ui/model_mercury/component/dialog.rs +++ b/core/embed/rust/src/ui/model_mercury/component/dialog.rs @@ -230,4 +230,5 @@ where } } +#[cfg(feature = "micropython")] impl crate::ui::flow::Swipable for IconDialog {} 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 d0b9fb503..29a0f8fe6 100644 --- a/core/embed/rust/src/ui/model_mercury/component/frame.rs +++ b/core/embed/rust/src/ui/model_mercury/component/frame.rs @@ -245,15 +245,16 @@ where } } +#[cfg(feature = "micropython")] impl crate::ui::flow::Swipable for Frame where T: Component + crate::ui::flow::Swipable, { - fn can_swipe(&self, direction: crate::ui::flow::SwipeDirection) -> bool { + fn can_swipe(&self, direction: crate::ui::component::SwipeDirection) -> bool { self.inner().can_swipe(direction) } - fn swiped(&mut self, ctx: &mut EventCtx, direction: crate::ui::flow::SwipeDirection) { + fn swiped(&mut self, ctx: &mut EventCtx, direction: crate::ui::component::SwipeDirection) { self.update_content(ctx, |ctx, inner| inner.swiped(ctx, direction)) } } diff --git a/core/embed/rust/src/ui/model_mercury/component/mod.rs b/core/embed/rust/src/ui/model_mercury/component/mod.rs index 71fc05395..43d1f4c43 100644 --- a/core/embed/rust/src/ui/model_mercury/component/mod.rs +++ b/core/embed/rust/src/ui/model_mercury/component/mod.rs @@ -24,6 +24,7 @@ mod progress; mod prompt_screen; mod result; mod scroll; +#[cfg(feature = "translations")] mod share_words; mod simple_page; mod status_screen; @@ -63,6 +64,7 @@ pub use progress::Progress; pub use prompt_screen::PromptScreen; pub use result::{ResultFooter, ResultScreen, ResultStyle}; pub use scroll::ScrollBar; +#[cfg(feature = "translations")] pub use share_words::ShareWords; pub use simple_page::SimplePage; pub use status_screen::StatusScreen; diff --git a/core/embed/rust/src/ui/model_mercury/component/prompt_screen.rs b/core/embed/rust/src/ui/model_mercury/component/prompt_screen.rs index 73f0370a5..28cf5ad87 100644 --- a/core/embed/rust/src/ui/model_mercury/component/prompt_screen.rs +++ b/core/embed/rust/src/ui/model_mercury/component/prompt_screen.rs @@ -130,6 +130,7 @@ impl Component for PromptScreen { } } +#[cfg(feature = "micropython")] impl crate::ui::flow::Swipable for PromptScreen {} #[cfg(feature = "ui_debug")] diff --git a/core/embed/rust/src/ui/model_mercury/component/swipe.rs b/core/embed/rust/src/ui/model_mercury/component/swipe.rs index b4244e38c..0a67a3b6f 100644 --- a/core/embed/rust/src/ui/model_mercury/component/swipe.rs +++ b/core/embed/rust/src/ui/model_mercury/component/swipe.rs @@ -8,7 +8,7 @@ use crate::ui::{ use super::theme; -pub use crate::ui::flow::SwipeDirection; +pub use crate::ui::component::SwipeDirection; pub struct Swipe { pub area: Rect, 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 127d75889..cd9c4fa54 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 @@ -2,7 +2,7 @@ use heapless::Vec; use super::theme; use crate::{ - micropython::buffer::StrBuffer, + strutil::TString, ui::{ component::{base::Component, Event, EventCtx}, display::Icon, @@ -50,7 +50,7 @@ impl VerticalMenu { areas_sep: AreasForSeparators::new(), } } - pub fn select_word(words: [StrBuffer; 3]) -> Self { + pub fn select_word(words: [TString<'static>; 3]) -> Self { let mut buttons_vec = VerticalMenuButtons::new(); for word in words { let button = Button::with_text(word.into()).styled(theme::button_default()); @@ -152,4 +152,5 @@ impl crate::trace::Trace for VerticalMenu { } } +#[cfg(feature = "micropython")] impl crate::ui::flow::Swipable for VerticalMenu {} diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_device.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_device.rs index 227eb8dc3..40afe365a 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_device.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_reset_device.rs @@ -4,11 +4,11 @@ use crate::{ strutil::TString, translations::TR, ui::{ - component::text::paragraphs::{Paragraph, Paragraphs}, - flow::{ - base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeDirection, SwipeFlow, - SwipePage, + component::{ + text::paragraphs::{Paragraph, Paragraphs}, + SwipeDirection, }, + flow::{base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeFlow, SwipePage}, }, }; use heapless::Vec; diff --git a/core/embed/rust/src/ui/model_mercury/flow/create_backup.rs b/core/embed/rust/src/ui/model_mercury/flow/create_backup.rs index 95504a2ae..e3fc8b8b3 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/create_backup.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/create_backup.rs @@ -3,11 +3,11 @@ use crate::{ strutil::TString, translations::TR, ui::{ - component::text::paragraphs::{Paragraph, Paragraphs}, - flow::{ - base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeDirection, SwipeFlow, - SwipePage, + component::{ + text::paragraphs::{Paragraph, Paragraphs}, + SwipeDirection, }, + flow::{base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeFlow, SwipePage}, }, }; use heapless::Vec; 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 716a0c231..116940075 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 @@ -4,11 +4,11 @@ use crate::{ component::{ image::BlendedImage, text::paragraphs::{Paragraph, Paragraphs}, - Qr, Timeout, + Qr, SwipeDirection, Timeout, }, flow::{ - base::Decision, flow_store, FlowMsg, FlowState, FlowStore, IgnoreSwipe, SwipeDirection, - SwipeFlow, SwipePage, + base::Decision, flow_store, FlowMsg, FlowState, FlowStore, IgnoreSwipe, SwipeFlow, + SwipePage, }, }, }; diff --git a/core/embed/rust/src/ui/model_mercury/flow/mod.rs b/core/embed/rust/src/ui/model_mercury/flow/mod.rs index 1bffe2ea1..555d3bc63 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/mod.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/mod.rs @@ -1,7 +1,7 @@ -pub mod get_address; pub mod confirm_reset_device; pub mod create_backup; +pub mod get_address; -pub use get_address::GetAddress; pub use confirm_reset_device::ConfirmResetDevice; pub use create_backup::CreateBackup; +pub use get_address::GetAddress; diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index 2378150b1..145798bbc 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -4,15 +4,8 @@ use heapless::Vec; use crate::{ error::Error, micropython::{ - buffer::{get_buffer, StrBuffer}, - gc::Gc, - iter::IterBuf, - list::List, - map::Map, - module::Module, - obj::Obj, - qstr::Qstr, - util, + buffer::get_buffer, gc::Gc, iter::IterBuf, list::List, map::Map, module::Module, obj::Obj, + qstr::Qstr, util, }, strutil::TString, translations::TR, @@ -1292,7 +1285,7 @@ extern "C" fn new_select_word(n_args: usize, args: *const Obj, kwargs: *mut Map) let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; let words_iterable: Obj = kwargs.get(Qstr::MP_QSTR_words)?; - let words: [StrBuffer; 3] = util::iter_into_array(words_iterable)?; + let words: [TString; 3] = util::iter_into_array(words_iterable)?; let content = VerticalMenu::select_word(words); let frame_with_menu = Frame::left_aligned(title, content).with_subtitle(description); diff --git a/core/embed/rust/src/ui/model_mercury/mod.rs b/core/embed/rust/src/ui/model_mercury/mod.rs index bb3c85347..dcb000930 100644 --- a/core/embed/rust/src/ui/model_mercury/mod.rs +++ b/core/embed/rust/src/ui/model_mercury/mod.rs @@ -6,6 +6,7 @@ pub mod component; pub mod constant; pub mod theme; +#[cfg(feature = "micropython")] pub mod flow; #[cfg(feature = "micropython")] pub mod layout;