Skip to content

Commit

Permalink
chore(eckhart): fix some clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
obrusvit committed Feb 26, 2025
1 parent 0db51e8 commit e992b77
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 42 deletions.
20 changes: 10 additions & 10 deletions core/embed/rust/src/ui/layout_eckhart/bootloader/welcome.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use crate::ui::{
component::{Component, Event, EventCtx, Never, Pad},
constant::screen,
display::Font,
geometry::{Offset, Point, Rect},
shape,
shape::Renderer,
};

use super::super::theme::{BLACK, GREY, WHITE};
use super::{
super::theme::{BLACK, GREY, WHITE},
fonts,
};

const TEXT_ORIGIN: Point = Point::new(0, 105);
const STRIDE: i16 = 22;
Expand Down Expand Up @@ -39,28 +41,26 @@ impl Component for Welcome {
fn render<'s>(&'s self, target: &mut impl Renderer<'s>) {
self.bg.render(target);

shape::Text::new(TEXT_ORIGIN, "Get started")
.with_font(Font::NORMAL)
let font = fonts::FONT_SATOSHI_REGULAR_38;
shape::Text::new(TEXT_ORIGIN, "Get started", font)
.with_fg(GREY)
.render(target);

shape::Text::new(TEXT_ORIGIN + Offset::y(STRIDE), "with your Trezor")
.with_font(Font::NORMAL)
shape::Text::new(TEXT_ORIGIN + Offset::y(STRIDE), "with your Trezor", font)
.with_fg(GREY)
.render(target);

shape::Text::new(TEXT_ORIGIN + Offset::y(2 * STRIDE), "at")
.with_font(Font::NORMAL)
shape::Text::new(TEXT_ORIGIN + Offset::y(2 * STRIDE), "at", font)
.with_fg(GREY)
.render(target);

let at_width = Font::NORMAL.text_width("at ");
let at_width = font.text_width("at ");

shape::Text::new(
TEXT_ORIGIN + Offset::new(at_width, 2 * STRIDE),
"trezor.io/start",
font,
)
.with_font(Font::NORMAL)
.with_fg(WHITE)
.render(target);
}
Expand Down
12 changes: 5 additions & 7 deletions core/embed/rust/src/ui/layout_eckhart/component/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,11 @@ impl<'a> Component for Hint<'a> {
let bounds = bounds.inset(Self::HINT_INSETS);
match &mut self.content {
HintContent::Instruction(instruction) => {
if let Some(icon) = instruction.icon {
let icon_width = instruction.icon_width();
let text_area = bounds.split_left(icon_width).1;
instruction.label.place(text_area);
} else {
instruction.label.place(bounds);
}
let text_area = match instruction.icon {
Some(_) => bounds.split_left(instruction.icon_width()).1,
None => bounds,
};
instruction.label.place(text_area);
}
_ => {}
}
Expand Down
23 changes: 10 additions & 13 deletions core/embed/rust/src/ui/layout_eckhart/component/text_screen.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
use crate::{
strutil::TString,
ui::{
component::{
swipe_detect::SwipeConfig,
text::paragraphs::{ParagraphSource, Paragraphs},
Component, Event, EventCtx, FormattedText, PaginateFull,
},
flow::Swipable,
geometry::{Insets, Rect},
shape::Renderer,
util::Pager,
use crate::ui::{
component::{
swipe_detect::SwipeConfig,
text::paragraphs::{ParagraphSource, Paragraphs},
Component, Event, EventCtx, FormattedText, PaginateFull,
},
flow::Swipable,
geometry::{Insets, Rect},
shape::Renderer,
util::Pager,
};

use super::{action_bar::ActionBarMsg, button::Button, ActionBar, Header, HeaderMsg, Hint};
pub(crate) use super::{action_bar::ActionBarMsg, ActionBar, Header, HeaderMsg, Hint};

/// Full-screen component for rendering text.
///
Expand Down
40 changes: 40 additions & 0 deletions core/embed/rust/src/ui/layout_eckhart/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
use super::{geometry::Rect, CommonUI};
use theme::backlight;

#[cfg(feature = "ui_debug_overlay")]
use super::{
display::Color,
geometry::{Alignment, Alignment2D, Offset, Point},
shape, DebugOverlay,
};

#[cfg(feature = "ui_debug_overlay")]
use crate::strutil::ShortString;

#[cfg(feature = "bootloader")]
pub mod bootloader;
pub mod component;
Expand Down Expand Up @@ -69,4 +79,34 @@ impl CommonUI for UIEckhart {
fn screen_boot_stage_2(fade_in: bool) {
screens::screen_boot_stage_2(fade_in);
}

#[cfg(feature = "ui_debug_overlay")]
fn render_debug_overlay<'s>(target: &mut impl shape::Renderer<'s>, info: DebugOverlay) {
let mut text = ShortString::new();
let t1 = info.render_time.min(99999) as u32;
let t2 = info.refresh_time.min(99999) as u32;
unwrap!(ufmt::uwrite!(
text,
"{}.{}|{}.{}",
t1 / 1000,
(t1 % 1000) / 100,
t2 / 1000,
(t2 % 1000) / 100
));
let font = fonts::FONT_SATOSHI_REGULAR_22;
let size = Offset::new(
font.visible_text_width("00.0|00.0"),
font.visible_text_height("0"),
);
let pos = Point::new(constant::WIDTH, 0);
let r = Rect::snap(pos, size, Alignment2D::TOP_RIGHT);
shape::Bar::new(r)
.with_alpha(192)
.with_bg(Color::black())
.render(target);
shape::Text::new(r.bottom_right(), &text, font)
.with_align(Alignment::End)
.with_fg(Color::rgb(255, 255, 0))
.render(target);
}
}
19 changes: 11 additions & 8 deletions core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
component::{
text::{
op::OpTextLayout,
paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt},
paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, VecExt},
},
Empty, FormattedText,
},
Expand Down Expand Up @@ -159,6 +159,7 @@ impl FirmwareUI for UIEckhart {
_title: TString<'static>,
_button: TString<'static>,
_button_style_confirm: bool,
_hold: bool,
_items: Obj,
) -> Result<impl LayoutMaybeTrace, Error> {
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(c"not implemented"))
Expand Down Expand Up @@ -204,7 +205,7 @@ impl FirmwareUI for UIEckhart {
chunkify: bool,
page_counter: bool,
_prompt_screen: bool,
cancel: bool,
_cancel: bool,
) -> Result<Gc<LayoutObj>, Error> {
let paragraphs = ConfirmValueParams {
description: description.unwrap_or("".into()),
Expand Down Expand Up @@ -258,17 +259,18 @@ impl FirmwareUI for UIEckhart {
_subtitle: Option<TString<'static>>,
_verb: Option<TString<'static>>,
_verb_cancel: Option<TString<'static>>,
_hold: bool,
_chunkify: bool,
) -> Result<Gc<LayoutObj>, Error> {
Err::<Gc<LayoutObj>, Error>(Error::ValueError(c"confirm_value_intro not implemented"))
}

fn confirm_with_info(
_title: TString<'static>,
_button: TString<'static>,
_info_button: TString<'static>,
_verb_cancel: Option<TString<'static>>,
_items: Obj,
_verb: TString<'static>,
_verb_info: TString<'static>,
_verb_cancel: Option<TString<'static>>,
) -> Result<impl LayoutMaybeTrace, Error> {
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(c"not implemented"))
}
Expand All @@ -291,6 +293,7 @@ impl FirmwareUI for UIEckhart {
fn flow_confirm_output(
_title: Option<TString<'static>>,
_subtitle: Option<TString<'static>>,
_description: Option<TString<'static>>,
_message: Obj,
_amount: Option<Obj>,
_chunkify: bool,
Expand All @@ -299,8 +302,8 @@ impl FirmwareUI for UIEckhart {
_account_path: Option<TString<'static>>,
_br_code: u16,
_br_name: TString<'static>,
_address: Option<Obj>,
_address_title: Option<TString<'static>>,
_address_item: Option<(TString<'static>, Obj)>,
_extra_item: Option<(TString<'static>, Obj)>,
_summary_items: Option<Obj>,
_fee_items: Option<Obj>,
_summary_title: Option<TString<'static>>,
Expand Down Expand Up @@ -671,7 +674,7 @@ impl FirmwareUI for UIEckhart {
value: TString<'static>,
description: TString<'static>,
allow_cancel: bool,
danger: bool, // TODO: review if `danger` needed in all layouts since we have show_danger
_danger: bool, // TODO: review if `danger` needed in all layouts since we have show_danger
) -> Result<Gc<LayoutObj>, Error> {
let paragraphs = ParagraphVecShort::from_iter([
Paragraph::new(&theme::TEXT_SMALL, description),
Expand Down
2 changes: 1 addition & 1 deletion core/site_scons/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_ui_module(model: str, stage: str):

layout = models.get_model_ui(model)

if layout == "delizia" and stage == "prodtest":
if layout in ("delizia", "eckhart") and stage == "prodtest":
layout = "bolt"

return ui_modules[layout]
Expand Down
6 changes: 3 additions & 3 deletions core/translations/signatures.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"current": {
"merkle_root": "1754d367a3f9796a460e21677a38465ac51110a5abaae96a8977e64cd3d35e27",
"datetime": "2025-02-25T22:15:23.529862",
"commit": "ba8a64d3e42febd344f60f039b6ac21ffb36aa9c"
"merkle_root": "19d4e95a0a33b04208bf228d5e00dceb75e0f0a59fc2fde24a8c53a3f61f6866",
"datetime": "2025-02-26T14:55:24.158526",
"commit": "d2061b7671c84edd65033f7e22d65deda13cad06"
},
"history": [
{
Expand Down

0 comments on commit e992b77

Please sign in to comment.