Skip to content

Commit

Permalink
feat(eckhart): implement show checklist
Browse files Browse the repository at this point in the history
  • Loading branch information
bieleluk committed Feb 27, 2025
1 parent 025f927 commit a797856
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 14 deletions.
36 changes: 32 additions & 4 deletions core/embed/rust/src/translations/generated/translated_string.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions core/embed/rust/src/ui/layout_eckhart/theme/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ pub const TEXT_MONO_LIGHT: TextStyle = TextStyle::new(
GREY_EXTRA_LIGHT,
);

pub const TEXT_CHECKLIST_INACTIVE: TextStyle = TextStyle::new(
fonts::FONT_SATOSHI_MEDIUM_26,
GREY_DARK,
BG,
GREY_DARK,
GREY_DARK,
);

/// Decide the text style of chunkified text according to its length.
pub fn get_chunkified_text_style(_character_length: usize) -> &'static TextStyle {
// TODO: implement properly for Eckhart, see Delizia implemenation
Expand Down
44 changes: 38 additions & 6 deletions core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::cmp::Ordering;

use crate::{
error::Error,
io::BinaryData,
Expand All @@ -8,10 +10,11 @@ use crate::{
component::{
text::{
op::OpTextLayout,
paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, VecExt},
paragraphs::{Checklist, Paragraph, ParagraphSource, ParagraphVecShort, VecExt},
},
Empty, FormattedText,
},
geometry::Offset,
layout::{
obj::{LayoutMaybeTrace, LayoutObj, RootComponent},
util::{ConfirmValueParams, RecoveryType, StrOrBytes},
Expand Down Expand Up @@ -449,12 +452,41 @@ impl FirmwareUI for UIEckhart {
}

fn show_checklist(
_title: TString<'static>,
_button: TString<'static>,
_active: usize,
_items: [TString<'static>; MAX_CHECKLIST_ITEMS],
title: TString<'static>,
button: TString<'static>,
active: usize,
items: [TString<'static>; MAX_CHECKLIST_ITEMS],
) -> Result<impl LayoutMaybeTrace, Error> {
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(c"not implemented"))
let mut paragraphs = ParagraphVecShort::new();
for (i, item) in items.into_iter().enumerate() {
let style = match i.cmp(&active) {
Ordering::Less => &theme::TEXT_CHECKLIST_INACTIVE,
Ordering::Equal => &theme::TEXT_MEDIUM,
Ordering::Greater => &theme::TEXT_CHECKLIST_INACTIVE,
};
paragraphs.add(Paragraph::new(style, item));
}

let checklist_content = Checklist::from_paragraphs(
theme::ICON_CHEVRON_RIGHT_MINI,
theme::ICON_CHECKMARK_MINI,
active,
paragraphs.into_paragraphs().with_spacing(40),
)
.with_check_width(32)
.with_icon_done_color(theme::GREEN_LIGHT)
.with_done_offset(Offset::y(7))
.with_current_offset(Offset::y(4));

let layout = RootComponent::new(
TextScreen::new(checklist_content)
.with_header(Header::new(title).with_menu_button())
.with_action_bar(ActionBar::new_single(
Button::with_text(button).styled(theme::button_default()),
)),
);

Ok(layout)
}

fn show_danger(
Expand Down
28 changes: 24 additions & 4 deletions core/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -676,15 +676,35 @@
"reset__slip39_checklist_more_info_threshold": "The threshold sets the minumum number of shares needed to recover your wallet.",
"reset__slip39_checklist_more_info_threshold_example_template": "If you set {0} out of {1} shares, you'll need {2} backup shares to recover your wallet.",
"reset__slip39_checklist_num_groups": "Number of groups",
"reset__slip39_checklist_num_groups_x_template": "Number of groups: {0}",
"reset__slip39_checklist_num_groups_x_template": {
"Bolt": "Number of groups: {0}",
"Caesar": "Number of groups: {0}",
"Delizia": "Number of groups: {0}",
"Eckhart": "Number of groups {0}"
},
"reset__slip39_checklist_num_shares": "Number of shares",
"reset__slip39_checklist_num_shares_x_template": "Number of shares: {0}",
"reset__slip39_checklist_num_shares_x_template": {
"Bolt": "Number of shares: {0}",
"Caesar": "Number of shares: {0}",
"Delizia": "Number of shares: {0}",
"Eckhart": "Number of shares {0}"
},
"reset__slip39_checklist_set_num_groups": "Set number of groups",
"reset__slip39_checklist_set_num_shares": "Set number of shares",
"reset__slip39_checklist_set_sizes": "Set sizes and thresholds",
"reset__slip39_checklist_set_sizes_longer": "Set size and threshold for each group",
"reset__slip39_checklist_set_threshold": "Set threshold",
"reset__slip39_checklist_threshold_x_template": "Recovery threshold: {0}",
"reset__slip39_checklist_set_threshold": {
"Bolt": "Set threshold",
"Caesar": "Set threshold",
"Delizia": "Set threshold",
"Eckhart": "Set recovery threshold"
},
"reset__slip39_checklist_threshold_x_template": {
"Bolt": "Recovery threshold: {0}",
"Caesar": "Recovery threshold: {0}",
"Delizia": "Recovery threshold: {0}",
"Eckhart": "Recovery threshold {0}"
},
"reset__slip39_checklist_title": "Backup checklist",
"reset__slip39_checklist_write_down": "Write down and check all shares",
"reset__slip39_checklist_write_down_recovery": "Write down & check all wallet backup shares",
Expand Down

0 comments on commit a797856

Please sign in to comment.