From 10449759bf5302ff4281bb6649e77a637a666e25 Mon Sep 17 00:00:00 2001 From: grdddj Date: Wed, 21 Jun 2023 12:00:15 +0200 Subject: [PATCH] chore(core): new designs of passphrase dialogs [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 b8bfd738f0..cbe5dc7e40 100644 --- a/core/embed/rust/librust_qstr.h +++ b/core/embed/rust/librust_qstr.h @@ -111,6 +111,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 646c1c8c98..7043e9c806 100644 --- a/core/embed/rust/src/ui/model_tr/layout.rs +++ b/core/embed/rust/src/ui/model_tr/layout.rs @@ -904,6 +904,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| { @@ -1464,6 +1475,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 1f67796f49..cffe55f0f5 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 c37c1004da..abb3c466f1 100644 --- a/core/src/apps/management/apply_settings.py +++ b/core/src/apps/management/apply_settings.py @@ -175,12 +175,14 @@ async def _require_confirm_change_label(label: str) -> None: async def _require_confirm_change_passphrase(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( "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 68a4ecef02..ec2ec96c28 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -1089,12 +1089,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(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 0c38ef9965..3f82c1a92e 100644 --- a/core/src/trezor/ui/layouts/tt_v2/__init__.py +++ b/core/src/trezor/ui/layouts/tt_v2/__init__.py @@ -1131,7 +1131,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.", ) )