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

chore(eckhart): update share words screen and flow

This commit is contained in:
Lukas Bielesch 2025-02-25 18:30:17 +01:00
parent c1ada0dfed
commit 0ca0a9e9b7
4 changed files with 42 additions and 28 deletions

View File

@ -88,11 +88,8 @@ impl<'a> ShareWordsScreen<'a> {
// Update hint content based on the current page
// First word gets a special hint
if self.content.pager().is_first() {
self.hint = Hint::new_instruction(TR::reset__share_words_first, Some(theme::ICON_INFO));
// Repeated words get a special hint
} else if self.content.is_repeated() {
if self.content.is_repeated() {
self.hint = Hint::new_instruction_green(
TR::reset__the_word_is_repeated,
Some(theme::ICON_INFO),

View File

@ -4,11 +4,8 @@ use crate::{
translations::TR,
ui::{
component::{
text::{
op::OpTextLayout,
paragraphs::{Paragraph, ParagraphSource},
},
ComponentExt, FormattedText,
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort},
ComponentExt,
},
flow::{
base::{Decision, DecisionBuilder as _},
@ -24,7 +21,7 @@ use super::super::{
component::{
ActionBar, Button, Header, ShareWordsScreen, ShareWordsScreenMsg, TextScreen, TextScreenMsg,
},
fonts, theme,
theme,
};
#[derive(Copy, Clone, PartialEq, Eq)]
@ -32,6 +29,7 @@ pub enum ShowShareWords {
Instruction,
ShareWords,
Confirm,
CheckBackupIntro,
}
impl FlowController for ShowShareWords {
@ -53,7 +51,8 @@ impl FlowController for ShowShareWords {
(Self::ShareWords, FlowMsg::Cancelled) => Self::Instruction.goto(),
(Self::ShareWords, FlowMsg::Confirmed) => Self::Confirm.goto(),
(Self::Confirm, FlowMsg::Cancelled) => Self::ShareWords.goto(),
(Self::Confirm, FlowMsg::Confirmed) => self.return_msg(FlowMsg::Confirmed),
(Self::Confirm, FlowMsg::Confirmed) => Self::CheckBackupIntro.goto(),
(Self::CheckBackupIntro, FlowMsg::Confirmed) => self.return_msg(FlowMsg::Confirmed),
_ => self.do_nothing(),
}
}
@ -62,13 +61,13 @@ impl FlowController for ShowShareWords {
pub fn new_show_share_words_flow(
words: Vec<TString<'static>, 33>,
_subtitle: TString<'static>,
instruction: Paragraph<'static>,
instructions_paragraphs: ParagraphVecShort<'static>,
text_confirm: TString<'static>,
) -> Result<SwipeFlow, error::Error> {
let instruction = TextScreen::new(
instruction
instructions_paragraphs
.into_paragraphs()
.with_placement(LinearPlacement::vertical()),
.with_placement(LinearPlacement::vertical().with_spacing(24)),
)
.with_header(Header::new(TR::reset__recovery_wallet_backup_title.into()))
.with_action_bar(ActionBar::new_double(
@ -86,13 +85,14 @@ pub fn new_show_share_words_flow(
ShareWordsScreenMsg::Confirmed => Some(FlowMsg::Confirmed),
});
let op_confirm =
OpTextLayout::new(theme::TEXT_NORMAL).text(text_confirm, fonts::FONT_SATOSHI_REGULAR_38);
let confirm_paragraphs = Paragraph::new(&theme::TEXT_REGULAR, text_confirm)
.into_paragraphs()
.with_placement(LinearPlacement::vertical());
let confirm = TextScreen::new(FormattedText::new(op_confirm))
let confirm = TextScreen::new(confirm_paragraphs)
.with_header(Header::new(TR::reset__recovery_wallet_backup_title.into()))
.with_action_bar(ActionBar::new_double(
Button::with_icon(theme::ICON_CHEVRON_LEFT),
Button::with_icon(theme::ICON_CHEVRON_UP),
Button::with_text(TR::buttons__hold_to_confirm.into())
.styled(theme::button_confirm())
.with_long_press(theme::CONFIRM_HOLD_DURATION),
@ -103,9 +103,25 @@ pub fn new_show_share_words_flow(
TextScreenMsg::Menu => Some(FlowMsg::Cancelled),
});
let check_backup_paragraphs =
Paragraph::new(&theme::TEXT_REGULAR, TR::reset__check_backup_instructions)
.into_paragraphs()
.with_placement(LinearPlacement::vertical());
let check_backup_intro = TextScreen::new(check_backup_paragraphs)
.with_header(Header::new(TR::reset__check_wallet_backup_title.into()))
.with_action_bar(ActionBar::new_single(Button::with_text(
TR::buttons__continue.into(),
)))
.map(|msg| match msg {
TextScreenMsg::Confirmed => Some(FlowMsg::Confirmed),
_ => None,
});
let res = SwipeFlow::new(&ShowShareWords::Instruction)?
.with_page(&ShowShareWords::Instruction, instruction)?
.with_page(&ShowShareWords::ShareWords, share_words)?
.with_page(&ShowShareWords::Confirm, confirm)?;
.with_page(&ShowShareWords::Confirm, confirm)?
.with_page(&ShowShareWords::CheckBackupIntro, check_backup_intro)?;
Ok(res)
}

View File

@ -623,17 +623,16 @@ impl FirmwareUI for UIEckhart {
_text_footer: Option<TString<'static>>,
text_confirm: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error> {
// TODO: add support for multiple instructions
let instruction: TString = IterBuf::new()
.try_iterate(instructions)?
.next()
.unwrap()
.try_into()?;
let mut instructions_paragraphs = ParagraphVecShort::new();
for item in IterBuf::new().try_iterate(instructions)? {
let text: TString = item.try_into()?;
instructions_paragraphs.add(Paragraph::new(&theme::TEXT_REGULAR, text));
}
let flow = flow::show_share_words::new_show_share_words_flow(
words,
subtitle.unwrap_or(TString::empty()),
Paragraph::new(&theme::TEXT_REGULAR, instruction),
instructions_paragraphs,
text_confirm,
)?;
Ok(flow)

View File

@ -27,8 +27,10 @@ def show_share_words(
words_count = len(share_words)
description = None
# Eckhart currently has only one instruction, other are shown in the hint area
instructions = [TR.reset__write_down_words_template.format(words_count)]
assert len(instructions) == 1
instructions = [
TR.reset__write_down_words_template.format(words_count),
TR.reset__words_may_repeat,
]
text_confirm = TR.reset__words_written_down_template.format(words_count)
return raise_if_not_confirmed(