mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-27 23:02:02 +00:00
chore(core): modify design of recovery flow
[no changelog]
This commit is contained in:
parent
a8d57bf2c4
commit
463f0df22a
@ -33,7 +33,7 @@ where
|
|||||||
Self {
|
Self {
|
||||||
prompt: Child::new(Maybe::visible(
|
prompt: Child::new(Maybe::visible(
|
||||||
theme::BG,
|
theme::BG,
|
||||||
Label::centered(prompt, theme::label_keyboard()),
|
Label::centered(prompt, theme::label_keyboard_prompt()),
|
||||||
)),
|
)),
|
||||||
back: Child::new(Maybe::hidden(
|
back: Child::new(Maybe::hidden(
|
||||||
theme::BG,
|
theme::BG,
|
||||||
|
@ -194,7 +194,8 @@ impl Component for Slip39Input {
|
|||||||
impl Slip39Input {
|
impl Slip39Input {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
button: Button::empty(),
|
// Button has the same style the whole time
|
||||||
|
button: Button::empty().styled(theme::button_pin_confirm()),
|
||||||
textbox: TextBox::empty(),
|
textbox: TextBox::empty(),
|
||||||
multi_tap: MultiTapKeyboard::new(),
|
multi_tap: MultiTapKeyboard::new(),
|
||||||
final_word: None,
|
final_word: None,
|
||||||
@ -232,13 +233,11 @@ impl Slip39Input {
|
|||||||
if self.final_word.is_some() {
|
if self.final_word.is_some() {
|
||||||
// Confirm button.
|
// Confirm button.
|
||||||
self.button.enable(ctx);
|
self.button.enable(ctx);
|
||||||
self.button.set_stylesheet(ctx, theme::button_pin_confirm());
|
|
||||||
self.button
|
self.button
|
||||||
.set_content(ctx, ButtonContent::Icon(theme::ICON_LIST_CHECK));
|
.set_content(ctx, ButtonContent::Icon(theme::ICON_LIST_CHECK));
|
||||||
} else {
|
} else {
|
||||||
// Disabled button.
|
// Disabled button.
|
||||||
self.button.disable(ctx);
|
self.button.disable(ctx);
|
||||||
self.button.set_stylesheet(ctx, theme::button_pin());
|
|
||||||
self.button.set_content(ctx, ButtonContent::Text(""));
|
self.button.set_content(ctx, ButtonContent::Text(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use crate::ui::{
|
|||||||
|
|
||||||
const NUMBERS: [u32; 5] = [12, 18, 20, 24, 33];
|
const NUMBERS: [u32; 5] = [12, 18, 20, 24, 33];
|
||||||
const LABELS: [&str; 5] = ["12", "18", "20", "24", "33"];
|
const LABELS: [&str; 5] = ["12", "18", "20", "24", "33"];
|
||||||
const CELLS: [(usize, usize); 5] = [(0, 0), (0, 2), (0, 4), (1, 1), (1, 3)];
|
const CELLS: [(usize, usize); 5] = [(0, 0), (0, 2), (0, 4), (1, 0), (1, 2)];
|
||||||
|
|
||||||
pub struct SelectWordCount {
|
pub struct SelectWordCount {
|
||||||
button: [Button<&'static str>; NUMBERS.len()],
|
button: [Button<&'static str>; NUMBERS.len()],
|
||||||
|
@ -1393,19 +1393,20 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
|
|||||||
let info_button: bool = kwargs.get_or(Qstr::MP_QSTR_info_button, false)?;
|
let info_button: bool = kwargs.get_or(Qstr::MP_QSTR_info_button, false)?;
|
||||||
|
|
||||||
let paragraphs = Paragraphs::new([
|
let paragraphs = Paragraphs::new([
|
||||||
Paragraph::new(&theme::TEXT_DEMIBOLD, title).centered(),
|
Paragraph::new(&theme::TEXT_DEMIBOLD, title),
|
||||||
Paragraph::new(&theme::TEXT_NORMAL_OFF_WHITE, description).centered(),
|
Paragraph::new(&theme::TEXT_NORMAL, description),
|
||||||
])
|
])
|
||||||
.with_spacing(theme::RECOVERY_SPACING);
|
.with_spacing(theme::RECOVERY_SPACING);
|
||||||
|
|
||||||
let notification = if dry_run {
|
let notification = if dry_run {
|
||||||
"BACKUP CHECK"
|
"BACKUP CHECK"
|
||||||
} else {
|
} else {
|
||||||
"RECOVERY MODE"
|
"RECOVER WALLET"
|
||||||
};
|
};
|
||||||
|
|
||||||
let obj = if info_button {
|
let obj = if info_button {
|
||||||
LayoutObj::new(NotificationFrame::new(
|
LayoutObj::new(Frame::left_aligned(
|
||||||
|
theme::label_title(),
|
||||||
notification,
|
notification,
|
||||||
Dialog::new(
|
Dialog::new(
|
||||||
paragraphs,
|
paragraphs,
|
||||||
@ -1413,7 +1414,8 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
|
|||||||
),
|
),
|
||||||
))?
|
))?
|
||||||
} else {
|
} else {
|
||||||
LayoutObj::new(NotificationFrame::new(
|
LayoutObj::new(Frame::left_aligned(
|
||||||
|
theme::label_title(),
|
||||||
notification,
|
notification,
|
||||||
Dialog::new(paragraphs, Button::cancel_confirm_text(None, Some(button))),
|
Dialog::new(paragraphs, Button::cancel_confirm_text(None, Some(button))),
|
||||||
))?
|
))?
|
||||||
@ -1432,13 +1434,10 @@ extern "C" fn new_select_word_count(n_args: usize, args: *const Obj, kwargs: *mu
|
|||||||
"RECOVER WALLET"
|
"RECOVER WALLET"
|
||||||
};
|
};
|
||||||
|
|
||||||
let paragraphs = Paragraphs::new(
|
let paragraphs = Paragraphs::new(Paragraph::new(
|
||||||
Paragraph::new(
|
|
||||||
&theme::TEXT_DEMIBOLD,
|
&theme::TEXT_DEMIBOLD,
|
||||||
StrBuffer::from("Select number of words in your recovery seed."),
|
StrBuffer::from("Select the number of words in your backup."),
|
||||||
)
|
));
|
||||||
.centered(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let obj = LayoutObj::new(Frame::left_aligned(
|
let obj = LayoutObj::new(Frame::left_aligned(
|
||||||
theme::label_title(),
|
theme::label_title(),
|
||||||
|
@ -121,6 +121,10 @@ pub const fn label_keyboard() -> TextStyle {
|
|||||||
TextStyle::new(Font::DEMIBOLD, OFF_WHITE, BG, GREY_LIGHT, GREY_LIGHT)
|
TextStyle::new(Font::DEMIBOLD, OFF_WHITE, BG, GREY_LIGHT, GREY_LIGHT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const fn label_keyboard_prompt() -> TextStyle {
|
||||||
|
TextStyle::new(Font::DEMIBOLD, GREY_LIGHT, BG, GREY_LIGHT, GREY_LIGHT)
|
||||||
|
}
|
||||||
|
|
||||||
pub const fn label_keyboard_warning() -> TextStyle {
|
pub const fn label_keyboard_warning() -> TextStyle {
|
||||||
TextStyle::new(Font::DEMIBOLD, RED, BG, GREY_LIGHT, GREY_LIGHT)
|
TextStyle::new(Font::DEMIBOLD, RED, BG, GREY_LIGHT, GREY_LIGHT)
|
||||||
}
|
}
|
||||||
@ -380,7 +384,7 @@ pub const fn button_pin() -> ButtonStyleSheet {
|
|||||||
disabled: &ButtonStyle {
|
disabled: &ButtonStyle {
|
||||||
font: Font::MONO,
|
font: Font::MONO,
|
||||||
text_color: GREY_LIGHT,
|
text_color: GREY_LIGHT,
|
||||||
button_color: GREY_DARK,
|
button_color: BG, // so there is no "button" itself, just the text
|
||||||
background_color: BG,
|
background_color: BG,
|
||||||
border_color: BG,
|
border_color: BG,
|
||||||
border_radius: RADIUS,
|
border_radius: RADIUS,
|
||||||
@ -412,7 +416,7 @@ pub const fn button_pin_confirm() -> ButtonStyleSheet {
|
|||||||
disabled: &ButtonStyle {
|
disabled: &ButtonStyle {
|
||||||
font: Font::MONO,
|
font: Font::MONO,
|
||||||
text_color: GREY_LIGHT,
|
text_color: GREY_LIGHT,
|
||||||
button_color: GREEN,
|
button_color: GREY_DARK,
|
||||||
background_color: BG,
|
background_color: BG,
|
||||||
border_color: BG,
|
border_color: BG,
|
||||||
border_radius: RADIUS,
|
border_radius: RADIUS,
|
||||||
@ -426,7 +430,7 @@ pub const fn button_pin_autocomplete() -> ButtonStyleSheet {
|
|||||||
normal: &ButtonStyle {
|
normal: &ButtonStyle {
|
||||||
font: Font::MONO,
|
font: Font::MONO,
|
||||||
text_color: FG,
|
text_color: FG,
|
||||||
button_color: BG,
|
button_color: GREY_DARK, // same as PIN buttons
|
||||||
background_color: BG,
|
background_color: BG,
|
||||||
border_color: BG,
|
border_color: BG,
|
||||||
border_radius: RADIUS,
|
border_radius: RADIUS,
|
||||||
|
@ -42,6 +42,7 @@ async def recovery_process() -> Success:
|
|||||||
|
|
||||||
async def _continue_recovery_process() -> Success:
|
async def _continue_recovery_process() -> Success:
|
||||||
from trezor.errors import MnemonicError
|
from trezor.errors import MnemonicError
|
||||||
|
from trezor import utils
|
||||||
|
|
||||||
# gather the current recovery state from storage
|
# gather the current recovery state from storage
|
||||||
dry_run = storage_recovery.is_dry_run()
|
dry_run = storage_recovery.is_dry_run()
|
||||||
@ -63,6 +64,8 @@ async def _continue_recovery_process() -> Success:
|
|||||||
if is_first_step:
|
if is_first_step:
|
||||||
# If we are starting recovery, ask for word count first...
|
# If we are starting recovery, ask for word count first...
|
||||||
# _request_word_count
|
# _request_word_count
|
||||||
|
# For TT, just continuing straight to word count keyboard
|
||||||
|
if utils.MODEL == "R":
|
||||||
await layout.homescreen_dialog(
|
await layout.homescreen_dialog(
|
||||||
"Continue", "Select the number of words in your backup."
|
"Continue", "Select the number of words in your backup."
|
||||||
)
|
)
|
||||||
@ -153,7 +156,7 @@ async def _finish_recovery(secret: bytes, backup_type: BackupType) -> Success:
|
|||||||
|
|
||||||
storage_recovery.end_progress()
|
storage_recovery.end_progress()
|
||||||
|
|
||||||
await show_success("success_recovery", "Wallet recovered successfully.")
|
await show_success("success_recovery", "Wallet recovered successfully")
|
||||||
return Success(message="Device recovered")
|
return Success(message="Device recovered")
|
||||||
|
|
||||||
|
|
||||||
|
@ -399,15 +399,6 @@ async def confirm_reset_device(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if recovery:
|
|
||||||
await confirm_action(
|
|
||||||
"recover_device",
|
|
||||||
title,
|
|
||||||
description="It is safe to eject your Trezor anytime and continue later.",
|
|
||||||
verb="CONTINUE",
|
|
||||||
br_code=ButtonRequestType.ProtectCall,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def prompt_backup() -> bool:
|
async def prompt_backup() -> bool:
|
||||||
br_type = "backup_device"
|
br_type = "backup_device"
|
||||||
|
@ -71,14 +71,17 @@ async def continue_recovery(
|
|||||||
# There is very limited space on the screen
|
# There is very limited space on the screen
|
||||||
# (and having middle button would mean shortening the right button text)
|
# (and having middle button would mean shortening the right button text)
|
||||||
|
|
||||||
description = text
|
# Never showing info for dry-run, user already saw it and it is disturbing
|
||||||
|
if dry_run:
|
||||||
|
show_info = False
|
||||||
|
|
||||||
if subtext:
|
if subtext:
|
||||||
description += f"\n\n{subtext}"
|
text += f"\n\n{subtext}"
|
||||||
|
|
||||||
homepage = RustLayout(
|
homepage = RustLayout(
|
||||||
trezorui2.confirm_recovery(
|
trezorui2.confirm_recovery(
|
||||||
title="",
|
title="",
|
||||||
description=description,
|
description=text,
|
||||||
button=button_label.upper(),
|
button=button_label.upper(),
|
||||||
info_button=False,
|
info_button=False,
|
||||||
dry_run=dry_run,
|
dry_run=dry_run,
|
||||||
|
@ -106,40 +106,28 @@ async def continue_recovery(
|
|||||||
) -> bool:
|
) -> bool:
|
||||||
from ..common import button_request
|
from ..common import button_request
|
||||||
|
|
||||||
title = text
|
if show_info:
|
||||||
if subtext:
|
# Show this just one-time
|
||||||
title += "\n"
|
description = "You'll only have to select the first 2-3 letters of each word."
|
||||||
title += subtext
|
|
||||||
|
|
||||||
description = "It is safe to eject Trezor\nand continue later"
|
|
||||||
|
|
||||||
if info_func is not None:
|
|
||||||
homepage = RustLayout(
|
|
||||||
trezorui2.confirm_recovery(
|
|
||||||
title=title,
|
|
||||||
description=description,
|
|
||||||
button=button_label.upper(),
|
|
||||||
info_button=True,
|
|
||||||
dry_run=dry_run,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
await button_request("recovery", ButtonRequestType.RecoveryHomepage)
|
|
||||||
return await _is_confirmed_info(homepage, info_func)
|
|
||||||
else:
|
else:
|
||||||
|
description = subtext or ""
|
||||||
|
|
||||||
homepage = RustLayout(
|
homepage = RustLayout(
|
||||||
trezorui2.confirm_recovery(
|
trezorui2.confirm_recovery(
|
||||||
title=text,
|
title=text,
|
||||||
description=description,
|
description=description,
|
||||||
button=button_label.upper(),
|
button=button_label.upper(),
|
||||||
info_button=False,
|
info_button=info_func is not None,
|
||||||
dry_run=dry_run,
|
dry_run=dry_run,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
result = await interact(
|
|
||||||
homepage,
|
await button_request("recovery", ButtonRequestType.RecoveryHomepage)
|
||||||
"recovery",
|
|
||||||
ButtonRequestType.RecoveryHomepage,
|
if info_func is not None:
|
||||||
)
|
return await _is_confirmed_info(homepage, info_func)
|
||||||
|
else:
|
||||||
|
result = await ctx_wait(homepage)
|
||||||
return result is CONFIRMED
|
return result is CONFIRMED
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user