diff --git a/core/embed/rust/src/ui/api/firmware_upy.rs b/core/embed/rust/src/ui/api/firmware_upy.rs index b6fad29272..b4ce2b9ae0 100644 --- a/core/embed/rust/src/ui/api/firmware_upy.rs +++ b/core/embed/rust/src/ui/api/firmware_upy.rs @@ -248,6 +248,34 @@ 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_progress(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { + let block = move |_args: &[Obj], kwargs: &Map| { + let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; + let indeterminate: bool = kwargs.get_or(Qstr::MP_QSTR_indeterminate, false)?; + let title: Option = kwargs + .get(Qstr::MP_QSTR_title) + .and_then(Obj::try_into_option) + .unwrap_or(None); + + let layout = ModelUI::show_progress(description, indeterminate, title)?; + Ok(LayoutObj::new_root(layout)?.into()) + }; + unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } +} + +extern "C" fn new_show_progress_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { + let block = move |_args: &[Obj], kwargs: &Map| { + let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; + let indeterminate: bool = kwargs.get_or(Qstr::MP_QSTR_indeterminate, false)?; + let time_ms: u32 = kwargs.get_or(Qstr::MP_QSTR_time_ms, 0)?; + let skip_first_paint: bool = kwargs.get_or(Qstr::MP_QSTR_skip_first_paint, false)?; + + let obj = ModelUI::show_progress_coinjoin(title, indeterminate, time_ms, skip_first_paint)?; + Ok(obj.into()) + }; + 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()?; @@ -497,6 +525,28 @@ 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_progress( + /// *, + /// description: str, + /// indeterminate: bool = False, + /// title: str | None = None, + /// ) -> LayoutObj[UiResult]: + /// """Show progress loader. Please note that the number of lines reserved on screen for + /// description is determined at construction time. If you want multiline descriptions + /// make sure the initial description has at least that amount of lines.""" + Qstr::MP_QSTR_show_progress => obj_fn_kw!(0, new_show_progress).as_obj(), + + /// def show_progress_coinjoin( + /// *, + /// title: str, + /// indeterminate: bool = False, + /// time_ms: int = 0, + /// skip_first_paint: bool = False, + /// ) -> LayoutObj[UiResult]: + /// """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(), diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index b9fbea3753..a8660167e3 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -1164,50 +1164,6 @@ extern "C" fn new_show_group_share_success( unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } -extern "C" fn new_show_progress(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; - let indeterminate: bool = kwargs.get_or(Qstr::MP_QSTR_indeterminate, false)?; - let title: Option = kwargs - .get(Qstr::MP_QSTR_title) - .and_then(Obj::try_into_option) - .unwrap_or(None); - - let (title, description) = if let Some(title) = title { - (title, description) - } else { - (description, "".into()) - }; - - Ok(LayoutObj::new(Progress::new(title, indeterminate, description))?.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - -extern "C" fn new_show_progress_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; - let indeterminate: bool = kwargs.get_or(Qstr::MP_QSTR_indeterminate, false)?; - let time_ms: u32 = kwargs.get_or(Qstr::MP_QSTR_time_ms, 0)?; - let skip_first_paint: bool = kwargs.get_or(Qstr::MP_QSTR_skip_first_paint, false)?; - - // The second type parameter is actually not used in `new()` but we need to - // provide it. - let progress = CoinJoinProgress::::new(title, indeterminate)?; - let obj = if time_ms > 0 && indeterminate { - let timeout = Timeout::new(time_ms); - LayoutObj::new((timeout, progress.map(|_msg| None)))? - } else { - LayoutObj::new(progress)? - }; - if skip_first_paint { - obj.skip_first_paint(); - } - Ok(obj.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, 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); @@ -1512,28 +1468,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Shown after successfully finishing a group.""" Qstr::MP_QSTR_show_group_share_success => obj_fn_kw!(0, new_show_group_share_success).as_obj(), - /// def show_progress( - /// *, - /// title: str, - /// indeterminate: bool = False, - /// description: str = "", - /// ) -> LayoutObj[UiResult]: - /// """Show progress loader. Please note that the number of lines reserved on screen for - /// description is determined at construction time. If you want multiline descriptions - /// make sure the initial description has at least that amount of lines.""" - Qstr::MP_QSTR_show_progress => obj_fn_kw!(0, new_show_progress).as_obj(), - - /// def show_progress_coinjoin( - /// *, - /// title: str, - /// indeterminate: bool = False, - /// time_ms: int = 0, - /// skip_first_paint: bool = False, - /// ) -> LayoutObj[UiResult]: - /// """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 tutorial() -> LayoutObj[UiResult]: /// """Show user how to interact with the device.""" Qstr::MP_QSTR_tutorial => obj_fn_0!(new_show_tutorial).as_obj(), 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 5426c077a5..30e3714777 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,10 +6,7 @@ use crate::{ translations::TR, ui::{ component::{ - connect::Connect, - swipe_detect::SwipeSettings, - text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs}, - CachedJpeg, + connect::Connect, swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs}, CachedJpeg, ComponentExt, Never, Timeout }, geometry::Direction, layout::{ @@ -22,8 +19,9 @@ use crate::{ use super::{ component::{ - check_homescreen_format, Bip39Input, Frame, Homescreen, Lockscreen, MnemonicKeyboard, - PinKeyboard, SelectWordCount, Slip39Input, SwipeContent, SwipeUpScreen, VerticalMenu, + check_homescreen_format, Bip39Input, CoinJoinProgress, Frame, Homescreen, Lockscreen, + MnemonicKeyboard, PinKeyboard, Progress, SelectWordCount, Slip39Input, SwipeContent, + SwipeUpScreen, VerticalMenu, }, flow::{self, new_confirm_action_simple, ConfirmActionMenu, ConfirmActionStrings}, theme, ModelMercuryFeatures, @@ -222,6 +220,40 @@ impl UIFeaturesFirmware for ModelMercuryFeatures { Ok(layout) } + fn show_progress( + description: TString<'static>, + indeterminate: bool, + title: Option>, + ) -> Result { + let (title, description) = if let Some(title) = title { + (title, description) + } else { + (description, "".into()) + }; + + let layout = RootComponent::new(Progress::new(title, indeterminate, description)); + Ok(layout) + } + + fn show_progress_coinjoin( + title: TString<'static>, + indeterminate: bool, + time_ms: u32, + skip_first_paint: bool, + ) -> Result, Error> { + let progress = CoinJoinProgress::::new(title, indeterminate)?; + let obj = if time_ms > 0 && indeterminate { + let timeout = Timeout::new(time_ms); + LayoutObj::new((timeout, progress.map(|_msg| None)))? + } else { + LayoutObj::new(progress)? + }; + if skip_first_paint { + obj.skip_first_paint(); + } + Ok(obj) + } + 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 b21db3def9..e05efc84b8 100644 --- a/core/embed/rust/src/ui/model_tr/layout.rs +++ b/core/embed/rust/src/ui/model_tr/layout.rs @@ -1327,50 +1327,6 @@ extern "C" fn new_show_group_share_success( unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } -extern "C" fn new_show_progress(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; - let indeterminate: bool = kwargs.get_or(Qstr::MP_QSTR_indeterminate, false)?; - let title: Option = kwargs - .get(Qstr::MP_QSTR_title) - .and_then(Obj::try_into_option) - .unwrap_or(None); - - let mut progress = Progress::new(indeterminate, description); - if let Some(title) = title { - progress = progress.with_title(title); - }; - - let obj = LayoutObj::new(progress)?; - Ok(obj.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - -extern "C" fn new_show_progress_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; - let indeterminate: bool = kwargs.get_or(Qstr::MP_QSTR_indeterminate, false)?; - let time_ms: u32 = kwargs.get_or(Qstr::MP_QSTR_time_ms, 0)?; - let skip_first_paint: bool = kwargs.get_or(Qstr::MP_QSTR_skip_first_paint, false)?; - - // The second type parameter is actually not used in `new()` but we need to - // provide it. - let progress = CoinJoinProgress::new(title, indeterminate); - let obj = if time_ms > 0 && indeterminate { - let timeout = Timeout::new(time_ms); - LayoutObj::new((timeout, progress.map(|_msg| None)))? - } else { - LayoutObj::new(progress)? - }; - if skip_first_paint { - obj.skip_first_paint(); - } - Ok(obj.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - #[no_mangle] pub static mp_module_trezorui2: Module = obj_module! { /// from trezor import utils @@ -1647,26 +1603,4 @@ pub static mp_module_trezorui2: Module = obj_module! { /// ) -> LayoutObj[int]: /// """Shown after successfully finishing a group.""" Qstr::MP_QSTR_show_group_share_success => obj_fn_kw!(0, new_show_group_share_success).as_obj(), - - /// def show_progress( - /// *, - /// description: str, - /// indeterminate: bool = False, - /// title: str | None = None, - /// ) -> LayoutObj[UiResult]: - /// """Show progress loader. Please note that the number of lines reserved on screen for - /// description is determined at construction time. If you want multiline descriptions - /// make sure the initial description has at least that amount of lines.""" - Qstr::MP_QSTR_show_progress => obj_fn_kw!(0, new_show_progress).as_obj(), - - /// def show_progress_coinjoin( - /// *, - /// title: str, - /// indeterminate: bool = False, - /// time_ms: int = 0, - /// skip_first_paint: bool = False, - /// ) -> LayoutObj[UiResult]: - /// """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(), }; 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 d7ab68fdbe..39eca14f99 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,7 +7,9 @@ use crate::{ translations::TR, ui::{ component::{ - connect::Connect, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt}, Component, ComponentExt, Label, LineBreaking, Paginate, Timeout + connect::Connect, + text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt}, + Component, ComponentExt, Empty, Label, LineBreaking, Paginate, Timeout, }, layout::{ obj::{LayoutMaybeTrace, LayoutObj, RootComponent}, @@ -19,8 +21,9 @@ use crate::{ use super::{ component::{ - ButtonDetails, ButtonPage, ConfirmHomescreen, Frame, Homescreen, Lockscreen, - PassphraseEntry, PinEntry, ScrollableFrame, SimpleChoice, WordlistEntry, WordlistType, + ButtonDetails, ButtonPage, CoinJoinProgress, ConfirmHomescreen, Frame, Homescreen, + Lockscreen, PassphraseEntry, PinEntry, Progress, ScrollableFrame, SimpleChoice, + WordlistEntry, WordlistType, }, theme, ModelTRFeatures, }; @@ -245,6 +248,39 @@ impl UIFeaturesFirmware for ModelTRFeatures { Ok(layout) } + fn show_progress( + description: TString<'static>, + indeterminate: bool, + title: Option>, + ) -> Result { + let mut progress = Progress::new(indeterminate, description); + if let Some(title) = title { + progress = progress.with_title(title); + }; + + let layout = RootComponent::new(progress); + Ok(layout) + } + + fn show_progress_coinjoin( + title: TString<'static>, + indeterminate: bool, + time_ms: u32, + skip_first_paint: bool, + ) -> Result, Error> { + let progress = CoinJoinProgress::new(title, indeterminate); + let obj = if time_ms > 0 && indeterminate { + let timeout = Timeout::new(time_ms); + LayoutObj::new((timeout, progress.map(|_msg| None)))? + } else { + LayoutObj::new(progress)? + }; + if skip_first_paint { + obj.skip_first_paint(); + } + Ok(obj) + } + 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_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index 3ff2a18824..076e0069b6 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -1304,51 +1304,6 @@ extern "C" fn new_show_remaining_shares(n_args: usize, args: *const Obj, kwargs: unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } -extern "C" fn new_show_progress(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; - let indeterminate: bool = kwargs.get_or(Qstr::MP_QSTR_indeterminate, false)?; - let title: Option = kwargs - .get(Qstr::MP_QSTR_title) - .and_then(Obj::try_into_option) - .unwrap_or(None); - - let (title, description) = if let Some(title) = title { - (title, description) - } else { - (description, "".into()) - }; - - let obj = LayoutObj::new(Progress::new(title, indeterminate, description))?; - Ok(obj.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - -extern "C" fn new_show_progress_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; - let indeterminate: bool = kwargs.get_or(Qstr::MP_QSTR_indeterminate, false)?; - let time_ms: u32 = kwargs.get_or(Qstr::MP_QSTR_time_ms, 0)?; - let skip_first_paint: bool = kwargs.get_or(Qstr::MP_QSTR_skip_first_paint, false)?; - - // The second type parameter is actually not used in `new()` but we need to - // provide it. - let progress = CoinJoinProgress::::new(title, indeterminate)?; - let obj = if time_ms > 0 && indeterminate { - let timeout = Timeout::new(time_ms); - LayoutObj::new((timeout, progress.map(|_msg| None)))? - } else { - LayoutObj::new(progress)? - }; - if skip_first_paint { - obj.skip_first_paint(); - } - Ok(obj.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - #[no_mangle] pub static mp_module_trezorui2: Module = obj_module! { /// from trezor import utils @@ -1631,28 +1586,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// ) -> LayoutObj[UiResult]: /// """Shows SLIP39 state after info button is pressed on `confirm_recovery`.""" Qstr::MP_QSTR_show_remaining_shares => obj_fn_kw!(0, new_show_remaining_shares).as_obj(), - - /// def show_progress( - /// *, - /// description: str, - /// indeterminate: bool = False, - /// title: str | None = None, - /// ) -> LayoutObj[UiResult]: - /// """Show progress loader. Please note that the number of lines reserved on screen for - /// description is determined at construction time. If you want multiline descriptions - /// make sure the initial description has at least that amount of lines.""" - Qstr::MP_QSTR_show_progress => obj_fn_kw!(0, new_show_progress).as_obj(), - - /// def show_progress_coinjoin( - /// *, - /// title: str, - /// indeterminate: bool = False, - /// time_ms: int = 0, - /// skip_first_paint: bool = False, - /// ) -> LayoutObj[UiResult]: - /// """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(), }; #[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 76b710a81c..4c27b17b9f 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,10 +6,7 @@ use crate::{ translations::TR, ui::{ component::{ - connect::Connect, - image::BlendedImage, - text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt}, - ComponentExt, Empty, Jpeg, Label, Timeout, + connect::Connect, image::BlendedImage, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt}, ComponentExt, Empty, Jpeg, Label, Never, Timeout }, layout::{ obj::{LayoutMaybeTrace, LayoutObj, RootComponent}, @@ -21,9 +18,7 @@ use crate::{ use super::{ component::{ - check_homescreen_format, Bip39Input, Button, ButtonMsg, ButtonPage, ButtonStyleSheet, - CancelConfirmMsg, Dialog, Frame, Homescreen, IconDialog, Lockscreen, MnemonicKeyboard, - PassphraseKeyboard, PinKeyboard, SelectWordCount, SetBrightnessDialog, Slip39Input, + check_homescreen_format, Bip39Input, Button, ButtonMsg, ButtonPage, ButtonStyleSheet, CancelConfirmMsg, CoinJoinProgress, Dialog, Frame, Homescreen, IconDialog, Lockscreen, MnemonicKeyboard, PassphraseKeyboard, PinKeyboard, Progress, SelectWordCount, SetBrightnessDialog, Slip39Input }, theme, ModelTTFeatures, }; @@ -273,6 +268,40 @@ impl UIFeaturesFirmware for ModelTTFeatures { Ok(layout) } + fn show_progress( + description: TString<'static>, + indeterminate: bool, + title: Option>, + ) -> Result { + let (title, description) = if let Some(title) = title { + (title, description) + } else { + (description, "".into()) + }; + + let layout = RootComponent::new(Progress::new(title, indeterminate, description)); + Ok(layout) + } + + fn show_progress_coinjoin( + title: TString<'static>, + indeterminate: bool, + time_ms: u32, + skip_first_paint: bool, + ) -> Result, Error> { + let progress = CoinJoinProgress::::new(title, indeterminate)?; + let obj = if time_ms > 0 && indeterminate { + let timeout = Timeout::new(time_ms); + LayoutObj::new((timeout, progress.map(|_msg| None)))? + } else { + LayoutObj::new(progress)? + }; + if skip_first_paint { + obj.skip_first_paint(); + } + Ok(obj) + } + 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/ui_features_fw.rs b/core/embed/rust/src/ui/ui_features_fw.rs index 1342ca7816..9cc8f4ac1d 100644 --- a/core/embed/rust/src/ui/ui_features_fw.rs +++ b/core/embed/rust/src/ui/ui_features_fw.rs @@ -86,5 +86,18 @@ pub trait UIFeaturesFirmware { coinjoin_authorized: bool, ) -> Result; + fn show_progress( + description: TString<'static>, + indeterminate: bool, + title: Option>, + ) -> Result; + + fn show_progress_coinjoin( + title: TString<'static>, + indeterminate: bool, + time_ms: u32, + skip_first_paint: bool, + ) -> Result, Error>; // TODO: return LayoutMaybeTrace + fn show_wait_text(text: TString<'static>) -> Result; } diff --git a/core/mocks/generated/trezorui2.pyi b/core/mocks/generated/trezorui2.pyi index 48931007e5..0fa4578188 100644 --- a/core/mocks/generated/trezorui2.pyi +++ b/core/mocks/generated/trezorui2.pyi @@ -300,30 +300,6 @@ def show_group_share_success( """Shown after successfully finishing a group.""" -# rust/src/ui/model_mercury/layout.rs -def show_progress( - *, - title: str, - indeterminate: bool = False, - description: str = "", -) -> LayoutObj[UiResult]: - """Show progress loader. Please note that the number of lines reserved on screen for - description is determined at construction time. If you want multiline descriptions - make sure the initial description has at least that amount of lines.""" - - -# rust/src/ui/model_mercury/layout.rs -def show_progress_coinjoin( - *, - title: str, - indeterminate: bool = False, - time_ms: int = 0, - skip_first_paint: bool = False, -) -> LayoutObj[UiResult]: - """Show progress loader for coinjoin. Returns CANCELLED after a specified time when - time_ms timeout is passed.""" - - # rust/src/ui/model_mercury/layout.rs def tutorial() -> LayoutObj[UiResult]: """Show user how to interact with the device.""" @@ -1029,27 +1005,3 @@ def show_remaining_shares( pages: Iterable[tuple[str, str]], ) -> LayoutObj[UiResult]: """Shows SLIP39 state after info button is pressed on `confirm_recovery`.""" - - -# rust/src/ui/model_tt/layout.rs -def show_progress( - *, - description: str, - indeterminate: bool = False, - title: str | None = None, -) -> LayoutObj[UiResult]: - """Show progress loader. Please note that the number of lines reserved on screen for - description is determined at construction time. If you want multiline descriptions - make sure the initial description has at least that amount of lines.""" - - -# rust/src/ui/model_tt/layout.rs -def show_progress_coinjoin( - *, - title: str, - indeterminate: bool = False, - time_ms: int = 0, - skip_first_paint: bool = False, -) -> LayoutObj[UiResult]: - """Show progress loader for coinjoin. Returns CANCELLED after a specified time when - time_ms timeout is passed.""" diff --git a/core/mocks/generated/trezorui_api.pyi b/core/mocks/generated/trezorui_api.pyi index 727a924f8b..8c3308c7e7 100644 --- a/core/mocks/generated/trezorui_api.pyi +++ b/core/mocks/generated/trezorui_api.pyi @@ -216,6 +216,30 @@ def show_lockscreen( """Homescreen for locked device.""" +# rust/src/ui/api/firmware_upy.rs +def show_progress( + *, + description: str, + indeterminate: bool = False, + title: str | None = None, +) -> LayoutObj[UiResult]: + """Show progress loader. Please note that the number of lines reserved on screen for + description is determined at construction time. If you want multiline descriptions + make sure the initial description has at least that amount of lines.""" + + +# rust/src/ui/api/firmware_upy.rs +def show_progress_coinjoin( + *, + title: str, + indeterminate: bool = False, + time_ms: int = 0, + skip_first_paint: bool = False, +) -> LayoutObj[UiResult]: + """Show progress loader for coinjoin. Returns CANCELLED after a specified time when + time_ms timeout is passed.""" + + # 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.""" diff --git a/core/src/trezor/ui/layouts/homescreen.py b/core/src/trezor/ui/layouts/homescreen.py index b0b61800a5..203a29b387 100644 --- a/core/src/trezor/ui/layouts/homescreen.py +++ b/core/src/trezor/ui/layouts/homescreen.py @@ -1,7 +1,6 @@ from typing import TYPE_CHECKING import storage.cache as storage_cache -import trezorui2 import trezorui_api from trezor import TR, ui @@ -114,7 +113,7 @@ class Busyscreen(HomescreenBase): def __init__(self, delay_ms: int) -> None: skip = storage_cache.homescreen_shown is self.RENDER_INDICATOR super().__init__( - layout=trezorui2.show_progress_coinjoin( + layout=trezorui_api.show_progress_coinjoin( title=TR.coinjoin__waiting_for_others, indeterminate=True, time_ms=delay_ms, diff --git a/core/src/trezor/ui/layouts/progress.py b/core/src/trezor/ui/layouts/progress.py index fae4c73a9f..da67b4f9a0 100644 --- a/core/src/trezor/ui/layouts/progress.py +++ b/core/src/trezor/ui/layouts/progress.py @@ -1,4 +1,4 @@ -import trezorui2 +import trezorui_api from trezor import TR, config, ui, utils @@ -30,7 +30,7 @@ def progress( description = TR.progress__please_wait # def_arg return ui.ProgressLayout( - layout=trezorui2.show_progress( + layout=trezorui_api.show_progress( description=description, title=title, indeterminate=indeterminate, @@ -44,7 +44,7 @@ def bitcoin_progress(message: str) -> ui.ProgressLayout: def coinjoin_progress(message: str) -> ui.ProgressLayout: return ui.ProgressLayout( - layout=trezorui2.show_progress_coinjoin(title=message, indeterminate=False) + layout=trezorui_api.show_progress_coinjoin(title=message, indeterminate=False) )