1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! A wrapper around the synchronous NBGL [nbgl_useCaseReviewStatus](https://github.com/LedgerHQ/ledger-secure-sdk/blob/master/lib_nbgl/src/nbgl_use_case.c#L3528) C API binding.
//!
//! Draws a transient (3s) status page of the chosen type.
use super::*;
/// A builder to create and show a status review page.
pub struct NbglReviewStatus {
status_type: StatusType,
}
impl SyncNBGL for NbglReviewStatus {}
impl<'a> NbglReviewStatus {
/// Creates a new status review page builder.
/// # Returns
/// Returns a new instance of `NbglReviewStatus`.
pub fn new() -> NbglReviewStatus {
NbglReviewStatus {
status_type: StatusType::Transaction,
}
}
/// Sets the type of status to display.
/// # Arguments
/// * `status_type` - The type of status to display.
/// # Returns
/// Returns the builder itself to allow method chaining.
pub fn status_type(self, status_type: StatusType) -> NbglReviewStatus {
NbglReviewStatus { status_type }
}
/// Shows the status review page (internal implementation).
fn show_internal(&self, success: bool) {
unsafe {
self.ux_sync_init();
nbgl_useCaseReviewStatus(self.status_type.to_message(success), Some(quit_callback));
self.ux_sync_wait(false);
}
}
/// Shows the status review page.
/// # Arguments
/// * `_comm` - Mutable reference to Comm.
/// * `success` - If `true`, shows a success status; otherwise, shows a failure status.
/// # Returns
/// This function does not return any value.
/// The status page is displayed for 3 seconds before automatically disappearing.
#[cfg(feature = "io_new")]
pub fn show<const N: usize>(&self, _comm: &mut crate::io::Comm<N>, success: bool) {
self.show_internal(success)
}
/// Shows the status review page.
/// # Arguments
/// * `success` - If `true`, shows a success status; otherwise, shows a failure status.
/// # Returns
/// This function does not return any value.
/// The status page is displayed for 3 seconds before automatically disappearing.
#[cfg(not(feature = "io_new"))]
pub fn show(&self, success: bool) {
self.show_internal(success)
}
}