1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-28 15:22:14 +00:00

feat(eckhart): implement confirm_action

This commit is contained in:
obrusvit 2025-01-13 17:49:24 +01:00
parent f2c5456bf8
commit 2b81f99e15
2 changed files with 79 additions and 13 deletions

View File

@ -12,6 +12,7 @@ use super::{
fonts,
};
pub const CONFIRM_HOLD_DURATION: Duration = Duration::from_millis(1500);
pub const ERASE_HOLD_DURATION: Duration = Duration::from_millis(1500);
// Color palette.
@ -147,7 +148,7 @@ pub const fn button_default() -> ButtonStyleSheet {
font: fonts::FONT_SATOSHI_MEDIUM_26,
text_color: GREY_LIGHT,
button_color: BG,
icon_color: FG,
icon_color: GREY_LIGHT,
background_color: BG,
},
active: &ButtonStyle {
@ -167,6 +168,32 @@ pub const fn button_default() -> ButtonStyleSheet {
}
}
pub const fn button_confirm() -> ButtonStyleSheet {
ButtonStyleSheet {
normal: &ButtonStyle {
font: fonts::FONT_SATOSHI_MEDIUM_26,
text_color: GREEN_LIGHT,
button_color: BG,
icon_color: GREEN_LIGHT,
background_color: BG,
},
active: &ButtonStyle {
font: fonts::FONT_SATOSHI_MEDIUM_26,
text_color: GREEN,
button_color: GREY_SUPER_DARK,
icon_color: GREEN,
background_color: BG,
},
disabled: &ButtonStyle {
font: fonts::FONT_SATOSHI_MEDIUM_26,
text_color: GREY_LIGHT,
button_color: GREY_DARK,
icon_color: GREY_LIGHT,
background_color: GREY_DARK,
},
}
}
pub const fn button_header() -> ButtonStyleSheet {
ButtonStyleSheet {

View File

@ -3,14 +3,18 @@ use crate::{
io::BinaryData,
micropython::{gc::Gc, list::List, obj::Obj},
strutil::TString,
translations::TR,
ui::{
component::{
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort},
Empty,
text::{
op::OpTextLayout,
paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort},
},
Empty, FormattedText,
},
layout::{
obj::{LayoutMaybeTrace, LayoutObj, RootComponent},
util::RecoveryType,
util::{ConfirmValueParams, RecoveryType, StrOrBytes},
},
ui_firmware::{
FirmwareUI, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS,
@ -20,25 +24,60 @@ use crate::{
};
use super::{
component::{ActionBar, Button, GenericScreen, Header, Hint},
theme, UIEckhart,
component::{ActionBar, Button, Header, Hint, TextScreen},
fonts, theme, UIEckhart,
};
impl FirmwareUI for UIEckhart {
fn confirm_action(
_title: TString<'static>,
_action: Option<TString<'static>>,
_description: Option<TString<'static>>,
title: TString<'static>,
action: Option<TString<'static>>,
description: Option<TString<'static>>,
_subtitle: Option<TString<'static>>,
_verb: Option<TString<'static>>,
verb: Option<TString<'static>>,
_verb_cancel: Option<TString<'static>>,
_hold: bool,
hold: bool,
_hold_danger: bool,
_reverse: bool,
reverse: bool,
_prompt_screen: bool,
_prompt_title: Option<TString<'static>>,
) -> Result<impl LayoutMaybeTrace, Error> {
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(c"not implemented"))
let action = action.unwrap_or("".into());
let description = description.unwrap_or("".into());
let formatted_text = {
let ops = if !reverse {
OpTextLayout::new(theme::TEXT_NORMAL)
.color(theme::GREY_LIGHT)
.text(action, fonts::FONT_SATOSHI_REGULAR_38)
.newline()
.color(theme::GREY)
.text(description, fonts::FONT_SATOSHI_REGULAR_22)
} else {
OpTextLayout::new(theme::TEXT_NORMAL)
.color(theme::GREY)
.text(description, fonts::FONT_SATOSHI_REGULAR_22)
.newline()
.color(theme::GREY_LIGHT)
.text(action, fonts::FONT_SATOSHI_REGULAR_38)
};
FormattedText::new(ops).vertically_centered()
};
let verb = verb.unwrap_or(TR::buttons__confirm.into());
let right_button = if hold {
Button::with_text(verb).with_long_press(theme::CONFIRM_HOLD_DURATION)
} else {
Button::with_text(verb)
};
let screen = TextScreen::new(formatted_text)
.with_header(Header::new(title).with_menu_button())
.with_hint(Hint::new_instruction(description, None))
.with_action_bar(ActionBar::new_double(
Button::with_icon(theme::ICON_CHEVRON_LEFT),
right_button,
));
let layout = RootComponent::new(screen);
Ok(layout)
}
fn confirm_address(