diff --git a/core/embed/rust/src/ui/model_tr/bootloader/confirm.rs b/core/embed/rust/src/ui/model_tr/bootloader/confirm.rs index 234fc470a8..f0bc4688c9 100644 --- a/core/embed/rust/src/ui/model_tr/bootloader/confirm.rs +++ b/core/embed/rust/src/ui/model_tr/bootloader/confirm.rs @@ -1,5 +1,8 @@ use crate::ui::{ - component::{text::paragraphs::Paragraphs, Child, Component, Event, EventCtx, Pad}, + component::{ + text::paragraphs::{ParagraphVecShort, Paragraphs}, + Child, Component, Event, EventCtx, Pad, + }, constant::screen, display, display::Color, @@ -29,7 +32,7 @@ pub struct Confirm { bg: Pad, bg_color: Color, icon: Option<&'static [u8]>, - message: Child>, + message: Child>>, left: Child>, right: Child>, confirm_left: bool, @@ -39,7 +42,7 @@ impl Confirm { pub fn new( bg_color: Color, icon: Option<&'static [u8]>, - message: Paragraphs<&'static str>, + message: Paragraphs>, left: Button<&'static str>, right: Button<&'static str>, confirm_left: bool, diff --git a/core/embed/rust/src/ui/model_tr/bootloader/intro.rs b/core/embed/rust/src/ui/model_tr/bootloader/intro.rs index 86125f4f6e..0e23ebdd76 100644 --- a/core/embed/rust/src/ui/model_tr/bootloader/intro.rs +++ b/core/embed/rust/src/ui/model_tr/bootloader/intro.rs @@ -1,5 +1,8 @@ use crate::ui::{ - component::{text::paragraphs::Paragraphs, Child, Component, Event, EventCtx, Pad}, + component::{ + text::paragraphs::{Paragraph, ParagraphVecShort, Paragraphs, VecExt}, + Child, Component, Event, EventCtx, Pad, + }, geometry::{LinearPlacement, Point, Rect}, model_tr::{ bootloader::{ @@ -34,15 +37,18 @@ pub struct Intro { title: Child, host: Child<Button<&'static str>>, menu: Child<Button<&'static str>>, - text: Child<Paragraphs<&'static str>>, + text: Child<Paragraphs<ParagraphVecShort<&'static str>>>, } impl Intro { pub fn new(bld_version: &'static str, vendor: &'static str, version: &'static str) -> Self { - let p1 = Paragraphs::new() - .add(TEXT_NORMAL, version) - .add(TEXT_NORMAL, vendor) - .with_placement(LinearPlacement::vertical().align_at_start()); + let mut messages = ParagraphVecShort::new(); + + messages.add(Paragraph::new(&TEXT_NORMAL, version)); + messages.add(Paragraph::new(&TEXT_NORMAL, vendor)); + + let p1 = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_start()); let mut instance = Self { bg: Pad::with_background(BLD_BG), diff --git a/core/embed/rust/src/ui/model_tr/bootloader/mod.rs b/core/embed/rust/src/ui/model_tr/bootloader/mod.rs index c41373d57c..01d25bd746 100644 --- a/core/embed/rust/src/ui/model_tr/bootloader/mod.rs +++ b/core/embed/rust/src/ui/model_tr/bootloader/mod.rs @@ -15,7 +15,10 @@ mod theme; mod title; use crate::ui::{ - component::{text::paragraphs::Paragraphs, Event, EventCtx}, + component::{ + text::paragraphs::{Paragraph, ParagraphVecShort, Paragraphs, VecExt}, + Event, EventCtx, + }, constant::{screen, BACKLIGHT_NORMAL, WIDTH}, display::{fade_backlight_duration, Color, TextOverlay}, event::ButtonEvent, @@ -115,26 +118,27 @@ extern "C" fn screen_install_confirm( "Update firmware by" }; - let mut message = Paragraphs::new() - .add(theme::TEXT_NORMAL, msg) - .centered() - .add(theme::TEXT_NORMAL, text) - .centered() - .add(theme::TEXT_NORMAL, version) - .centered(); + let mut message = ParagraphVecShort::new(); + + message.add(Paragraph::new(&theme::TEXT_NORMAL, msg).centered()); + message.add(Paragraph::new(&theme::TEXT_NORMAL, text).centered()); + message.add(Paragraph::new(&theme::TEXT_NORMAL, version).centered()); if vendor || downgrade { - message = message - .add(theme::TEXT_BOLD, "Seed will be erased!") - .centered(); + message.add(Paragraph::new(&theme::TEXT_BOLD, "Seed will be erased!").centered()); } - message = message.with_placement(LinearPlacement::vertical().align_at_center()); - let left = Button::with_text(ButtonPos::Left, "CANCEL", bld_button_cancel()); let right = Button::with_text(ButtonPos::Right, "INSTALL", bld_button_default()); - let mut frame = Confirm::new(BLD_BG, ICON, message, left, right, false); + let mut frame = Confirm::new( + BLD_BG, + ICON, + Paragraphs::new(message).with_placement(LinearPlacement::vertical().align_at_center()), + left, + right, + false, + ); run(&mut frame) } @@ -143,12 +147,19 @@ extern "C" fn screen_install_confirm( extern "C" fn screen_wipe_confirm() -> u32 { const ICON: Option<&'static [u8]> = None; //Some(ERASE_BIG); - let message = Paragraphs::new() - .add(theme::TEXT_NORMAL, "Do you really want to wipe the device?") - .centered() - .add(theme::TEXT_BOLD, "Seed will be erased!") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let mut messages = ParagraphVecShort::new(); + + messages.add( + Paragraph::new( + &theme::TEXT_NORMAL, + "Do you really want to wipe the device?", + ) + .centered(), + ); + messages.add(Paragraph::new(&theme::TEXT_BOLD, "Seed will be erased!").centered()); + + let message = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); let left = Button::with_text(ButtonPos::Left, "WIPE", bld_button_default()); let right = Button::with_text(ButtonPos::Right, "CANCEL", bld_button_cancel()); @@ -243,10 +254,12 @@ extern "C" fn screen_wipe_progress(progress: u16, initialize: bool) -> u32 { #[no_mangle] extern "C" fn screen_connect() -> u32 { - let mut frame = Paragraphs::new() - .add(theme::TEXT_NORMAL, "Waiting for host...") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let mut messages = ParagraphVecShort::new(); + + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Waiting for host...").centered()); + + let mut frame = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); frame.place(SCREEN_ADJ); frame.paint(); @@ -255,19 +268,19 @@ extern "C" fn screen_connect() -> u32 { #[no_mangle] extern "C" fn screen_wipe_success() -> u32 { - let m_top = Paragraphs::new() - .add(theme::TEXT_NORMAL, "Device wiped") - .centered() - .add(theme::TEXT_NORMAL, "successfully.") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let mut messages = ParagraphVecShort::new(); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Device wiped").centered()); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "successfully.").centered()); - let m_bottom = Paragraphs::new() - .add(theme::TEXT_NORMAL, "PLEASE RECONNECT") - .centered() - .add(theme::TEXT_NORMAL, "THE DEVICE") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let m_top = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); + + let mut messages = ParagraphVecShort::new(); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "PLEASE RECONNECT").centered()); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "THE DEVICE").centered()); + + let m_bottom = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); let mut frame = ResultScreen::new(BLD_FG, BLD_BG, m_top, m_bottom, true); frame.place(SCREEN_ADJ); @@ -277,19 +290,19 @@ extern "C" fn screen_wipe_success() -> u32 { #[no_mangle] extern "C" fn screen_wipe_fail() -> u32 { - let m_top = Paragraphs::new() - .add(theme::TEXT_NORMAL, "Device wipe was") - .centered() - .add(theme::TEXT_NORMAL, "not successful.") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let mut messages = ParagraphVecShort::new(); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Device wipe was").centered()); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "not successful.").centered()); - let m_bottom = Paragraphs::new() - .add(theme::TEXT_NORMAL, "PLEASE RECONNECT") - .centered() - .add(theme::TEXT_NORMAL, "THE DEVICE") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let m_top = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); + + let mut messages = ParagraphVecShort::new(); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "PLEASE RECONNECT").centered()); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "THE DEVICE").centered()); + + let m_bottom = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); let mut frame = ResultScreen::new(BLD_FG, BLD_BG, m_top, m_bottom, true); frame.place(SCREEN_ADJ); @@ -304,19 +317,18 @@ extern "C" fn screen_boot_empty(_firmware_present: bool) { #[no_mangle] extern "C" fn screen_install_fail() -> u32 { - let m_top = Paragraphs::new() - .add(theme::TEXT_NORMAL, "Firmware installation was") - .centered() - .add(theme::TEXT_NORMAL, "not successful.") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let mut messages = ParagraphVecShort::new(); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Firmware installation was").centered()); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "not successful.").centered()); + let m_top = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); - let m_bottom = Paragraphs::new() - .add(theme::TEXT_NORMAL, "PLEASE RECONNECT") - .centered() - .add(theme::TEXT_NORMAL, "THE DEVICE") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let mut messages = ParagraphVecShort::new(); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "PLEASE RECONNECT").centered()); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "THE DEVICE").centered()); + + let m_bottom = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); let mut frame = ResultScreen::new(BLD_FG, BLD_BG, m_top, m_bottom, true); frame.place(SCREEN_ADJ); @@ -325,17 +337,18 @@ extern "C" fn screen_install_fail() -> u32 { } fn screen_install_success_bld(msg: &'static str, complete_draw: bool) -> u32 { - let m_top = Paragraphs::new() - .add(theme::TEXT_NORMAL, "Firmware installed") - .centered() - .add(theme::TEXT_NORMAL, "successfully.") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let mut messages = ParagraphVecShort::new(); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Firmware installed").centered()); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "successfully.").centered()); - let m_bottom = Paragraphs::new() - .add(theme::TEXT_NORMAL, msg) - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let m_top = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); + + let mut messages = ParagraphVecShort::new(); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, msg).centered()); + + let m_bottom = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); let mut frame = ResultScreen::new(BLD_FG, BLD_BG, m_top, m_bottom, complete_draw); frame.place(SCREEN_ADJ); @@ -344,17 +357,18 @@ fn screen_install_success_bld(msg: &'static str, complete_draw: bool) -> u32 { } fn screen_install_success_initial(msg: &'static str, complete_draw: bool) -> u32 { - let m_top = Paragraphs::new() - .add(theme::TEXT_NORMAL, "Firmware installed") - .centered() - .add(theme::TEXT_NORMAL, "successfully.") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let mut messages = ParagraphVecShort::new(); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "Firmware installed").centered()); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, "successfully.").centered()); - let m_bottom = Paragraphs::new() - .add(theme::TEXT_NORMAL, msg) - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let m_top = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); + + let mut messages = ParagraphVecShort::new(); + messages.add(Paragraph::new(&theme::TEXT_NORMAL, msg).centered()); + + let m_bottom = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); let mut frame = ResultScreen::new(BLD_FG, BLD_BG, m_top, m_bottom, complete_draw); frame.place(SCREEN_ADJ); @@ -378,14 +392,12 @@ extern "C" fn screen_install_success( #[no_mangle] extern "C" fn screen_welcome() -> u32 { - let mut frame = Paragraphs::new() - .add(theme::TEXT_BOLD, "Get started with") - .centered() - .add(theme::TEXT_BOLD, "your trezor at") - .centered() - .add(theme::TEXT_BOLD, "trezor.io/start") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let mut messages = ParagraphVecShort::new(); + messages.add(Paragraph::new(&theme::TEXT_BOLD, "Get started with").centered()); + messages.add(Paragraph::new(&theme::TEXT_BOLD, "your trezor at").centered()); + messages.add(Paragraph::new(&theme::TEXT_BOLD, "trezor.io/start").centered()); + let mut frame = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); frame.place(SCREEN_ADJ); frame.paint(); diff --git a/core/embed/rust/src/ui/model_tr/component/result.rs b/core/embed/rust/src/ui/model_tr/component/result.rs index eee484e3ab..135f07be71 100644 --- a/core/embed/rust/src/ui/model_tr/component/result.rs +++ b/core/embed/rust/src/ui/model_tr/component/result.rs @@ -1,5 +1,8 @@ use crate::ui::{ - component::{text::paragraphs::Paragraphs, Child, Component, Event, EventCtx, Never, Pad}, + component::{ + text::paragraphs::{ParagraphVecShort, Paragraphs}, + Child, Component, Event, EventCtx, Never, Pad, + }, constant::{HEIGHT, WIDTH}, display::Color, geometry::{Point, Rect}, @@ -10,16 +13,16 @@ pub struct ResultScreen { small_pad: Pad, fg_color: Color, bg_color: Color, - message_top: Child<Paragraphs<&'static str>>, - message_bottom: Child<Paragraphs<&'static str>>, + message_top: Child<Paragraphs<ParagraphVecShort<&'static str>>>, + message_bottom: Child<Paragraphs<ParagraphVecShort<&'static str>>>, } impl ResultScreen { pub fn new( fg_color: Color, bg_color: Color, - message_top: Paragraphs<&'static str>, - message_bottom: Paragraphs<&'static str>, + message_top: Paragraphs<ParagraphVecShort<&'static str>>, + message_bottom: Paragraphs<ParagraphVecShort<&'static str>>, complete_draw: bool, ) -> Self { let mut instance = Self { diff --git a/core/embed/rust/src/ui/model_tr/screens.rs b/core/embed/rust/src/ui/model_tr/screens.rs index cb154bd18a..ee823917a5 100644 --- a/core/embed/rust/src/ui/model_tr/screens.rs +++ b/core/embed/rust/src/ui/model_tr/screens.rs @@ -1,5 +1,8 @@ use crate::ui::{ - component::{text::paragraphs::Paragraphs, Component}, + component::{ + text::paragraphs::{Paragraph, ParagraphVecShort, Paragraphs, VecExt}, + Component, + }, geometry::LinearPlacement, model_tr::{ component::ResultScreen, @@ -12,30 +15,30 @@ use crate::ui::{ #[no_mangle] extern "C" fn screen_fatal_error(msg: *const cty::c_char, file: *const cty::c_char) -> u32 { let m_top = if msg.is_null() { - Paragraphs::new() - .add(TEXT_BOLD, "FATAL ERROR!") - .centered() - // .add(theme::TEXT_WIPE_NORMAL, unwrap!(unsafe { from_c_str(expr) })) - // .centered() - .add(TEXT_NORMAL, unwrap!(unsafe { from_c_str(file) })) - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()) + let mut messages = ParagraphVecShort::new(); + + messages.add(Paragraph::new(&TEXT_BOLD, "FATAL ERROR!").centered()); + + messages.add(Paragraph::new(&TEXT_NORMAL, unwrap!(unsafe { from_c_str(file) })).centered()); + + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()) } else { let msg = unwrap!(unsafe { from_c_str(msg) }); - Paragraphs::new() - .add(TEXT_BOLD, "FATAL ERROR!") - .centered() - .add(TEXT_NORMAL, msg) - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()) + + let mut messages = ParagraphVecShort::new(); + + messages.add(Paragraph::new(&TEXT_BOLD, "FATAL ERROR!").centered()); + messages.add(Paragraph::new(&TEXT_NORMAL, msg).centered()); + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()) }; - let m_bottom = Paragraphs::new() - .add(TEXT_BOLD, "PLEASE CONTACT") - .centered() - .add(TEXT_BOLD, "TREZOR SUPPORT") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let mut messages = ParagraphVecShort::new(); + + messages.add(Paragraph::new(&TEXT_BOLD, "PLEASE CONTACT").centered()); + messages.add(Paragraph::new(&TEXT_BOLD, "TREZOR SUPPORT").centered()); + + let m_bottom = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); let mut frame = ResultScreen::new(WHITE, BLACK, m_top, m_bottom, true); frame.place(constant::screen()); @@ -48,26 +51,26 @@ extern "C" fn screen_error_shutdown(label: *const cty::c_char, msg: *const cty:: let label = unwrap!(unsafe { from_c_str(label) }); let m_top = if msg.is_null() { - Paragraphs::new() - .add(TEXT_BOLD, label) - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()) + let mut messages = ParagraphVecShort::new(); + + messages.add(Paragraph::new(&TEXT_BOLD, label).centered()); + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()) } else { let msg = unwrap!(unsafe { from_c_str(msg) }); - Paragraphs::new() - .add(TEXT_BOLD, label) - .centered() - .add(TEXT_NORMAL, msg) - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()) + + let mut messages = ParagraphVecShort::new(); + + messages.add(Paragraph::new(&TEXT_BOLD, label).centered()); + messages.add(Paragraph::new(&TEXT_NORMAL, msg).centered()); + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()) }; - let m_bottom = Paragraphs::new() - .add(TEXT_BOLD, "PLEASE UNPLUG") - .centered() - .add(TEXT_BOLD, "THE DEVICE") - .centered() - .with_placement(LinearPlacement::vertical().align_at_center()); + let mut messages = ParagraphVecShort::new(); + + messages.add(Paragraph::new(&TEXT_BOLD, "PLEASE UNPLUG").centered()); + messages.add(Paragraph::new(&TEXT_BOLD, "THE DEVICE").centered()); + let m_bottom = + Paragraphs::new(messages).with_placement(LinearPlacement::vertical().align_at_center()); let mut frame = ResultScreen::new(WHITE, BLACK, m_top, m_bottom, true); frame.place(constant::screen());