Skip to content

Commit 14265bc

Browse files
committed
feat(core): allow external menu on Eckhart show_info() layout
It will be used for N4W1 I/O layouts. [no changelog]
1 parent 94ae852 commit 14265bc

7 files changed

Lines changed: 25 additions & 2 deletions

File tree

core/embed/rust/src/ui/api/firmware_micropython.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,8 +1081,9 @@ extern "C" fn new_show_info(n_args: usize, args: *const Obj, kwargs: *mut Map) -
10811081
})
10821082
.transpose()?;
10831083
let time_ms: u32 = kwargs.get_or(Qstr::MP_QSTR_time_ms, 0)?.try_into()?;
1084+
let external_menu: bool = kwargs.get_or(Qstr::MP_QSTR_external_menu, false)?;
10841085

1085-
let obj = ModelUI::show_info(title, description, button, time_ms)?;
1086+
let obj = ModelUI::show_info(title, description, button, time_ms, external_menu)?;
10861087
Ok(obj.into())
10871088
};
10881089
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
@@ -2022,6 +2023,7 @@ pub static mp_module_trezorui_api: Module = obj_module! {
20222023
/// description: str = "",
20232024
/// button: tuple[str, bool] | None = None,
20242025
/// time_ms: int = 0,
2026+
/// external_menu: bool = False,
20252027
/// ) -> LayoutObj[UiResult]:
20262028
/// """Info screen."""
20272029
Qstr::MP_QSTR_show_info => obj_fn_kw!(0, new_show_info).as_obj(),

core/embed/rust/src/ui/layout_bolt/ui_firmware.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,11 @@ impl FirmwareUI for UIBolt {
992992
description: TString<'static>,
993993
button: Option<(TString<'static>, bool)>,
994994
time_ms: u32,
995+
external_menu: bool, // TODO: will eventually replace the internal menu
995996
) -> Result<Gc<LayoutObj>, Error> {
997+
if external_menu {
998+
return Err(Error::NotImplementedError);
999+
}
9961000
let button_text = match (button, time_ms) {
9971001
// either button or timeout must be set
9981002
(None, 0) => return Err(Error::NotImplementedError),

core/embed/rust/src/ui/layout_caesar/ui_firmware.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,11 @@ impl FirmwareUI for UICaesar {
11751175
description: TString<'static>,
11761176
_button: Option<(TString<'static>, bool)>,
11771177
time_ms: u32,
1178+
external_menu: bool, // TODO: will eventually replace the internal menu
11781179
) -> Result<Gc<LayoutObj>, Error> {
1180+
if external_menu {
1181+
return Err(Error::NotImplementedError);
1182+
}
11791183
let content = Frame::new(
11801184
title,
11811185
Paragraphs::new([Paragraph::new(&theme::TEXT_NORMAL, description)]),

core/embed/rust/src/ui/layout_delizia/ui_firmware.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,11 @@ impl FirmwareUI for UIDelizia {
973973
description: TString<'static>,
974974
_button: Option<(TString<'static>, bool)>,
975975
_time_ms: u32,
976+
external_menu: bool, // TODO: will eventually replace the internal menu
976977
) -> Result<Gc<LayoutObj>, Error> {
978+
if external_menu {
979+
return Err(Error::NotImplementedError);
980+
}
977981
let content = Paragraphs::new(Paragraph::new(&theme::TEXT_MAIN_GREY_LIGHT, description));
978982
let obj = LayoutObj::new(SwipeUpScreen::new(
979983
Frame::left_aligned(title, SwipeContent::new(content)).with_swipeup_footer(None),

core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,15 +1235,22 @@ impl FirmwareUI for UIEckhart {
12351235
description: TString<'static>,
12361236
button: Option<(TString<'static>, bool)>,
12371237
_time_ms: u32,
1238+
external_menu: bool, // TODO: will eventually replace the internal menu
12381239
) -> Result<Gc<LayoutObj>, Error> {
12391240
let content = Paragraphs::new(Paragraph::new(&theme::TEXT_REGULAR, description))
12401241
.with_placement(LinearPlacement::vertical());
12411242

12421243
let button = button.map_or_else(Button::empty, |(text, enabled)| {
12431244
Button::with_text(text).initially_enabled(enabled)
12441245
});
1246+
let header = Header::new(title);
12451247
let screen = TextScreen::new(content)
1246-
.with_header(Header::new(title))
1248+
.with_header(if external_menu {
1249+
header.with_menu_button()
1250+
} else {
1251+
header
1252+
})
1253+
.with_external_menu(external_menu)
12471254
.with_action_bar(ActionBar::new_single(button));
12481255
let obj = LayoutObj::new(screen)?;
12491256
Ok(obj)

core/embed/rust/src/ui/ui_firmware.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ pub trait FirmwareUI {
387387
description: TString<'static>,
388388
button: Option<(TString<'static>, bool)>,
389389
time_ms: u32,
390+
external_menu: bool, // TODO: will eventually replace the internal menu
390391
) -> Result<Gc<LayoutObj>, Error>; // TODO: return LayoutMaybeTrace
391392

392393
fn show_info_with_cancel(

core/mocks/generated/trezorui_api.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ def show_info(
693693
description: str = "",
694694
button: tuple[str, bool] | None = None,
695695
time_ms: int = 0,
696+
external_menu: bool = False,
696697
) -> LayoutObj[UiResult]:
697698
"""Info screen."""
698699

0 commit comments

Comments
 (0)