mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-04 05:42:34 +00:00
feat(core): create new design for word-count input
This commit is contained in:
parent
51fb99d792
commit
e68c4456a6
@ -10,7 +10,7 @@ use crate::ui::{
|
|||||||
|
|
||||||
const NUMBERS: [u32; 5] = [12, 18, 20, 24, 33];
|
const NUMBERS: [u32; 5] = [12, 18, 20, 24, 33];
|
||||||
const LABELS: [&str; 5] = ["12", "18", "20", "24", "33"];
|
const LABELS: [&str; 5] = ["12", "18", "20", "24", "33"];
|
||||||
const CELLS: [(usize, usize); 5] = [(0, 0), (0, 2), (0, 4), (1, 0), (1, 2)];
|
const CELLS: [(usize, usize); 5] = [(0, 0), (0, 4), (1, 0), (1, 4), (2, 2)];
|
||||||
|
|
||||||
pub struct SelectWordCount {
|
pub struct SelectWordCount {
|
||||||
button: [Button<&'static str>; NUMBERS.len()],
|
button: [Button<&'static str>; NUMBERS.len()],
|
||||||
@ -32,12 +32,13 @@ impl Component for SelectWordCount {
|
|||||||
type Msg = SelectWordCountMsg;
|
type Msg = SelectWordCountMsg;
|
||||||
|
|
||||||
fn place(&mut self, bounds: Rect) -> Rect {
|
fn place(&mut self, bounds: Rect) -> Rect {
|
||||||
let (_, bounds) = bounds.split_bottom(2 * theme::BUTTON_HEIGHT + theme::BUTTON_SPACING);
|
let (_, bounds) =
|
||||||
let grid = Grid::new(bounds, 2, 6).with_spacing(theme::BUTTON_SPACING);
|
bounds.split_bottom(3 * theme::WORDCOUNT_BUTTON_HEIGHT + theme::PIN_BUTTON_SPACING);
|
||||||
|
let grid = Grid::new(bounds, 3, 8).with_spacing(theme::PIN_BUTTON_SPACING);
|
||||||
for (btn, (x, y)) in self.button.iter_mut().zip(CELLS) {
|
for (btn, (x, y)) in self.button.iter_mut().zip(CELLS) {
|
||||||
btn.place(grid.cells(GridCellSpan {
|
btn.place(grid.cells(GridCellSpan {
|
||||||
from: (x, y),
|
from: (x, y),
|
||||||
to: (x, y + 1),
|
to: (x, y + 3),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
bounds
|
bounds
|
||||||
|
@ -1475,23 +1475,12 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
|
|||||||
|
|
||||||
extern "C" fn new_select_word_count(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
extern "C" fn new_select_word_count(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
||||||
let block = move |_args: &[Obj], kwargs: &Map| {
|
let block = move |_args: &[Obj], kwargs: &Map| {
|
||||||
let dry_run: bool = kwargs.get(Qstr::MP_QSTR_dry_run)?.try_into()?;
|
|
||||||
let title: StrBuffer = if dry_run {
|
|
||||||
TR::recovery__title_dry_run.try_into()?
|
|
||||||
} else {
|
|
||||||
TR::recovery__title.try_into()?
|
|
||||||
};
|
|
||||||
|
|
||||||
let paragraphs = Paragraphs::new(Paragraph::<StrBuffer>::new(
|
let paragraphs = Paragraphs::new(Paragraph::<StrBuffer>::new(
|
||||||
&theme::TEXT_DEMIBOLD,
|
&theme::TEXT_DEMIBOLD,
|
||||||
TR::recovery__select_num_of_words.try_into()?,
|
TR::recovery__select_num_of_words.try_into()?,
|
||||||
));
|
));
|
||||||
|
|
||||||
let obj = LayoutObj::new(Frame::left_aligned(
|
let obj = LayoutObj::new(Dialog::new(paragraphs, SelectWordCount::new()))?;
|
||||||
theme::label_title(),
|
|
||||||
title,
|
|
||||||
Dialog::new(paragraphs, SelectWordCount::new()),
|
|
||||||
))?;
|
|
||||||
Ok(obj.into())
|
Ok(obj.into())
|
||||||
};
|
};
|
||||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||||
@ -2038,7 +2027,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
|||||||
|
|
||||||
/// def select_word_count(
|
/// def select_word_count(
|
||||||
/// *,
|
/// *,
|
||||||
/// dry_run: bool,
|
/// dry_run: bool, # unused in T3T1
|
||||||
/// ) -> int | str: # TT returns int
|
/// ) -> int | str: # TT returns int
|
||||||
/// """Select mnemonic word count from (12, 18, 20, 24, 33)."""
|
/// """Select mnemonic word count from (12, 18, 20, 24, 33)."""
|
||||||
Qstr::MP_QSTR_select_word_count => obj_fn_kw!(0, new_select_word_count).as_obj(),
|
Qstr::MP_QSTR_select_word_count => obj_fn_kw!(0, new_select_word_count).as_obj(),
|
||||||
|
@ -714,6 +714,7 @@ pub const TEXT_CHECKLIST_DONE: TextStyle =
|
|||||||
|
|
||||||
pub const CONTENT_BORDER: i16 = 0;
|
pub const CONTENT_BORDER: i16 = 0;
|
||||||
pub const BUTTON_HEIGHT: i16 = 50;
|
pub const BUTTON_HEIGHT: i16 = 50;
|
||||||
|
pub const WORDCOUNT_BUTTON_HEIGHT: i16 = 60;
|
||||||
pub const BUTTON_WIDTH: i16 = 56;
|
pub const BUTTON_WIDTH: i16 = 56;
|
||||||
pub const BUTTON_SPACING: i16 = 6;
|
pub const BUTTON_SPACING: i16 = 6;
|
||||||
pub const KEYBOARD_SPACING: i16 = BUTTON_SPACING;
|
pub const KEYBOARD_SPACING: i16 = BUTTON_SPACING;
|
||||||
|
Loading…
Reference in New Issue
Block a user