1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-03-12 22:26:08 +00:00

refactor(eckhart): ignore empty description

- don't show empty text in confirm_action
This commit is contained in:
obrusvit 2025-03-01 14:09:27 +01:00
parent 3bd80af533
commit 1a755fb70c

View File

@ -38,7 +38,7 @@ impl FirmwareUI for UIEckhart {
title: TString<'static>, title: TString<'static>,
action: Option<TString<'static>>, action: Option<TString<'static>>,
description: Option<TString<'static>>, description: Option<TString<'static>>,
_subtitle: Option<TString<'static>>, subtitle: Option<TString<'static>>,
verb: Option<TString<'static>>, verb: Option<TString<'static>>,
_verb_cancel: Option<TString<'static>>, _verb_cancel: Option<TString<'static>>,
hold: bool, hold: bool,
@ -48,22 +48,28 @@ impl FirmwareUI for UIEckhart {
_prompt_title: Option<TString<'static>>, _prompt_title: Option<TString<'static>>,
) -> Result<impl LayoutMaybeTrace, Error> { ) -> Result<impl LayoutMaybeTrace, Error> {
let action = action.unwrap_or("".into()); let action = action.unwrap_or("".into());
let description = description.unwrap_or("".into());
let formatted_text = { let formatted_text = {
let ops = if !reverse { let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
OpTextLayout::new(theme::TEXT_NORMAL) if !reverse {
ops = ops
.color(theme::GREY_LIGHT) .color(theme::GREY_LIGHT)
.text(action, fonts::FONT_SATOSHI_REGULAR_38) .text(action, fonts::FONT_SATOSHI_REGULAR_38);
.newline() if let Some(description) = description {
.color(theme::GREY) ops = ops
.text(description, fonts::FONT_SATOSHI_REGULAR_22) .newline()
.color(theme::GREY)
.text(description, fonts::FONT_SATOSHI_REGULAR_22);
}
} else { } else {
OpTextLayout::new(theme::TEXT_NORMAL) if let Some(description) = description {
.color(theme::GREY) ops = ops
.text(description, fonts::FONT_SATOSHI_REGULAR_22) .color(theme::GREY)
.newline() .text(description, fonts::FONT_SATOSHI_REGULAR_22)
.newline();
}
ops = ops
.color(theme::GREY_LIGHT) .color(theme::GREY_LIGHT)
.text(action, fonts::FONT_SATOSHI_REGULAR_38) .text(action, fonts::FONT_SATOSHI_REGULAR_38);
}; };
FormattedText::new(ops).vertically_centered() FormattedText::new(ops).vertically_centered()
}; };
@ -74,13 +80,15 @@ impl FirmwareUI for UIEckhart {
} else { } else {
Button::with_text(verb) Button::with_text(verb)
}; };
let screen = TextScreen::new(formatted_text) let mut screen = TextScreen::new(formatted_text)
.with_header(Header::new(title).with_menu_button()) .with_header(Header::new(title).with_menu_button())
.with_hint(Hint::new_instruction(description, None))
.with_action_bar(ActionBar::new_double( .with_action_bar(ActionBar::new_double(
Button::with_icon(theme::ICON_CHEVRON_LEFT), Button::with_icon(theme::ICON_CHEVRON_LEFT),
right_button, right_button,
)); ));
if let Some(subtitle) = subtitle {
screen = screen.with_hint(Hint::new_instruction(subtitle, None));
}
let layout = RootComponent::new(screen); let layout = RootComponent::new(screen);
Ok(layout) Ok(layout)
} }