mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-26 15:20:58 +00:00
WIP: feat(jefferson): confirm action prototype
This commit is contained in:
parent
f045779d37
commit
5dffbb974d
@ -13,6 +13,7 @@ use crate::{
|
||||
|
||||
use super::component::{ButtonStyle, ButtonStyleSheet, ResultStyle};
|
||||
|
||||
pub const CONFIRM_HOLD_DURATION: Duration = Duration::from_millis(1500);
|
||||
pub const ERASE_HOLD_DURATION: Duration = Duration::from_millis(1500);
|
||||
|
||||
// Color palette.
|
||||
@ -99,25 +100,51 @@ pub const fn button_default() -> ButtonStyleSheet {
|
||||
ButtonStyleSheet {
|
||||
normal: &ButtonStyle {
|
||||
font: Font::DEMIBOLD,
|
||||
text_color: FG,
|
||||
text_color: GREY_LIGHT,
|
||||
button_color: BG,
|
||||
icon_color: FG,
|
||||
icon_color: GREY_LIGHT,
|
||||
background_color: BG,
|
||||
},
|
||||
active: &ButtonStyle {
|
||||
font: Font::DEMIBOLD,
|
||||
text_color: FG,
|
||||
button_color: BG,
|
||||
icon_color: FG,
|
||||
text_color: GREY_LIGHT,
|
||||
button_color: GREY_SUPER_DARK,
|
||||
icon_color: GREY_LIGHT,
|
||||
background_color: BG,
|
||||
},
|
||||
disabled: &ButtonStyle {
|
||||
font: Font::DEMIBOLD,
|
||||
text_color: FG,
|
||||
text_color: GREY_LIGHT,
|
||||
button_color: GREY_DARK,
|
||||
icon_color: GREY_LIGHT,
|
||||
background_color: GREY_DARK,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn button_confirm() -> ButtonStyleSheet {
|
||||
ButtonStyleSheet {
|
||||
normal: &ButtonStyle {
|
||||
font: Font::DEMIBOLD,
|
||||
text_color: GREEN_LIGHT,
|
||||
button_color: BG,
|
||||
icon_color: FG,
|
||||
icon_color: GREEN_LIGHT,
|
||||
background_color: BG,
|
||||
},
|
||||
active: &ButtonStyle {
|
||||
font: Font::DEMIBOLD,
|
||||
text_color: GREEN,
|
||||
button_color: GREY_SUPER_DARK,
|
||||
icon_color: GREEN,
|
||||
background_color: BG,
|
||||
},
|
||||
disabled: &ButtonStyle {
|
||||
font: Font::DEMIBOLD,
|
||||
text_color: GREY_LIGHT,
|
||||
button_color: GREY_DARK,
|
||||
icon_color: GREY_LIGHT,
|
||||
background_color: GREY_DARK,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,14 @@ 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},
|
||||
@ -19,23 +23,60 @@ use crate::{
|
||||
},
|
||||
};
|
||||
|
||||
use super::{theme, UIJefferson};
|
||||
use super::{
|
||||
component::{ActionBar, Button, GenericScreen, Header, Hint},
|
||||
theme, UIJefferson,
|
||||
};
|
||||
|
||||
impl FirmwareUI for UIJefferson {
|
||||
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 {
|
||||
let mut ops_text = OpTextLayout::new(theme::TEXT_NORMAL);
|
||||
OpTextLayout::new(theme::TEXT_NORMAL)
|
||||
.text_normal(action)
|
||||
.newline()
|
||||
.text_normal(description)
|
||||
} else {
|
||||
OpTextLayout::new(theme::TEXT_NORMAL)
|
||||
.text_normal(description)
|
||||
.newline()
|
||||
.text_demibold(action)
|
||||
};
|
||||
|
||||
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 = GenericScreen::new(formatted_text)
|
||||
.with_header(Header::new(title))
|
||||
// .with_hint(Hint::new_instruction(description, None))
|
||||
.with_hint(Hint::new_page_counter())
|
||||
.with_action_bar(ActionBar::new_paginate(
|
||||
Button::with_icon(theme::ICON_CHEVRON_LEFT),
|
||||
right_button,
|
||||
));
|
||||
let layout = RootComponent::new(screen);
|
||||
Ok(layout)
|
||||
}
|
||||
|
||||
fn confirm_address(
|
||||
|
Loading…
Reference in New Issue
Block a user