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 // 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 // Repeated words get a special hint
} else if self.content.is_repeated() { if self.content.is_repeated() {
self.hint = Hint::new_instruction_green( self.hint = Hint::new_instruction_green(
TR::reset__the_word_is_repeated, TR::reset__the_word_is_repeated,
Some(theme::ICON_INFO), Some(theme::ICON_INFO),

View File

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

View File

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

View File

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