From c3f7e29548d24ba19d1aa22cc2858cf902e75622 Mon Sep 17 00:00:00 2001 From: grdddj Date: Wed, 21 Jun 2023 12:00:15 +0200 Subject: [PATCH] chore(core): passphrase flow design changes [no changelog] --- core/embed/rust/librust_qstr.h | 1 + core/embed/rust/src/ui/model_tr/layout.rs | 15 +++++++++++++++ core/mocks/generated/trezorui2.pyi | 5 +++++ core/src/apps/management/apply_settings.py | 8 +++++--- core/src/trezor/ui/layouts/tr/__init__.py | 7 +------ core/src/trezor/ui/layouts/tt_v2/__init__.py | 2 +- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/core/embed/rust/librust_qstr.h b/core/embed/rust/librust_qstr.h index 735d05898..274f00123 100644 --- a/core/embed/rust/librust_qstr.h +++ b/core/embed/rust/librust_qstr.h @@ -108,6 +108,7 @@ static void _librust_qstrs(void) { MP_QSTR_show_info; MP_QSTR_show_lockscreen; MP_QSTR_show_mismatch; + MP_QSTR_show_passphrase; MP_QSTR_show_progress; MP_QSTR_show_progress_coinjoin; MP_QSTR_show_remaining_shares; diff --git a/core/embed/rust/src/ui/model_tr/layout.rs b/core/embed/rust/src/ui/model_tr/layout.rs index eb0c05f77..e5ccf3bbf 100644 --- a/core/embed/rust/src/ui/model_tr/layout.rs +++ b/core/embed/rust/src/ui/model_tr/layout.rs @@ -900,6 +900,17 @@ extern "C" fn new_show_info(n_args: usize, args: *const Obj, kwargs: *mut Map) - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } +extern "C" fn new_show_passphrase() -> Obj { + let block = move || { + let text: StrBuffer = "Please enter your passphrase.".into(); + let paragraph = Paragraph::new(&theme::TEXT_NORMAL, text).centered(); + let content = Paragraphs::new([paragraph]); + let obj = LayoutObj::new(content)?; + Ok(obj.into()) + }; + unsafe { util::try_or_raise(block) } +} + extern "C" fn new_show_mismatch() -> Obj { let block = move || { let get_page = move |page_index| { @@ -1457,6 +1468,10 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Info modal.""" Qstr::MP_QSTR_show_info => obj_fn_kw!(0, new_show_info).as_obj(), + /// def show_passphrase() -> object: + /// """Show passphrase on host dialog.""" + Qstr::MP_QSTR_show_passphrase => obj_fn_0!(new_show_passphrase).as_obj(), + /// def show_mismatch() -> object: /// """Warning modal, receiving address mismatch.""" Qstr::MP_QSTR_show_mismatch => obj_fn_0!(new_show_mismatch).as_obj(), diff --git a/core/mocks/generated/trezorui2.pyi b/core/mocks/generated/trezorui2.pyi index 1f67796f4..cffe55f0f 100644 --- a/core/mocks/generated/trezorui2.pyi +++ b/core/mocks/generated/trezorui2.pyi @@ -184,6 +184,11 @@ def show_info( """Info modal.""" +# rust/src/ui/model_tr/layout.rs +def show_passphrase() -> object: + """Show passphrase on host dialog.""" + + # rust/src/ui/model_tr/layout.rs def show_mismatch() -> object: """Warning modal, receiving address mismatch.""" diff --git a/core/src/apps/management/apply_settings.py b/core/src/apps/management/apply_settings.py index 9ffbff5a3..54673beae 100644 --- a/core/src/apps/management/apply_settings.py +++ b/core/src/apps/management/apply_settings.py @@ -183,13 +183,15 @@ async def _require_confirm_change_label(ctx: GenericContext, label: str) -> None async def _require_confirm_change_passphrase(ctx: GenericContext, use: bool) -> None: - template = "Do you want to {} passphrase protection?" - description = template.format("enable" if use else "disable") + on_or_off = "on" if use else "off" + description = f"Turn {on_or_off} passphrase protection?" + verb = f"Turn {on_or_off}" await confirm_action( ctx, "set_passphrase", - "Enable passphrase" if use else "Disable passphrase", + "Passphrase settings", description=description, + verb=verb, br_code=BRT_PROTECT_CALL, ) diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index aacb48471..35414172e 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -1157,12 +1157,7 @@ async def show_error_popup( def request_passphrase_on_host() -> None: - draw_simple( - trezorui2.show_info( - title="HIDDEN WALLET", - description="Please type your passphrase on the connected host.", - ) - ) + draw_simple(trezorui2.show_passphrase()) async def request_passphrase_on_device(ctx: GenericContext, max_len: int) -> str: diff --git a/core/src/trezor/ui/layouts/tt_v2/__init__.py b/core/src/trezor/ui/layouts/tt_v2/__init__.py index 4b8eedefc..ca8f7d83b 100644 --- a/core/src/trezor/ui/layouts/tt_v2/__init__.py +++ b/core/src/trezor/ui/layouts/tt_v2/__init__.py @@ -1197,7 +1197,7 @@ def request_passphrase_on_host() -> None: draw_simple( trezorui2.show_simple( title=None, - description="Please type your passphrase on the connected host.", + description="Please enter your passphrase.", ) )