1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

refactor(core/ui): fix bootloader build failure

This commit is contained in:
Martin Milata 2024-04-23 23:47:18 +02:00
parent 23021c5152
commit 908f123dbf
19 changed files with 50 additions and 45 deletions

View File

@ -17,6 +17,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;
@ -35,6 +37,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},

View File

@ -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,

View File

@ -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 {

View File

@ -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,
},

View File

@ -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};

View File

@ -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,
};

View File

@ -7,7 +7,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;

View File

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

View File

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

View File

@ -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;

View File

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

View File

@ -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,

View File

@ -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 {}

View File

@ -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;

View File

@ -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;

View File

@ -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,
},
},
};

View File

@ -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;

View File

@ -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);

View File

@ -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;