diff --git a/core/embed/rust/src/ui/model_mercury/component/keyboard/passphrase.rs b/core/embed/rust/src/ui/model_mercury/component/keyboard/passphrase.rs index ed7aa26c35..645882cee1 100644 --- a/core/embed/rust/src/ui/model_mercury/component/keyboard/passphrase.rs +++ b/core/embed/rust/src/ui/model_mercury/component/keyboard/passphrase.rs @@ -1,16 +1,17 @@ use crate::{ strutil::TString, + translations::TR, ui::{ component::{ - base::ComponentExt, text::common::TextBox, Child, Component, Event, EventCtx, Never, + base::ComponentExt, text::common::TextBox, Child, Component, Event, EventCtx, Label, + Maybe, Never, Swipe, SwipeDirection, }, display, - geometry::{Grid, Offset, Rect}, + geometry::{Alignment, Grid, Insets, Offset, Rect}, model_mercury::component::{ button::{Button, ButtonContent, ButtonMsg}, - keyboard::common::{paint_pending_marker, render_pending_marker, MultiTapKeyboard}, - swipe::{Swipe, SwipeDirection}, - theme, ScrollBar, + keyboard::common::{render_pending_marker, MultiTapKeyboard}, + theme, }, shape, shape::Renderer, @@ -19,57 +20,126 @@ use crate::{ }; use core::cell::Cell; +use num_traits::ToPrimitive; pub enum PassphraseKeyboardMsg { Confirmed, Cancelled, } +/// Enum keeping track of which keyboard is shown and which comes next. Keep the +/// number of values and the constant PAGE_COUNT in synch. +#[repr(u32)] +#[derive(Copy, Clone, ToPrimitive)] +enum KeyboardLayout { + LettersLower = 0, + LettersUpper = 1, + Numeric = 2, + Special = 3, +} + +impl KeyboardLayout { + fn next(self) -> Self { + match self { + Self::LettersLower => Self::LettersUpper, + Self::LettersUpper => Self::Numeric, + Self::Numeric => Self::Special, + Self::Special => Self::LettersLower, + } + } + + fn prev(self) -> Self { + match self { + Self::LettersLower => Self::Special, + Self::LettersUpper => Self::LettersLower, + Self::Numeric => Self::LettersUpper, + Self::Special => Self::Numeric, + } + } +} + +impl From for ButtonContent { + /// Used to get content for the "next keyboard" button + fn from(kl: KeyboardLayout) -> Self { + match kl { + KeyboardLayout::LettersLower => ButtonContent::Text("abc".into()), + KeyboardLayout::LettersUpper => ButtonContent::Text("ABC".into()), + KeyboardLayout::Numeric => ButtonContent::Text("123".into()), + KeyboardLayout::Special => ButtonContent::Icon(theme::ICON_ASTERISK), + } + } +} + pub struct PassphraseKeyboard { page_swipe: Swipe, input: Child, - back: Child