From 1f35a64c3b99b8740f5776cc4df7f864d57bd75e Mon Sep 17 00:00:00 2001 From: grdddj Date: Sat, 12 Nov 2022 08:52:39 +0100 Subject: [PATCH] WIP - fixes and comments --- core/embed/rust/src/ui/model_tr/component/bip39.rs | 8 ++++---- .../rust/src/ui/model_tr/component/passphrase.rs | 5 +++-- .../rust/src/ui/model_tr/component/simple_choice.rs | 4 +++- core/mocks/generated/trezorui2.pyi | 11 +++++++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/core/embed/rust/src/ui/model_tr/component/bip39.rs b/core/embed/rust/src/ui/model_tr/component/bip39.rs index 530dba2c90..a0c24c8f55 100644 --- a/core/embed/rust/src/ui/model_tr/component/bip39.rs +++ b/core/embed/rust/src/ui/model_tr/component/bip39.rs @@ -16,7 +16,7 @@ pub enum Bip39EntryMsg { ResultWord(String<15>), } -const MAX_LENGTH: usize = 10; +const MAX_WORD_LENGTH: usize = 10; const MAX_CHOICE_LENGTH: usize = 26; /// Offer words when there will be fewer of them than this @@ -110,9 +110,9 @@ impl ChoiceFactory for ChoiceFactoryBIP39 { /// Component for entering a BIP39 mnemonic. pub struct Bip39Entry { choice_page: ChoicePage, - chosen_letters: Child>>, + chosen_letters: Child>>, letter_choices: Vec, - textbox: TextBox, + textbox: TextBox, offer_words: bool, words_list: bip39::Wordlist, } @@ -154,7 +154,7 @@ impl Bip39Entry { } fn update_chosen_letters(&mut self, ctx: &mut EventCtx) { - let text = build_string!({ MAX_LENGTH + 1 }, self.textbox.content(), PROMPT); + let text = build_string!({ MAX_WORD_LENGTH + 1 }, self.textbox.content(), PROMPT); self.chosen_letters.inner_mut().update_text(text); self.chosen_letters.request_complete_repaint(ctx); } diff --git a/core/embed/rust/src/ui/model_tr/component/passphrase.rs b/core/embed/rust/src/ui/model_tr/component/passphrase.rs index f67abafb3c..d882f6d54e 100644 --- a/core/embed/rust/src/ui/model_tr/component/passphrase.rs +++ b/core/embed/rust/src/ui/model_tr/component/passphrase.rs @@ -112,13 +112,14 @@ impl ChoiceFactoryPassphrase { ButtonLayout::default_three_icons(), ); - // Including accept button on the left and cancel on the very right + // Including accept button on the left and cancel on the very right. // TODO: could have some icons instead of the shortcut text if choice_index == 0 { menu_item.set_left_btn(Some( ButtonDetails::text("ACC").with_duration(HOLD_DURATION), )); - } else if choice_index == MENU.len() as u8 - 1 { + } + if choice_index == MENU.len() as u8 - 1 { menu_item.set_right_btn(Some( ButtonDetails::text("CAN").with_duration(HOLD_DURATION), )); diff --git a/core/embed/rust/src/ui/model_tr/component/simple_choice.rs b/core/embed/rust/src/ui/model_tr/component/simple_choice.rs index af91bde0e7..5fcd84d2bc 100644 --- a/core/embed/rust/src/ui/model_tr/component/simple_choice.rs +++ b/core/embed/rust/src/ui/model_tr/component/simple_choice.rs @@ -42,10 +42,12 @@ where let mut choice_item = ChoiceItem::new(text, ButtonLayout::default_three_icons()); // Disabling prev/next buttons for the first/last choice when not in carousel. + // (could be done to the same button if there is only one) if !self.carousel { if choice_index == 0 { choice_item.set_left_btn(None); - } else if choice_index as usize == N - 1 { + } + if choice_index as usize == N - 1 { choice_item.set_right_btn(None); } } diff --git a/core/mocks/generated/trezorui2.pyi b/core/mocks/generated/trezorui2.pyi index 670226a962..87eb5be5e5 100644 --- a/core/mocks/generated/trezorui2.pyi +++ b/core/mocks/generated/trezorui2.pyi @@ -90,6 +90,17 @@ def confirm_total_r( """Confirm summary of a transaction. Specific for model R.""" +# rust/src/ui/model_tr/layout.rs +def show_qr( + *, + title: str, + address: str, + verb_cancel: str, + case_sensitive: bool, +) -> object: + """Show QR code.""" + + # rust/src/ui/model_tr/layout.rs def tutorial() -> object: """Show user how to interact with the device."""