Skip to content

Commit

Permalink
Merge pull request #105 from LedgerHQ/xch/display_pending_review
Browse files Browse the repository at this point in the history
ui:gadgets.rs: Add display_pending_review()
  • Loading branch information
xchapron-ledger authored Dec 15, 2023
2 parents 6152310 + a685684 commit 78c26ea
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ledger_device_sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ledger_device_sdk"
version = "1.2.1"
version = "1.3.0"
authors = ["yhql", "yogh333"]
edition = "2021"
license.workspace = true
Expand Down
49 changes: 47 additions & 2 deletions ledger_device_sdk/src/ui/gadgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use core::str::from_utf8;

use crate::{
buttons::ButtonEvent::*,
io::{self, ApduHeader, Reply},
io::{self, ApduHeader, Comm, Event, Reply},
};
use ledger_secure_sdk_sys::{
buttons::{get_button_event, ButtonEvent, ButtonsState},
seph,
};

use crate::ui::bitmaps::Glyph;
use crate::ui::bitmaps::{Glyph, WARNING};

use crate::ui::{bagls::*, fonts::OPEN_SANS};

Expand Down Expand Up @@ -66,6 +66,51 @@ pub fn clear_screen() {
BLANK.paint();
}

/// Display a developer mode / pending review popup, cleared with user interaction.
///
/// This method must be called by an application at the very beginning until it has been reviewed
/// and approved by Ledger.
///
/// # Arguments
///
/// * `comm` - Communication manager used to get device events.
///
/// # Examples
///
/// Following is an application example main function calling the pending review popup at the very
/// beginning, before doing any other application logic.
///
/// ```
/// #[no_mangle]
/// extern "C" fn sample_main() {
/// let mut comm = Comm::new();
/// ledger_device_sdk::ui::gadgets::display_pending_review(&mut comm);
/// ...
/// }
/// `
pub fn display_pending_review(comm: &mut Comm) {
clear_screen();

// Add icon and text to match the C SDK equivalent.
if cfg!(target_os = "nanos") {
"Pending".place(Location::Custom(2), Layout::Centered, true);
"Ledger review".place(Location::Custom(14), Layout::Centered, true);
} else {
WARNING.draw(57, 10);
"Pending".place(Location::Custom(28), Layout::Centered, true);
"Ledger review".place(Location::Custom(42), Layout::Centered, true);
}

crate::ui::screen_util::screen_update();

// Process events until a double button press release.
loop {
if let Event::Button(BothButtonsRelease) = comm.next_event::<ApduHeader>() {
break;
}
}
}

/// Shorthand to display a single message
/// and wait for button action
pub fn popup(message: &str) {
Expand Down

0 comments on commit 78c26ea

Please sign in to comment.