fix(core): fix the chunkification of longer Cardano addresses in send flow

[no changelog]
pull/3346/head
grdddj 6 months ago committed by Jiří Musil
parent 50d53e15f4
commit 1968599bbc

@ -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
};

@ -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);

Loading…
Cancel
Save