diff --git a/core/embed/rust/src/ui/api/firmware_upy.rs b/core/embed/rust/src/ui/api/firmware_upy.rs index d0ac07ee57..b6fad29272 100644 --- a/core/embed/rust/src/ui/api/firmware_upy.rs +++ b/core/embed/rust/src/ui/api/firmware_upy.rs @@ -248,6 +248,17 @@ extern "C" fn new_show_lockscreen(n_args: usize, args: *const Obj, kwargs: *mut unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } +extern "C" fn new_show_wait_text(message: Obj) -> Obj { + let block = || { + let message: TString<'static> = message.try_into()?; + + let layout = ModelUI::show_wait_text(message)?; + Ok(LayoutObj::new_root(layout)?.into()) + }; + + unsafe { util::try_or_raise(block) } +} + pub extern "C" fn upy_check_homescreen_format(data: Obj) -> Obj { let block = || { let buffer = data.try_into()?; @@ -486,6 +497,10 @@ pub static mp_module_trezorui_api: Module = obj_module! { /// """Homescreen for locked device.""" Qstr::MP_QSTR_show_lockscreen => obj_fn_kw!(0, new_show_lockscreen).as_obj(), + /// def show_wait_text(message: str, /) -> LayoutObj[None]: + /// """Show single-line text in the middle of the screen.""" + Qstr::MP_QSTR_show_wait_text => obj_fn_1!(new_show_wait_text).as_obj(), + /// class BacklightLevels: /// """Backlight levels. Values dynamically update based on user settings.""" /// MAX: ClassVar[int] diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index d3e2de7c7f..b9fbea3753 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -1208,15 +1208,6 @@ extern "C" fn new_show_progress_coinjoin(n_args: usize, args: *const Obj, kwargs unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } -extern "C" fn new_show_wait_text(message: Obj) -> Obj { - let block = || { - let message: TString<'static> = message.try_into()?; - Ok(LayoutObj::new(Connect::new(message, theme::FG, theme::BG))?.into()) - }; - - unsafe { util::try_or_raise(block) } -} - extern "C" fn new_confirm_fido(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { #[cfg(feature = "universal_fw")] return flow::confirm_fido::new_confirm_fido(n_args, args, kwargs); @@ -1547,10 +1538,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Show user how to interact with the device.""" Qstr::MP_QSTR_tutorial => obj_fn_0!(new_show_tutorial).as_obj(), - /// def show_wait_text(message: str, /) -> LayoutObj[None]: - /// """Show single-line text in the middle of the screen.""" - Qstr::MP_QSTR_show_wait_text => obj_fn_1!(new_show_wait_text).as_obj(), - /// def flow_get_address( /// *, /// address: str | bytes, diff --git a/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs b/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs index 453b14ccd5..5426c077a5 100644 --- a/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs @@ -6,6 +6,7 @@ use crate::{ translations::TR, ui::{ component::{ + connect::Connect, swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs}, CachedJpeg, @@ -220,4 +221,9 @@ impl UIFeaturesFirmware for ModelMercuryFeatures { let layout = RootComponent::new(Lockscreen::new(label, bootscreen, coinjoin_authorized)); Ok(layout) } + + fn show_wait_text(text: TString<'static>) -> Result { + let layout = RootComponent::new(Connect::new(text, theme::FG, theme::BG)); + Ok(layout) + } } diff --git a/core/embed/rust/src/ui/model_tr/layout.rs b/core/embed/rust/src/ui/model_tr/layout.rs index 1ae4070c1b..b21db3def9 100644 --- a/core/embed/rust/src/ui/model_tr/layout.rs +++ b/core/embed/rust/src/ui/model_tr/layout.rs @@ -1371,16 +1371,6 @@ extern "C" fn new_show_progress_coinjoin(n_args: usize, args: *const Obj, kwargs unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } -extern "C" fn new_show_wait_text(message: Obj) -> Obj { - let block = || { - let message: TString<'static> = message.try_into()?; - let obj = LayoutObj::new(Connect::new(message, theme::FG, theme::BG))?; - Ok(obj.into()) - }; - - unsafe { util::try_or_raise(block) } -} - #[no_mangle] pub static mp_module_trezorui2: Module = obj_module! { /// from trezor import utils @@ -1679,8 +1669,4 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Show progress loader for coinjoin. Returns CANCELLED after a specified time when /// time_ms timeout is passed.""" Qstr::MP_QSTR_show_progress_coinjoin => obj_fn_kw!(0, new_show_progress_coinjoin).as_obj(), - - /// def show_wait_text(message: str, /) -> None: - /// """Show single-line text in the middle of the screen.""" - Qstr::MP_QSTR_show_wait_text => obj_fn_1!(new_show_wait_text).as_obj(), }; diff --git a/core/embed/rust/src/ui/model_tr/ui_features_fw.rs b/core/embed/rust/src/ui/model_tr/ui_features_fw.rs index b34008af5a..d7ab68fdbe 100644 --- a/core/embed/rust/src/ui/model_tr/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_tr/ui_features_fw.rs @@ -7,8 +7,7 @@ use crate::{ translations::TR, ui::{ component::{ - text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt}, - Component, ComponentExt, Label, LineBreaking, Paginate, Timeout, + connect::Connect, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt}, Component, ComponentExt, Label, LineBreaking, Paginate, Timeout }, layout::{ obj::{LayoutMaybeTrace, LayoutObj, RootComponent}, @@ -245,6 +244,11 @@ impl UIFeaturesFirmware for ModelTRFeatures { let layout = RootComponent::new(Lockscreen::new(label, bootscreen, coinjoin_authorized)); Ok(layout) } + + fn show_wait_text(text: TString<'static>) -> Result { + let layout = RootComponent::new(Connect::new(text, theme::FG, theme::BG)); + Ok(layout) + } } /// Function to create and call a `ButtonPage` dialog based on paginable content diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index 45865f11fb..3ff2a18824 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -1349,16 +1349,6 @@ extern "C" fn new_show_progress_coinjoin(n_args: usize, args: *const Obj, kwargs unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } -extern "C" fn new_show_wait_text(message: Obj) -> Obj { - let block = || { - let message: TString<'static> = message.try_into()?; - let obj = LayoutObj::new(Connect::new(message, theme::FG, theme::BG))?; - Ok(obj.into()) - }; - - unsafe { util::try_or_raise(block) } -} - #[no_mangle] pub static mp_module_trezorui2: Module = obj_module! { /// from trezor import utils @@ -1663,10 +1653,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Show progress loader for coinjoin. Returns CANCELLED after a specified time when /// time_ms timeout is passed.""" Qstr::MP_QSTR_show_progress_coinjoin => obj_fn_kw!(0, new_show_progress_coinjoin).as_obj(), - - /// def show_wait_text(message: str, /) -> LayoutObj[None]: - /// """Show single-line text in the middle of the screen.""" - Qstr::MP_QSTR_show_wait_text => obj_fn_1!(new_show_wait_text).as_obj(), }; #[cfg(test)] diff --git a/core/embed/rust/src/ui/model_tt/ui_features_fw.rs b/core/embed/rust/src/ui/model_tt/ui_features_fw.rs index 0dccc576a9..76b710a81c 100644 --- a/core/embed/rust/src/ui/model_tt/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_tt/ui_features_fw.rs @@ -6,6 +6,7 @@ use crate::{ translations::TR, ui::{ component::{ + connect::Connect, image::BlendedImage, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt}, ComponentExt, Empty, Jpeg, Label, Timeout, @@ -271,6 +272,11 @@ impl UIFeaturesFirmware for ModelTTFeatures { let layout = RootComponent::new(Lockscreen::new(label, bootscreen, coinjoin_authorized)); Ok(layout) } + + fn show_wait_text(text: TString<'static>) -> Result { + let layout = RootComponent::new(Connect::new(text, theme::FG, theme::BG)); + Ok(layout) + } } fn new_show_modal( diff --git a/core/embed/rust/src/ui/ui_features_fw.rs b/core/embed/rust/src/ui/ui_features_fw.rs index 9a8d4f6d5a..1342ca7816 100644 --- a/core/embed/rust/src/ui/ui_features_fw.rs +++ b/core/embed/rust/src/ui/ui_features_fw.rs @@ -85,4 +85,6 @@ pub trait UIFeaturesFirmware { bootscreen: bool, coinjoin_authorized: bool, ) -> Result; + + fn show_wait_text(text: TString<'static>) -> Result; } diff --git a/core/mocks/generated/trezorui2.pyi b/core/mocks/generated/trezorui2.pyi index 34f10ef34d..48931007e5 100644 --- a/core/mocks/generated/trezorui2.pyi +++ b/core/mocks/generated/trezorui2.pyi @@ -329,11 +329,6 @@ def tutorial() -> LayoutObj[UiResult]: """Show user how to interact with the device.""" -# rust/src/ui/model_mercury/layout.rs -def show_wait_text(message: str, /) -> LayoutObj[None]: - """Show single-line text in the middle of the screen.""" - - # rust/src/ui/model_mercury/layout.rs def flow_get_address( *, @@ -1058,8 +1053,3 @@ def show_progress_coinjoin( ) -> LayoutObj[UiResult]: """Show progress loader for coinjoin. Returns CANCELLED after a specified time when time_ms timeout is passed.""" - - -# rust/src/ui/model_tt/layout.rs -def show_wait_text(message: str, /) -> LayoutObj[None]: - """Show single-line text in the middle of the screen.""" diff --git a/core/mocks/generated/trezorui_api.pyi b/core/mocks/generated/trezorui_api.pyi index 8fa9ec0f79..727a924f8b 100644 --- a/core/mocks/generated/trezorui_api.pyi +++ b/core/mocks/generated/trezorui_api.pyi @@ -216,6 +216,11 @@ def show_lockscreen( """Homescreen for locked device.""" +# rust/src/ui/api/firmware_upy.rs +def show_wait_text(message: str, /) -> LayoutObj[None]: + """Show single-line text in the middle of the screen.""" + + # rust/src/ui/api/firmware_upy.rs class BacklightLevels: """Backlight levels. Values dynamically update based on user settings.""" diff --git a/core/src/trezor/ui/layouts/mercury/__init__.py b/core/src/trezor/ui/layouts/mercury/__init__.py index abd1985d1d..d87633da72 100644 --- a/core/src/trezor/ui/layouts/mercury/__init__.py +++ b/core/src/trezor/ui/layouts/mercury/__init__.py @@ -1090,7 +1090,7 @@ def request_passphrase_on_host() -> None: def show_wait_text(message: str) -> None: - draw_simple(trezorui2.show_wait_text(message)) + draw_simple(trezorui_api.show_wait_text(message)) def request_passphrase_on_device(max_len: int) -> Awaitable[str]: diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index e34ad068c8..e305ec0444 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -1148,7 +1148,7 @@ def request_passphrase_on_host() -> None: def show_wait_text(message: str) -> None: - draw_simple(trezorui2.show_wait_text(message)) + draw_simple(trezorui_api.show_wait_text(message)) async def request_passphrase_on_device(max_len: int) -> str: diff --git a/core/src/trezor/ui/layouts/tt/__init__.py b/core/src/trezor/ui/layouts/tt/__init__.py index 3d9aba3e49..4c83561ded 100644 --- a/core/src/trezor/ui/layouts/tt/__init__.py +++ b/core/src/trezor/ui/layouts/tt/__init__.py @@ -1149,7 +1149,7 @@ def request_passphrase_on_host() -> None: def show_wait_text(message: str) -> None: - draw_simple(trezorui2.show_wait_text(message)) + draw_simple(trezorui_api.show_wait_text(message)) async def request_passphrase_on_device(max_len: int) -> str: