Skip to content

Commit

Permalink
Merge pull request #120 from LedgerHQ/fix/multifield_stack
Browse files Browse the repository at this point in the history
rework MultiFieldReview to use less stack
  • Loading branch information
yogh333 authored Jan 25, 2024
2 parents ce8a59c + 8e1d525 commit 8211c9d
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 124 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.4.2"
version = "1.4.3"
authors = ["yhql", "yogh333"]
edition = "2021"
license.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion ledger_device_sdk/examples/gadgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_: &PanicInfo) -> ! {
loop {}
ledger_device_sdk::exit_app(1);
}

use ledger_device_sdk::buttons::*;
Expand Down
40 changes: 40 additions & 0 deletions ledger_device_sdk/examples/review.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#![no_std]
#![no_main]

use core::panic::PanicInfo;
#[panic_handler]
fn panic(_: &PanicInfo) -> ! {
ledger_device_sdk::exit_app(1);
}

use ledger_device_sdk::ui::bitmaps::*;
use ledger_device_sdk::ui::gadgets::{Field, MultiFieldReview};

#[no_mangle]
extern "C" fn sample_main() {
let fields = [
Field {
name: "Amount",
value: "CRAB 666",
},
Field {
name: "Destination",
value: "0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae",
},
Field {
name: "Memo",
value: "This is a very long memo. It will force the app client to send the serialized transaction to be sent in chunk. As the maximum chunk size is 255 bytes we will make this memo greater than 255 characters. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam.",
},
];
let review = MultiFieldReview::new(
&fields,
&["Review ", "Transaction"],
Some(&EYE),
"Approve",
Some(&VALIDATE_14),
"Reject",
Some(&CROSSMARK),
);
review.show();
ledger_device_sdk::exit_app(0);
}
13 changes: 13 additions & 0 deletions ledger_device_sdk/src/ui/bagls/mcu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ pub enum Font {
Symbols1,
}

#[derive(Clone, Copy)]
pub struct Label<'a> {
pub loc: Location,
pub layout: Layout,
Expand All @@ -142,6 +143,18 @@ pub struct Label<'a> {
pub text: &'a str,
}

impl Default for Label<'_> {
fn default() -> Self {
Label {
text: "",
bold: false,
dims: (128, 11),
loc: Location::Middle,
layout: Layout::Centered,
}
}
}

impl<'a> Label<'a> {
pub const fn new() -> Self {
Label {
Expand Down
12 changes: 12 additions & 0 deletions ledger_device_sdk/src/ui/bagls/se.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@ use crate::ui::fonts::OPEN_SANS;
use crate::ui::layout::*;
use ledger_secure_sdk_sys;

#[derive(Clone, Copy)]
pub struct Label<'a> {
pub text: &'a str,
pub bold: bool,
pub loc: Location,
layout: Layout,
}

impl Default for Label<'_> {
fn default() -> Self {
Label {
text: "",
bold: false,
loc: Location::Middle,
layout: Layout::Centered,
}
}
}

impl<'a> From<&'a str> for Label<'a> {
fn from(s: &'a str) -> Label<'a> {
Label {
Expand Down
Loading

0 comments on commit 8211c9d

Please sign in to comment.