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

rework MultiFieldReview to use less stack #120

Merged
merged 2 commits into from
Jan 25, 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
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