diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index ca75443cc..7af8beddb 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -522,7 +522,8 @@ impl ConfirmBlobParams { description_font: &theme::TEXT_NORMAL, extra_font: &theme::TEXT_DEMIBOLD, data_font: if self.chunkify { - &theme::TEXT_MONO_ADDRESS_CHUNKS + let data: StrBuffer = self.data.try_into()?; + theme::get_chunkified_text_style(data.len()) } else { &theme::TEXT_MONO }, @@ -585,15 +586,8 @@ extern "C" fn new_confirm_address(n_args: usize, args: *const Obj, kwargs: *mut let chunkify: bool = kwargs.get_or(Qstr::MP_QSTR_chunkify, false)?; let data_style = if chunkify { - // Longer addresses have smaller x_offset so they fit even with scrollbar - // (as they will be shown on more than one page) - const FITS_ON_ONE_PAGE: usize = 16 * 4; let address: StrBuffer = data.try_into()?; - if address.len() <= FITS_ON_ONE_PAGE { - &theme::TEXT_MONO_ADDRESS_CHUNKS - } else { - &theme::TEXT_MONO_ADDRESS_CHUNKS_SMALLER_X_OFFSET - } + theme::get_chunkified_text_style(address.len()) } else { &theme::TEXT_MONO }; diff --git a/core/embed/rust/src/ui/model_tt/theme/mod.rs b/core/embed/rust/src/ui/model_tt/theme/mod.rs index 8110f1757..70b82b5f0 100644 --- a/core/embed/rust/src/ui/model_tt/theme/mod.rs +++ b/core/embed/rust/src/ui/model_tt/theme/mod.rs @@ -596,6 +596,18 @@ pub const TEXT_MONO_ADDRESS_CHUNKS_SMALLER_X_OFFSET: TextStyle = TEXT_MONO .with_line_spacing(5) .with_ellipsis_icon(ICON_PAGE_NEXT, -12); +/// Decide the text style of chunkified text according to its length. +pub fn get_chunkified_text_style(character_length: usize) -> &'static TextStyle { + // Longer addresses have smaller x_offset so they fit even with scrollbar + // (as they will be shown on more than one page) + const FITS_ON_ONE_PAGE: usize = 16 * 4; + if character_length <= FITS_ON_ONE_PAGE { + &TEXT_MONO_ADDRESS_CHUNKS + } else { + &TEXT_MONO_ADDRESS_CHUNKS_SMALLER_X_OFFSET + } +} + /// Convert Python-side numeric id to a `TextStyle`. pub fn textstyle_number(num: i32) -> &'static TextStyle { let font = Font::from_i32(-num);