mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 01:18:28 +00:00
refactor(core): move show_wait_text to UiFeatures
This commit is contained in:
parent
e82988665c
commit
160e6be4b9
@ -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]
|
||||
|
@ -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,
|
||||
|
@ -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<impl LayoutMaybeTrace, Error> {
|
||||
let layout = RootComponent::new(Connect::new(text, theme::FG, theme::BG));
|
||||
Ok(layout)
|
||||
}
|
||||
}
|
||||
|
@ -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(),
|
||||
};
|
||||
|
@ -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<impl LayoutMaybeTrace, Error> {
|
||||
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
|
||||
|
@ -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)]
|
||||
|
@ -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<impl LayoutMaybeTrace, Error> {
|
||||
let layout = RootComponent::new(Connect::new(text, theme::FG, theme::BG));
|
||||
Ok(layout)
|
||||
}
|
||||
}
|
||||
|
||||
fn new_show_modal(
|
||||
|
@ -85,4 +85,6 @@ pub trait UIFeaturesFirmware {
|
||||
bootscreen: bool,
|
||||
coinjoin_authorized: bool,
|
||||
) -> Result<impl LayoutMaybeTrace, Error>;
|
||||
|
||||
fn show_wait_text(text: TString<'static>) -> Result<impl LayoutMaybeTrace, Error>;
|
||||
}
|
||||
|
@ -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."""
|
||||
|
@ -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."""
|
||||
|
@ -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]:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user