Skip to content

Commit

Permalink
Merge pull request #193 from Zondax/feat/zondax-rebased
Browse files Browse the repository at this point in the history
Some new features
  • Loading branch information
yogh333 authored Sep 30, 2024
2 parents 8d19e15 + 4148e2c commit 1dfd4c5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
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

0 comments on commit 1dfd4c5

Please sign in to comment.