1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-08-01 19:38:33 +00:00

fix(eckhart): a few alignment and style issues

- fix pyright
This commit is contained in:
obrusvit 2025-05-10 12:53:04 +02:00 committed by Vít Obrusník
parent c66b435212
commit 0afc97227f
8 changed files with 66 additions and 71 deletions

View File

@ -261,8 +261,7 @@ fn content_menu_info(
paragraphs paragraphs
.map_or_else(ParagraphVecShort::new, |p| p) .map_or_else(ParagraphVecShort::new, |p| p)
.into_paragraphs() .into_paragraphs()
.with_placement(LinearPlacement::vertical()) .with_placement(LinearPlacement::vertical().with_spacing(theme::PARAGRAPHS_SPACING)),
.with_spacing(12),
) )
.with_header(Header::new(title).with_close_button()) .with_header(Header::new(title).with_close_button())
.with_subtitle(subtitle.unwrap_or(TString::empty())) .with_subtitle(subtitle.unwrap_or(TString::empty()))
@ -302,8 +301,7 @@ pub fn new_confirm_output(
let content_main = TextScreen::new( let content_main = TextScreen::new(
main_paragraphs main_paragraphs
.into_paragraphs() .into_paragraphs()
.with_placement(LinearPlacement::vertical()) .with_placement(LinearPlacement::vertical().with_spacing(theme::PARAGRAPHS_SPACING)),
.with_spacing(12),
) )
.with_header(Header::new(title.unwrap_or(TString::empty())).with_menu_button()) .with_header(Header::new(title.unwrap_or(TString::empty())).with_menu_button())
.with_action_bar(ActionBar::new_single(Button::with_text( .with_action_bar(ActionBar::new_single(Button::with_text(
@ -399,31 +397,29 @@ pub fn new_confirm_output(
flow flow
} else if let Some(summary_paragraphs) = summary_paragraphs { } else if let Some(summary_paragraphs) = summary_paragraphs {
// Summary // Summary
let content_summary = TextScreen::new( let content_summary =
summary_paragraphs TextScreen::new(summary_paragraphs.into_paragraphs().with_placement(
.into_paragraphs() LinearPlacement::vertical().with_spacing(theme::PARAGRAPHS_SPACING),
.with_placement(LinearPlacement::vertical()) ))
.with_spacing(12), .with_header(
) Header::new(summary_title.unwrap_or(TR::words__title_summary.into()))
.with_header( .with_menu_button(),
Header::new(summary_title.unwrap_or(TR::words__title_summary.into())) )
.with_menu_button(), .with_action_bar(ActionBar::new_double(
) Button::with_icon(theme::ICON_CHEVRON_UP),
.with_action_bar(ActionBar::new_double( Button::with_text(TR::instructions__hold_to_sign.into())
Button::with_icon(theme::ICON_CHEVRON_UP), .with_long_press(theme::CONFIRM_HOLD_DURATION)
Button::with_text(TR::instructions__hold_to_sign.into()) .styled(theme::button_confirm()),
.with_long_press(theme::CONFIRM_HOLD_DURATION) ))
.styled(theme::button_confirm()), .map(|msg| match msg {
)) TextScreenMsg::Confirmed => Some(FlowMsg::Confirmed),
.map(|msg| match msg { TextScreenMsg::Cancelled => Some(FlowMsg::Cancelled),
TextScreenMsg::Confirmed => Some(FlowMsg::Confirmed), TextScreenMsg::Menu => Some(FlowMsg::Info),
TextScreenMsg::Cancelled => Some(FlowMsg::Cancelled), })
TextScreenMsg::Menu => Some(FlowMsg::Info), .one_button_request(ButtonRequest::from_num(
}) summary_br_code.unwrap(),
.one_button_request(ButtonRequest::from_num( summary_br_name.unwrap(),
summary_br_code.unwrap(), ));
summary_br_name.unwrap(),
));
// SummaryMenu // SummaryMenu
let mut summary_menu = VerticalMenu::<ShortMenuVec>::empty(); let mut summary_menu = VerticalMenu::<ShortMenuVec>::empty();

View File

@ -80,8 +80,7 @@ fn content_menu_info(
paragraphs paragraphs
.map_or_else(ParagraphVecShort::new, |p| p) .map_or_else(ParagraphVecShort::new, |p| p)
.into_paragraphs() .into_paragraphs()
.with_placement(LinearPlacement::vertical()) .with_placement(LinearPlacement::vertical().with_spacing(theme::PARAGRAPHS_SPACING)),
.with_spacing(12),
) )
.with_header(Header::new(title).with_close_button()) .with_header(Header::new(title).with_close_button())
.with_subtitle(subtitle.unwrap_or(TString::empty())) .with_subtitle(subtitle.unwrap_or(TString::empty()))
@ -115,8 +114,7 @@ pub fn new_confirm_summary(
let content_summary = TextScreen::new( let content_summary = TextScreen::new(
summary_paragraphs summary_paragraphs
.into_paragraphs() .into_paragraphs()
.with_placement(LinearPlacement::vertical()) .with_placement(LinearPlacement::vertical().with_spacing(theme::PARAGRAPHS_SPACING)),
.with_spacing(12),
) )
.with_header(Header::new(title).with_menu_button()) .with_header(Header::new(title).with_menu_button())
.with_action_bar(ActionBar::new_single( .with_action_bar(ActionBar::new_single(

View File

@ -63,13 +63,17 @@ pub fn new_confirm_with_menu<T: AllowedTextContent + MaybeTrace + 'static>(
cancel_menu_label: Option<TString<'static>>, cancel_menu_label: Option<TString<'static>>,
) -> Result<SwipeFlow, error::Error> { ) -> Result<SwipeFlow, error::Error> {
let cancel_menu_label = cancel_menu_label.unwrap_or(TR::buttons__cancel.into()); let cancel_menu_label = cancel_menu_label.unwrap_or(TR::buttons__cancel.into());
let confirm_label = confirm_label.unwrap_or(TR::buttons__confirm.into());
// Value // Value
let mut confirm_button = Button::with_text(confirm_label).styled(theme::button_confirm()); let confirm_button = if hold {
if hold { let confirm_label = confirm_label.unwrap_or(TR::buttons__hold_to_confirm.into());
confirm_button = confirm_button.with_long_press(theme::LOCK_HOLD_DURATION); Button::with_text(confirm_label)
} .styled(theme::button_confirm())
.with_long_press(theme::LOCK_HOLD_DURATION)
} else {
let confirm_label = confirm_label.unwrap_or(TR::buttons__confirm.into());
Button::with_text(confirm_label).styled(theme::button_default())
};
let content_value = TextScreen::new(content) let content_value = TextScreen::new(content)
.with_header(Header::new(title).with_menu_button()) .with_header(Header::new(title).with_menu_button())
.with_action_bar(ActionBar::new_single(confirm_button)) .with_action_bar(ActionBar::new_single(confirm_button))

View File

@ -69,7 +69,7 @@ pub const TEXT_MONO_MEDIUM: TextStyle = TextStyle::new(
GREY_EXTRA_LIGHT, GREY_EXTRA_LIGHT,
GREY_EXTRA_LIGHT, GREY_EXTRA_LIGHT,
) )
.with_line_breaking(LineBreaking::BreakWordsNoHyphen); .with_line_breaking(LineBreaking::BreakAtWhitespace);
pub const TEXT_MONO_MEDIUM_LIGHT: TextStyle = TextStyle::new( pub const TEXT_MONO_MEDIUM_LIGHT: TextStyle = TextStyle::new(
fonts::FONT_MONO_MEDIUM_38, fonts::FONT_MONO_MEDIUM_38,
@ -78,7 +78,7 @@ pub const TEXT_MONO_MEDIUM_LIGHT: TextStyle = TextStyle::new(
GREY_LIGHT, GREY_LIGHT,
GREY_LIGHT, GREY_LIGHT,
) )
.with_line_breaking(LineBreaking::BreakWordsNoHyphen); .with_line_breaking(LineBreaking::BreakAtWhitespace);
/// Roboto Mono Light - 30 (Address, data) /// Roboto Mono Light - 30 (Address, data)
pub const TEXT_MONO_LIGHT: TextStyle = TextStyle::new( pub const TEXT_MONO_LIGHT: TextStyle = TextStyle::new(

View File

@ -54,6 +54,7 @@ pub const PADDING: i16 = 24; // px
pub const HEADER_HEIGHT: i16 = 96; // [px] pub const HEADER_HEIGHT: i16 = 96; // [px]
pub const SIDE_INSETS: Insets = Insets::sides(PADDING); pub const SIDE_INSETS: Insets = Insets::sides(PADDING);
pub const ACTION_BAR_HEIGHT: i16 = 90; // [px] pub const ACTION_BAR_HEIGHT: i16 = 90; // [px]
pub const PARAGRAPHS_SPACING: i16 = 12; // px
pub const TEXT_VERTICAL_SPACING: i16 = 24; // [px] pub const TEXT_VERTICAL_SPACING: i16 = 24; // [px]
// Tile pattern grid constants // Tile pattern grid constants

View File

@ -38,8 +38,9 @@ pub type BootloaderString = String<128>;
const RECONNECT_MESSAGE: &str = "Please reconnect\nthe device"; const RECONNECT_MESSAGE: &str = "Please reconnect\nthe device";
const SCREEN: Rect = UIEckhart::SCREEN; const SCREEN: Rect = UIEckhart::SCREEN;
// TODO: adjust offset const PROGRESS_TEXT_ORIGIN: Point = SCREEN
const PROGRESS_TEXT_ORIGIN: Point = SCREEN.top_left().ofs(Offset::new(24, 48)); .top_left()
.ofs(Offset::new(theme::PADDING, theme::HEADER_HEIGHT));
const SCREEN_BORDER_BLUE: ScreenBorder = ScreenBorder::new(BLUE); const SCREEN_BORDER_BLUE: ScreenBorder = ScreenBorder::new(BLUE);
const SCREEN_BORDER_RED: ScreenBorder = ScreenBorder::new(RED); const SCREEN_BORDER_RED: ScreenBorder = ScreenBorder::new(RED);
@ -57,17 +58,17 @@ impl UIEckhart {
display::sync(); display::sync();
render_on_display(None, Some(bg_color), |target| { render_on_display(None, Some(bg_color), |target| {
shape::Text::new(PROGRESS_TEXT_ORIGIN, text, fonts::FONT_SATOSHI_REGULAR_38)
.with_align(Alignment::Start)
.with_fg(BLD_FG)
.render(target);
let border: &ScreenBorder = match bg_color { let border: &ScreenBorder = match bg_color {
RED => &SCREEN_BORDER_RED, RED => &SCREEN_BORDER_RED,
_ => &SCREEN_BORDER_BLUE, _ => &SCREEN_BORDER_BLUE,
}; };
render_loader(progress, border, target); render_loader(progress, border, target);
shape::Text::new(PROGRESS_TEXT_ORIGIN, text, fonts::FONT_SATOSHI_REGULAR_38)
.with_align(Alignment::Start)
.with_fg(BLD_FG)
.render(target);
if let Some(center_text) = center_text { if let Some(center_text) = center_text {
shape::Text::new(SCREEN.center(), center_text, fonts::FONT_SATOSHI_REGULAR_38) shape::Text::new(SCREEN.center(), center_text, fonts::FONT_SATOSHI_REGULAR_38)
.with_align(Alignment::Center) .with_align(Alignment::Center)

View File

@ -225,10 +225,9 @@ impl FirmwareUI for UIEckhart {
let flow = flow::new_confirm_with_menu( let flow = flow::new_confirm_with_menu(
title, title,
None, None,
paragraphs paragraphs.into_paragraphs().with_placement(
.into_paragraphs() LinearPlacement::vertical().with_spacing(theme::PARAGRAPHS_SPACING),
.with_spacing(12) ),
.with_placement(LinearPlacement::vertical()),
None, None,
false, false,
Some(TR::words__title_information.into()), Some(TR::words__title_information.into()),
@ -256,12 +255,9 @@ impl FirmwareUI for UIEckhart {
]); ]);
let layout = RootComponent::new( let layout = RootComponent::new(
TextScreen::new( TextScreen::new(paragraphs.into_paragraphs().with_placement(
paragraphs LinearPlacement::vertical().with_spacing(theme::PARAGRAPHS_SPACING),
.into_paragraphs() ))
.with_placement(LinearPlacement::vertical())
.with_spacing(12),
)
.with_header(Header::new(TR::modify_amount__title.into())) .with_header(Header::new(TR::modify_amount__title.into()))
.with_action_bar(ActionBar::new_double( .with_action_bar(ActionBar::new_double(
Button::with_icon(theme::ICON_CROSS), Button::with_icon(theme::ICON_CROSS),
@ -352,10 +348,9 @@ impl FirmwareUI for UIEckhart {
let flow = flow::new_confirm_with_menu( let flow = flow::new_confirm_with_menu(
title, title,
None, None,
paragraphs paragraphs.into_paragraphs().with_placement(
.into_paragraphs() LinearPlacement::vertical().with_spacing(theme::PARAGRAPHS_SPACING),
.with_spacing(12) ),
.with_placement(LinearPlacement::vertical()),
None, None,
hold, hold,
None, None,
@ -869,7 +864,9 @@ impl FirmwareUI for UIEckhart {
theme::ICON_CHEVRON_RIGHT_MINI, theme::ICON_CHEVRON_RIGHT_MINI,
theme::ICON_CHECKMARK_MINI, theme::ICON_CHECKMARK_MINI,
active, active,
paragraphs.into_paragraphs().with_spacing(40), paragraphs
.into_paragraphs()
.with_placement(LinearPlacement::vertical().with_spacing(40)),
) )
.with_check_width(32) .with_check_width(32)
.with_icon_done_color(theme::GREEN_LIGHT) .with_icon_done_color(theme::GREEN_LIGHT)
@ -1060,13 +1057,11 @@ impl FirmwareUI for UIEckhart {
} }
} }
let screen = TextScreen::new( let screen =
paragraphs TextScreen::new(paragraphs.into_paragraphs().with_placement(
.into_paragraphs() LinearPlacement::vertical().with_spacing(theme::PARAGRAPHS_SPACING),
.with_spacing(12) ))
.with_placement(LinearPlacement::vertical()), .with_header(Header::new(title).with_close_button());
)
.with_header(Header::new(title).with_close_button());
let layout = RootComponent::new(screen); let layout = RootComponent::new(screen);
Ok(layout) Ok(layout)
} }

View File

@ -896,7 +896,7 @@ if not utils.BITCOIN_ONLY:
account_path: str, account_path: str,
vote_account: str, vote_account: str,
stake_item: tuple[str, str] | None, stake_item: tuple[str, str] | None,
amount_item: tuple[str, str], amount_item: tuple[str, str] | None,
fee_item: tuple[str, str], fee_item: tuple[str, str],
fee_details: Iterable[tuple[str, str]], fee_details: Iterable[tuple[str, str]],
blockhash_item: tuple[str, str], blockhash_item: tuple[str, str],
@ -922,7 +922,7 @@ if not utils.BITCOIN_ONLY:
extra_item=blockhash_item, extra_item=blockhash_item,
fee_items=fee_details, fee_items=fee_details,
summary_title=title, summary_title=title,
summary_items=(amount_item, fee_item), summary_items=(amount_item, fee_item) if amount_item else (fee_item,),
summary_br_name="confirm_total", summary_br_name="confirm_total",
summary_br_code=ButtonRequestType.SignTx, summary_br_code=ButtonRequestType.SignTx,
cancel_text=TR.buttons__cancel, cancel_text=TR.buttons__cancel,