refactor(core/ui): fix bootloader build failure

pull/3740/head
Martin Milata 4 weeks ago
parent 5521f90157
commit de383f2a8e

@ -16,6 +16,8 @@ pub mod pad;
pub mod paginated; pub mod paginated;
pub mod placed; pub mod placed;
pub mod qr_code; pub mod qr_code;
#[cfg(feature = "touch")]
pub mod swipe;
pub mod text; pub mod text;
pub mod timeout; pub mod timeout;
@ -33,6 +35,8 @@ pub use pad::Pad;
pub use paginated::{PageMsg, Paginate}; pub use paginated::{PageMsg, Paginate};
pub use placed::{FixedHeightBar, Floating, GridPlaced, Split}; pub use placed::{FixedHeightBar, Floating, GridPlaced, Split};
pub use qr_code::Qr; pub use qr_code::Qr;
#[cfg(feature = "touch")]
pub use swipe::{Swipe, SwipeDirection};
pub use text::{ pub use text::{
formatted::FormattedText, formatted::FormattedText,
layout::{LineBreaking, PageBreaking, TextLayout}, layout::{LineBreaking, PageBreaking, TextLayout},

@ -1,11 +1,18 @@
use crate::ui::{ use crate::ui::{
component::{Component, Event, EventCtx}, component::{Component, Event, EventCtx},
event::TouchEvent, event::TouchEvent,
flow::base::SwipeDirection,
geometry::{Point, Rect}, geometry::{Point, Rect},
shape::Renderer, shape::Renderer,
}; };
#[derive(Copy, Clone)]
pub enum SwipeDirection {
Up,
Down,
Left,
Right,
}
/// Copy of `model_tt/component/swipe.rs` but without the backlight handling. /// Copy of `model_tt/component/swipe.rs` but without the backlight handling.
pub struct Swipe { pub struct Swipe {
pub area: Rect, pub area: Rect,

@ -1,14 +1,9 @@
use crate::ui::{component::EventCtx, geometry::Offset}; use crate::ui::{
component::{EventCtx, SwipeDirection},
geometry::Offset,
};
use num_traits::ToPrimitive; use num_traits::ToPrimitive;
#[derive(Copy, Clone)]
pub enum SwipeDirection {
Up,
Down,
Left,
Right,
}
impl SwipeDirection { impl SwipeDirection {
pub fn as_offset(self, size: Offset) -> Offset { pub fn as_offset(self, size: Offset) -> Offset {
match self { match self {

@ -3,8 +3,8 @@ use crate::{
time::{Duration, Instant}, time::{Duration, Instant},
ui::{ ui::{
animation::Animation, animation::Animation,
component::{Component, Event, EventCtx}, component::{Component, Event, EventCtx, Swipe, SwipeDirection},
flow::{base::Decision, swipe::Swipe, FlowMsg, FlowState, FlowStore, SwipeDirection}, flow::{base::Decision, FlowMsg, FlowState, FlowStore},
geometry::{Offset, Rect}, geometry::{Offset, Rect},
shape::Renderer, shape::Renderer,
}, },

@ -2,9 +2,8 @@ pub mod base;
mod flow; mod flow;
pub mod page; pub mod page;
mod store; mod store;
mod swipe;
pub use base::{FlowMsg, FlowState, Swipable, SwipeDirection}; pub use base::{FlowMsg, FlowState, Swipable};
pub use flow::SwipeFlow; pub use flow::SwipeFlow;
pub use page::{IgnoreSwipe, SwipePage}; pub use page::{IgnoreSwipe, SwipePage};
pub use store::{flow_store, FlowStore}; pub use store::{flow_store, FlowStore};

@ -1,6 +1,6 @@
use crate::ui::{ use crate::ui::{
component::{Component, Event, EventCtx, Paginate}, component::{Component, Event, EventCtx, Paginate, SwipeDirection},
flow::base::{Swipable, SwipeDirection}, flow::base::Swipable,
geometry::{Axis, Rect}, geometry::{Axis, Rect},
shape::Renderer, shape::Renderer,
}; };

@ -6,7 +6,7 @@ pub mod component;
pub mod constant; pub mod constant;
pub mod display; pub mod display;
pub mod event; pub mod event;
#[cfg(all(feature = "micropython", feature = "model_mercury"))] #[cfg(all(feature = "micropython", feature = "touch"))]
pub mod flow; pub mod flow;
pub mod geometry; pub mod geometry;
pub mod lerp; pub mod lerp;

@ -230,4 +230,5 @@ where
} }
} }
#[cfg(feature = "micropython")]
impl<U> crate::ui::flow::Swipable for IconDialog<U> {} impl<U> crate::ui::flow::Swipable for IconDialog<U> {}

@ -245,15 +245,16 @@ where
} }
} }
#[cfg(feature = "micropython")]
impl<T> crate::ui::flow::Swipable for Frame<T> impl<T> crate::ui::flow::Swipable for Frame<T>
where where
T: Component + crate::ui::flow::Swipable, 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) 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)) self.update_content(ctx, |ctx, inner| inner.swiped(ctx, direction))
} }
} }

