Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some new features #193

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions ledger_device_sdk/src/nbgl/nbgl_review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct NbglReview<'a> {
glyph: Option<&'a NbglGlyph<'a>>,
tx_type: TransactionType,
blind: bool,
light: bool,
}

impl SyncNBGL for NbglReview<'_> {}
Expand All @@ -22,6 +23,7 @@ impl<'a> NbglReview<'a> {
glyph: None,
tx_type: TransactionType::Transaction,
blind: false,
light: false,
}
}

Expand All @@ -36,6 +38,13 @@ impl<'a> NbglReview<'a> {
}
}

pub fn light(self) -> NbglReview<'a> {
NbglReview {
light: true,
..self
}
}

pub fn titles(
self,
title: &'a str,
Expand Down Expand Up @@ -106,15 +115,27 @@ impl<'a> NbglReview<'a> {
);
}
false => {
nbgl_useCaseReview(
self.tx_type.to_c_type(false),
&tag_value_list as *const nbgl_contentTagValueList_t,
&icon as *const nbgl_icon_details_t,
self.title.as_ptr() as *const c_char,
self.subtitle.as_ptr() as *const c_char,
self.finish_title.as_ptr() as *const c_char,
Some(choice_callback),
);
if self.light {
nbgl_useCaseReviewLight(
self.tx_type.to_c_type(false),
&tag_value_list as *const nbgl_contentTagValueList_t,
&icon as *const nbgl_icon_details_t,
self.title.as_ptr() as *const c_char,
self.subtitle.as_ptr() as *const c_char,
self.finish_title.as_ptr() as *const c_char,
Some(choice_callback),
);
} else {
nbgl_useCaseReview(
self.tx_type.to_c_type(false),
&tag_value_list as *const nbgl_contentTagValueList_t,
&icon as *const nbgl_icon_details_t,
self.title.as_ptr() as *const c_char,
self.subtitle.as_ptr() as *const c_char,
self.finish_title.as_ptr() as *const c_char,
Some(choice_callback),
);
}
}
}
let sync_ret = self.ux_sync_wait(false);
Expand Down
25 changes: 22 additions & 3 deletions ledger_device_sdk/src/ui/gadgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,10 @@ impl<'a> Menu<'a> {
pub enum PageStyle {
#[default]
PictureNormal, // Picture (should be 16x16) with two lines of text (page layout depends on device).
PictureBold, // Icon on top with one line of text on the bottom.
BoldNormal, // One line of bold text and one line of normal text.
Normal, // 2 lines of centered text.
PictureBold, // Icon on top with one line of text on the bottom.
BoldNormal, // One line of bold text and one line of normal text.
Normal, // 2 lines of centered text.
BoldCenteredNormal, // 2 lines of centered text, where the first one is bold
}

#[derive(Copy, Clone, Default)]
Expand Down Expand Up @@ -396,6 +397,21 @@ impl<'a> From<([&'a str; 2], bool)> for Page<'a> {
}
}

// new bold normal or new normal
impl<'a> From<([&'a str; 2], bool, bool)> for Page<'a> {
fn from((label, bold, centered): ([&'a str; 2], bool, bool)) -> Page<'a> {
if centered {
if bold {
Page::new(PageStyle::BoldCenteredNormal, [label[0], label[1]], None)
} else {
Page::new(PageStyle::Normal, [label[0], label[1]], None)
}
} else {
Page::new(PageStyle::BoldNormal, [label[0], label[1]], None)
}
}
}

// new picture bold
impl<'a> From<(&'a str, &'a Glyph<'a>)> for Page<'a> {
fn from((label, glyph): (&'a str, &'a Glyph<'a>)) -> Page<'a> {
Expand All @@ -418,6 +434,9 @@ impl<'a> Page<'a> {
PageStyle::Normal => {
self.label.place(Location::Middle, Layout::Centered, false);
}
PageStyle::BoldCenteredNormal => {
self.label.place(Location::Middle, Layout::Centered, true);
}
PageStyle::PictureNormal => {
let mut icon_x = 16;
let mut icon_y = 8;
Expand Down