mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-03 21:32:33 +00:00
fixup! model R bld
This commit is contained in:
parent
1ce85119c3
commit
a97a25f76a
@ -11,7 +11,7 @@ use crate::ui::{
|
|||||||
theme::{BLD_BG, BLD_FG},
|
theme::{BLD_BG, BLD_FG},
|
||||||
ReturnToC,
|
ReturnToC,
|
||||||
},
|
},
|
||||||
component::{ChoiceFactory, ChoicePage, ChoicePageMsg},
|
component::{Choice, ChoiceFactory, ChoicePage, ChoicePageMsg},
|
||||||
theme::ICON_BIN,
|
theme::ICON_BIN,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -43,43 +43,58 @@ impl MenuChoiceFactory {
|
|||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {}
|
Self {}
|
||||||
}
|
}
|
||||||
fn get(&self, choice_index: u8) -> (&'static str, &'static str, &'static [u8]) {
|
}
|
||||||
MenuChoiceFactory::CHOICES[choice_index as usize]
|
|
||||||
|
pub struct MenuChoice {
|
||||||
|
text1: &'static str,
|
||||||
|
text2: &'static str,
|
||||||
|
icon: &'static [u8],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MenuChoice {
|
||||||
|
pub fn new(text1: &'static str, text2: &'static str, icon: &'static [u8]) -> Self {
|
||||||
|
Self { text1, text2, icon }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChoiceFactory for MenuChoiceFactory {
|
impl Choice for MenuChoice {
|
||||||
fn count(&self) -> u8 {
|
fn paint_center(&self, _area: Rect, _inverse: bool) {
|
||||||
CHOICE_LENGTH as u8
|
display::icon(
|
||||||
}
|
screen().center() + Offset::y(-20),
|
||||||
|
self.icon,
|
||||||
fn paint_center(&self, choice_index: u8, _area: Rect, _inverse: bool) {
|
BLD_FG,
|
||||||
let content = self.get(choice_index);
|
BLD_BG,
|
||||||
|
);
|
||||||
let text_1 = content.0;
|
|
||||||
let text_2 = content.1;
|
|
||||||
let icon = content.2;
|
|
||||||
|
|
||||||
display::icon(screen().center() + Offset::y(-20), icon, BLD_FG, BLD_BG);
|
|
||||||
display::text_center(
|
display::text_center(
|
||||||
screen().center() + Offset::y(0),
|
screen().center() + Offset::y(0),
|
||||||
text_1,
|
self.text1,
|
||||||
Font::NORMAL,
|
Font::NORMAL,
|
||||||
BLD_FG,
|
BLD_FG,
|
||||||
BLD_BG,
|
BLD_BG,
|
||||||
);
|
);
|
||||||
display::text_center(
|
display::text_center(
|
||||||
screen().center() + Offset::y(10),
|
screen().center() + Offset::y(10),
|
||||||
text_2,
|
self.text2,
|
||||||
Font::NORMAL,
|
Font::NORMAL,
|
||||||
BLD_FG,
|
BLD_FG,
|
||||||
BLD_BG,
|
BLD_BG,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ui_debug")]
|
impl ChoiceFactory for MenuChoiceFactory {
|
||||||
fn trace(&self, t: &mut dyn Tracer, name: &str, choice_index: u8) {
|
type Item = MenuChoice;
|
||||||
t.field(name, &self.get(choice_index));
|
|
||||||
|
fn count(&self) -> u8 {
|
||||||
|
CHOICE_LENGTH as u8
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get(&self, choice_index: u8) -> MenuChoice {
|
||||||
|
MenuChoice::new(
|
||||||
|
MenuChoiceFactory::CHOICES[choice_index as usize].0,
|
||||||
|
MenuChoiceFactory::CHOICES[choice_index as usize].1,
|
||||||
|
MenuChoiceFactory::CHOICES[choice_index as usize].2,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user