mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-28 23:32:05 +00:00
feat(eckhart): implement confirm_action
This commit is contained in:
parent
f2c5456bf8
commit
2b81f99e15
@ -12,6 +12,7 @@ use super::{
|
|||||||
fonts,
|
fonts,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const CONFIRM_HOLD_DURATION: Duration = Duration::from_millis(1500);
|
||||||
pub const ERASE_HOLD_DURATION: Duration = Duration::from_millis(1500);
|
pub const ERASE_HOLD_DURATION: Duration = Duration::from_millis(1500);
|
||||||
|
|
||||||
// Color palette.
|
// Color palette.
|
||||||
@ -147,7 +148,7 @@ pub const fn button_default() -> ButtonStyleSheet {
|
|||||||
font: fonts::FONT_SATOSHI_MEDIUM_26,
|
font: fonts::FONT_SATOSHI_MEDIUM_26,
|
||||||
text_color: GREY_LIGHT,
|
text_color: GREY_LIGHT,
|
||||||
button_color: BG,
|
button_color: BG,
|
||||||
icon_color: FG,
|
icon_color: GREY_LIGHT,
|
||||||
background_color: BG,
|
background_color: BG,
|
||||||
},
|
},
|
||||||
active: &ButtonStyle {
|
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 {
|
pub const fn button_header() -> ButtonStyleSheet {
|
||||||
ButtonStyleSheet {
|
ButtonStyleSheet {
|
||||||
|
@ -3,14 +3,18 @@ use crate::{
|
|||||||
io::BinaryData,
|
io::BinaryData,
|
||||||
micropython::{gc::Gc, list::List, obj::Obj},
|
micropython::{gc::Gc, list::List, obj::Obj},
|
||||||
strutil::TString,
|
strutil::TString,
|
||||||
|
translations::TR,
|
||||||
ui::{
|
ui::{
|
||||||
component::{
|
component::{
|
||||||
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort},
|
text::{
|
||||||
Empty,
|
op::OpTextLayout,
|
||||||
|
paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort},
|
||||||
|
},
|
||||||
|
Empty, FormattedText,
|
||||||
},
|
},
|
||||||
layout::{
|
layout::{
|
||||||
obj::{LayoutMaybeTrace, LayoutObj, RootComponent},
|
obj::{LayoutMaybeTrace, LayoutObj, RootComponent},
|
||||||
util::RecoveryType,
|
util::{ConfirmValueParams, RecoveryType, StrOrBytes},
|
||||||
},
|
},
|
||||||
ui_firmware::{
|
ui_firmware::{
|
||||||
FirmwareUI, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS,
|
FirmwareUI, MAX_CHECKLIST_ITEMS, MAX_GROUP_SHARE_LINES, MAX_WORD_QUIZ_ITEMS,
|
||||||
@ -20,25 +24,60 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
component::{ActionBar, Button, GenericScreen, Header, Hint},
|
component::{ActionBar, Button, Header, Hint, TextScreen},
|
||||||
theme, UIEckhart,
|
fonts, theme, UIEckhart,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl FirmwareUI for UIEckhart {
|
impl FirmwareUI for UIEckhart {
|
||||||
fn confirm_action(
|
fn confirm_action(
|
||||||
_title: TString<'static>,
|
title: TString<'static>,
|
||||||
_action: Option<TString<'static>>,
|
action: Option<TString<'static>>,
|
||||||
_description: Option<TString<'static>>,
|
description: Option<TString<'static>>,
|
||||||
_subtitle: Option<TString<'static>>,
|
_subtitle: Option<TString<'static>>,
|
||||||
_verb: Option<TString<'static>>,
|
verb: Option<TString<'static>>,
|
||||||
_verb_cancel: Option<TString<'static>>,
|
_verb_cancel: Option<TString<'static>>,
|
||||||
_hold: bool,
|
hold: bool,
|
||||||
_hold_danger: bool,
|
_hold_danger: bool,
|
||||||
_reverse: bool,
|
reverse: bool,
|
||||||
_prompt_screen: bool,
|
_prompt_screen: bool,
|
||||||
_prompt_title: Option<TString<'static>>,
|
_prompt_title: Option<TString<'static>>,
|
||||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
) -> 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(
|
fn confirm_address(
|
||||||
|
Loading…
Reference in New Issue
Block a user