1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 12:28:09 +00:00

feat(core): revise path warning on model T

This commit is contained in:
Martin Milata 2023-08-30 16:31:41 +02:00
parent c1492159f0
commit 7e9f127aec
5 changed files with 35 additions and 7 deletions

View File

@ -0,0 +1 @@
Changed design of the path warning screen (model T only).

View File

@ -134,6 +134,10 @@ where
self.with_text(&theme::TEXT_NORMAL_OFF_WHITE, description) self.with_text(&theme::TEXT_NORMAL_OFF_WHITE, description)
} }
pub fn with_value(self, value: T) -> Self {
self.with_text(&theme::TEXT_MONO, value)
}
pub fn new_shares(lines: [T; 4], controls: U) -> Self { pub fn new_shares(lines: [T; 4], controls: U) -> Self {
let [l0, l1, l2, l3] = lines; let [l0, l1, l2, l3] = lines;
Self { Self {

View File

@ -919,6 +919,7 @@ fn new_show_modal(
button_style: ButtonStyleSheet, button_style: ButtonStyleSheet,
) -> Result<Obj, Error> { ) -> Result<Obj, Error> {
let title: StrBuffer = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; let title: StrBuffer = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let value: StrBuffer = kwargs.get_or(Qstr::MP_QSTR_value, StrBuffer::empty())?;
let description: StrBuffer = kwargs.get_or(Qstr::MP_QSTR_description, StrBuffer::empty())?; let description: StrBuffer = kwargs.get_or(Qstr::MP_QSTR_description, StrBuffer::empty())?;
let button: StrBuffer = kwargs.get_or(Qstr::MP_QSTR_button, "CONTINUE".into())?; let button: StrBuffer = kwargs.get_or(Qstr::MP_QSTR_button, "CONTINUE".into())?;
let allow_cancel: bool = kwargs.get_or(Qstr::MP_QSTR_allow_cancel, true)?; let allow_cancel: bool = kwargs.get_or(Qstr::MP_QSTR_allow_cancel, true)?;
@ -928,7 +929,12 @@ fn new_show_modal(
let obj = if no_buttons && time_ms == 0 { let obj = if no_buttons && time_ms == 0 {
// No buttons and no timer, used when we only want to draw the dialog once and // No buttons and no timer, used when we only want to draw the dialog once and
// then throw away the layout object. // then throw away the layout object.
LayoutObj::new(IconDialog::new(icon, title, Empty).with_description(description))?.into() LayoutObj::new(
IconDialog::new(icon, title, Empty)
.with_value(value)
.with_description(description),
)?
.into()
} else if no_buttons && time_ms > 0 { } else if no_buttons && time_ms > 0 {
// Timeout, no buttons. // Timeout, no buttons.
LayoutObj::new( LayoutObj::new(
@ -937,6 +943,7 @@ fn new_show_modal(
title, title,
Timeout::new(time_ms).map(|_| Some(CancelConfirmMsg::Confirmed)), Timeout::new(time_ms).map(|_| Some(CancelConfirmMsg::Confirmed)),
) )
.with_value(value)
.with_description(description), .with_description(description),
)? )?
.into() .into()
@ -952,6 +959,7 @@ fn new_show_modal(
false, false,
), ),
) )
.with_value(value)
.with_description(description), .with_description(description),
)? )?
.into() .into()
@ -965,6 +973,7 @@ fn new_show_modal(
(matches!(msg, ButtonMsg::Clicked)).then(|| CancelConfirmMsg::Confirmed) (matches!(msg, ButtonMsg::Clicked)).then(|| CancelConfirmMsg::Confirmed)
})), })),
) )
.with_value(value)
.with_description(description), .with_description(description),
)? )?
.into() .into()
@ -1788,6 +1797,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// *, /// *,
/// title: str, /// title: str,
/// button: str = "CONTINUE", /// button: str = "CONTINUE",
/// value: str = "",
/// description: str = "", /// description: str = "",
/// allow_cancel: bool = False, /// allow_cancel: bool = False,
/// time_ms: int = 0, /// time_ms: int = 0,

View File

@ -623,6 +623,7 @@ def show_warning(
*, *,
title: str, title: str,
button: str = "CONTINUE", button: str = "CONTINUE",
value: str = "",
description: str = "", description: str = "",
allow_cancel: bool = False, allow_cancel: bool = False,
time_ms: int = 0, time_ms: int = 0,

View File

@ -365,13 +365,25 @@ async def confirm_path_warning(
path: str, path: str,
path_type: str | None = None, path_type: str | None = None,
) -> None: ) -> None:
title = "Unknown path" if not path_type else f"Unknown {path_type.lower()}" title = (
await show_warning( "Wrong derivation path for selected account."
if not path_type
else f"Unknown {path_type.lower()}."
)
await raise_if_not_confirmed(
interact(
RustLayout(
trezorui2.show_warning(
title=title,
value=path,
description="Continue anyway?",
button="CONTINUE",
)
),
"path_warning", "path_warning",
title,
path,
br_code=ButtonRequestType.UnknownDerivationPath, br_code=ButtonRequestType.UnknownDerivationPath,
) )
)
async def confirm_homescreen( async def confirm_homescreen(