@ -24,6 +24,7 @@ mod progress;
mod prompt_screen; mod prompt_screen;
mod result; mod result;
mod scroll; mod scroll;
#[cfg(feature = "translations")]
mod share_words; mod share_words;
mod simple_page; mod simple_page;
mod status_screen; mod status_screen;
@ -63,6 +64,7 @@ pub use progress::Progress;
pub use prompt_screen::PromptScreen; pub use prompt_screen::PromptScreen;
pub use result::{ResultFooter, ResultScreen, ResultStyle}; pub use result::{ResultFooter, ResultScreen, ResultStyle};
pub use scroll::ScrollBar; pub use scroll::ScrollBar;
#[cfg(feature = "translations")]
pub use share_words::ShareWords; pub use share_words::ShareWords;
pub use simple_page::SimplePage; pub use simple_page::SimplePage;
pub use status_screen::StatusScreen; pub use status_screen::StatusScreen;

@ -130,6 +130,7 @@ impl Component for PromptScreen {
} }
} }
#[cfg(feature = "micropython")]
impl crate::ui::flow::Swipable for PromptScreen {} impl crate::ui::flow::Swipable for PromptScreen {}
#[cfg(feature = "ui_debug")] #[cfg(feature = "ui_debug")]

@ -8,7 +8,7 @@ use crate::ui::{
use super::theme; use super::theme;
pub use crate::ui::flow::SwipeDirection; pub use crate::ui::component::SwipeDirection;
pub struct Swipe { pub struct Swipe {
pub area: Rect, pub area: Rect,

@ -2,7 +2,7 @@ use heapless::Vec;
use super::theme; use super::theme;
use crate::{ use crate::{
micropython::buffer::StrBuffer, strutil::TString,
ui::{ ui::{
component::{base::Component, Event, EventCtx}, component::{base::Component, Event, EventCtx},
display::Icon, display::Icon,
@ -50,7 +50,7 @@ impl VerticalMenu {
areas_sep: AreasForSeparators::new(), 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(); let mut buttons_vec = VerticalMenuButtons::new();
for word in words { for word in words {
let button = Button::with_text(word.into()).styled(theme::button_default()); 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 {} impl crate::ui::flow::Swipable for VerticalMenu {}

@ -4,11 +4,11 @@ use crate::{
strutil::TString, strutil::TString,
translations::TR, translations::TR,
ui::{ ui::{
component::text::paragraphs::{Paragraph, Paragraphs}, component::{
flow::{ text::paragraphs::{Paragraph, Paragraphs},
base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeDirection, SwipeFlow, SwipeDirection,
SwipePage,
}, },
flow::{base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeFlow, SwipePage},
}, },
}; };
use heapless::Vec; use heapless::Vec;

@ -3,11 +3,11 @@ use crate::{
strutil::TString, strutil::TString,
translations::TR, translations::TR,
ui::{ ui::{
component::text::paragraphs::{Paragraph, Paragraphs}, component::{
flow::{ text::paragraphs::{Paragraph, Paragraphs},
base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeDirection, SwipeFlow, SwipeDirection,
SwipePage,
}, },
flow::{base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeFlow, SwipePage},
}, },
}; };
use heapless::Vec; use heapless::Vec;

@ -4,11 +4,11 @@ use crate::{
component::{ component::{
image::BlendedImage, image::BlendedImage,
text::paragraphs::{Paragraph, Paragraphs}, text::paragraphs::{Paragraph, Paragraphs},
Qr, Timeout, Qr, SwipeDirection, Timeout,
}, },
flow::{ flow::{
base::Decision, flow_store, FlowMsg, FlowState, FlowStore, IgnoreSwipe, SwipeDirection, base::Decision, flow_store, FlowMsg, FlowState, FlowStore, IgnoreSwipe, SwipeFlow,
SwipeFlow, SwipePage, SwipePage,
}, },
}, },
}; };

@ -1,7 +1,7 @@
pub mod get_address;
pub mod confirm_reset_device; pub mod confirm_reset_device;
pub mod create_backup; pub mod create_backup;
pub mod get_address;
pub use get_address::GetAddress;
pub use confirm_reset_device::ConfirmResetDevice; pub use confirm_reset_device::ConfirmResetDevice;
pub use create_backup::CreateBackup; pub use create_backup::CreateBackup;
pub use get_address::GetAddress;

@ -4,15 +4,8 @@ use heapless::Vec;
use crate::{ use crate::{
error::Error, error::Error,
micropython::{ micropython::{
buffer::{get_buffer, StrBuffer}, buffer::get_buffer, gc::Gc, iter::IterBuf, list::List, map::Map, module::Module, obj::Obj,
gc::Gc, qstr::Qstr, util,
iter::IterBuf,
list::List,
map::Map,
module::Module,
obj::Obj,
qstr::Qstr,
util,
}, },
strutil::TString, strutil::TString,
translations::TR, 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 title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.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_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 content = VerticalMenu::select_word(words);
let frame_with_menu = Frame::left_aligned(title, content).with_subtitle(description); let frame_with_menu = Frame::left_aligned(title, content).with_subtitle(description);

@ -6,6 +6,7 @@ pub mod component;
pub mod constant; pub mod constant;
pub mod theme; pub mod theme;
#[cfg(feature = "micropython")]
pub mod flow; pub mod flow;
#[cfg(feature = "micropython")] #[cfg(feature = "micropython")]
pub mod layout; pub mod layout;

Loading…
Cancel
Save