From 97c9f84f8d4779c044f6c37b75996602b19453cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ioan=20Biz=C4=83u?= Date: Wed, 13 Nov 2024 17:53:51 +0100 Subject: [PATCH] feat(core/ui): add page counter to paginated blobs --- core/.changelog.d/4302.added | 1 + core/embed/rust/librust_qstr.h | 1 + core/embed/rust/src/ui/component/base.rs | 2 +- core/embed/rust/src/ui/component/paginated.rs | 2 +- .../rust/src/ui/component/text/formatted.rs | 28 ++++++++-------- .../rust/src/ui/component/text/paragraphs.rs | 6 ++-- core/embed/rust/src/ui/flow/page.rs | 8 +++++ .../component/address_details.rs | 2 +- .../src/ui/model_mercury/component/footer.rs | 32 ++++++++----------- .../src/ui/model_mercury/component/frame.rs | 4 +-- .../model_mercury/component/vertical_menu.rs | 2 +- .../ui/model_mercury/flow/confirm_action.rs | 29 ++++++++++++++--- .../src/ui/model_mercury/flow/confirm_fido.rs | 2 +- .../model_mercury/flow/continue_recovery.rs | 2 +- .../ui/model_mercury/flow/show_share_words.rs | 5 ++- .../rust/src/ui/model_mercury/flow/util.rs | 8 +++++ .../embed/rust/src/ui/model_mercury/layout.rs | 8 +++++ .../src/ui/model_tr/component/flow_pages.rs | 2 +- .../rust/src/ui/model_tr/component/frame.rs | 2 +- .../src/ui/model_tr/component/scrollbar.rs | 2 +- .../src/ui/model_tr/component/share_words.rs | 3 +- core/embed/rust/src/ui/model_tr/layout.rs | 1 + .../ui/model_tt/component/address_details.rs | 2 +- core/embed/rust/src/ui/model_tt/layout.rs | 1 + core/mocks/generated/trezorui2.pyi | 3 ++ .../src/trezor/ui/layouts/mercury/__init__.py | 1 + 26 files changed, 103 insertions(+), 56 deletions(-) create mode 100644 core/.changelog.d/4302.added diff --git a/core/.changelog.d/4302.added b/core/.changelog.d/4302.added new file mode 100644 index 0000000000..f4274d9c17 --- /dev/null +++ b/core/.changelog.d/4302.added @@ -0,0 +1 @@ +[T3T1] Add page counter to paginated blobs. diff --git a/core/embed/rust/librust_qstr.h b/core/embed/rust/librust_qstr.h index 2d3a3f54d7..449f802f27 100644 --- a/core/embed/rust/librust_qstr.h +++ b/core/embed/rust/librust_qstr.h @@ -357,6 +357,7 @@ static void _librust_qstrs(void) { MP_QSTR_notification; MP_QSTR_notification_level; MP_QSTR_page_count; + MP_QSTR_page_counter; MP_QSTR_page_limit; MP_QSTR_pages; MP_QSTR_paint; diff --git a/core/embed/rust/src/ui/component/base.rs b/core/embed/rust/src/ui/component/base.rs index 2cb1acdf03..e23b7223eb 100644 --- a/core/embed/rust/src/ui/component/base.rs +++ b/core/embed/rust/src/ui/component/base.rs @@ -150,7 +150,7 @@ where } impl Paginate for Child { - fn page_count(&mut self) -> usize { + fn page_count(&self) -> usize { self.component.page_count() } diff --git a/core/embed/rust/src/ui/component/paginated.rs b/core/embed/rust/src/ui/component/paginated.rs index 4c4efb62b2..75a05ac3ed 100644 --- a/core/embed/rust/src/ui/component/paginated.rs +++ b/core/embed/rust/src/ui/component/paginated.rs @@ -22,7 +22,7 @@ pub enum PageMsg { pub trait Paginate { /// How many pages of content are there in total? - fn page_count(&mut self) -> usize; + fn page_count(&self) -> usize; /// Navigate to the given page. fn change_page(&mut self, active_page: usize); } diff --git a/core/embed/rust/src/ui/component/text/formatted.rs b/core/embed/rust/src/ui/component/text/formatted.rs index 2844756ce4..f41ebc956e 100644 --- a/core/embed/rust/src/ui/component/text/formatted.rs +++ b/core/embed/rust/src/ui/component/text/formatted.rs @@ -33,8 +33,17 @@ impl FormattedText { } pub(crate) fn layout_content(&self, sink: &mut dyn LayoutSink) -> LayoutFit { + self.layout_content_with_offset(sink, self.char_offset, self.y_offset) + } + + fn layout_content_with_offset( + &self, + sink: &mut dyn LayoutSink, + char_offset: usize, + y_offset: i16, + ) -> LayoutFit { self.op_layout - .layout_ops(self.char_offset, Offset::y(self.y_offset), sink) + .layout_ops(char_offset, Offset::y(y_offset), sink) } fn align_vertically(&mut self, content_height: i16) { @@ -53,20 +62,15 @@ impl FormattedText { // Pagination impl Paginate for FormattedText { - fn page_count(&mut self) -> usize { + fn page_count(&self) -> usize { let mut page_count = 1; // There's always at least one page. - // Make sure we're starting page counting from the very beginning - // (but remembering the offsets not to change them). - let initial_y_offset = self.y_offset; - let initial_char_offset = self.char_offset; - self.char_offset = 0; - self.y_offset = 0; + let mut char_offset = 0; // Looping through the content and counting pages // until we finally fit. loop { - let fit = self.layout_content(&mut TextNoOp); + let fit = self.layout_content_with_offset(&mut TextNoOp, char_offset, 0); match fit { LayoutFit::Fitting { .. } => { break; @@ -75,15 +79,11 @@ impl Paginate for FormattedText { processed_chars, .. } => { page_count += 1; - self.char_offset += processed_chars; + char_offset += processed_chars; } } } - // Setting the offsets back to the initial values. - self.char_offset = initial_char_offset; - self.y_offset = initial_y_offset; - page_count } diff --git a/core/embed/rust/src/ui/component/text/paragraphs.rs b/core/embed/rust/src/ui/component/text/paragraphs.rs index 26a6033e40..871fb8544e 100644 --- a/core/embed/rust/src/ui/component/text/paragraphs.rs +++ b/core/embed/rust/src/ui/component/text/paragraphs.rs @@ -210,7 +210,7 @@ impl<'a, T> Paginate for Paragraphs where T: ParagraphSource<'a>, { - fn page_count(&mut self) -> usize { + fn page_count(&self) -> usize { // There's always at least one page. self.break_pages().count().max(1) } @@ -374,7 +374,7 @@ struct PageOffset { } impl PageOffset { - /// Given an `PageOffset` and a `Rect` area, returns: + /// Given a `PageOffset` and a `Rect` area, returns: /// /// - The next offset. /// - Part of `area` that remains free after the current offset is rendered @@ -690,7 +690,7 @@ impl<'a, T> Paginate for Checklist where T: ParagraphSource<'a>, { - fn page_count(&mut self) -> usize { + fn page_count(&self) -> usize { 1 } diff --git a/core/embed/rust/src/ui/flow/page.rs b/core/embed/rust/src/ui/flow/page.rs index f2d3e7ba4b..48c410ed68 100644 --- a/core/embed/rust/src/ui/flow/page.rs +++ b/core/embed/rust/src/ui/flow/page.rs @@ -47,6 +47,14 @@ impl SwipePage { self.limit = limit; self } + + pub fn page_count(&self) -> usize { + self.pages + } + + pub fn current_page(&self) -> usize { + self.current + } } impl Component for SwipePage { diff --git a/core/embed/rust/src/ui/model_mercury/component/address_details.rs b/core/embed/rust/src/ui/model_mercury/component/address_details.rs index ce0ee70c98..16ea2025af 100644 --- a/core/embed/rust/src/ui/model_mercury/component/address_details.rs +++ b/core/embed/rust/src/ui/model_mercury/component/address_details.rs @@ -117,7 +117,7 @@ impl AddressDetails { } impl Paginate for AddressDetails { - fn page_count(&mut self) -> usize { + fn page_count(&self) -> usize { self.get_internal_page_count() } diff --git a/core/embed/rust/src/ui/model_mercury/component/footer.rs b/core/embed/rust/src/ui/model_mercury/component/footer.rs index c0c4ba0c5f..d9a97a2202 100644 --- a/core/embed/rust/src/ui/model_mercury/component/footer.rs +++ b/core/embed/rust/src/ui/model_mercury/component/footer.rs @@ -69,11 +69,8 @@ impl<'a> Footer<'a> { ) } - pub fn with_page_counter(max_pages: u8, instruction: TString<'static>) -> Self { - Self::from_content(FooterContent::PageCounter(PageCounter::new( - max_pages, - instruction, - ))) + pub fn with_page_counter(instruction: TString<'static>) -> Self { + Self::from_content(FooterContent::PageCounter(PageCounter::new(instruction))) } pub fn with_page_hint( @@ -115,18 +112,18 @@ impl<'a> Footer<'a> { } } - pub fn update_page_counter(&mut self, ctx: &mut EventCtx, current: usize, max: Option) { + pub fn update_page_counter(&mut self, ctx: &mut EventCtx, current: usize, max: usize) { match &mut self.content { FooterContent::PageCounter(counter) => { - counter.update_current_page(current); + counter.update_current_page(current, max); self.swipe_allow_down = counter.is_first_page(); self.swipe_allow_up = counter.is_last_page(); ctx.request_paint(); } - FooterContent::PageHint(page_hint) => { - page_hint.update_current_page(current, max); - self.swipe_allow_down = page_hint.is_first_page(); - self.swipe_allow_up = page_hint.is_last_page(); + FooterContent::PageHint(hint) => { + hint.update_current_page(current, max); + self.swipe_allow_down = hint.is_first_page(); + self.swipe_allow_up = hint.is_last_page(); ctx.request_paint(); } _ => { @@ -322,16 +319,17 @@ struct PageCounter { } impl PageCounter { - fn new(page_max: u8, instruction: TString<'static>) -> Self { + fn new(instruction: TString<'static>) -> Self { Self { instruction, page_curr: 0, - page_max, + page_max: 0, font: Font::SUB, } } - fn update_current_page(&mut self, new_value: usize) { + fn update_current_page(&mut self, new_value: usize, max: usize) { + self.page_max = max as u8; self.page_curr = (new_value as u8).clamp(0, self.page_max.saturating_sub(1)); } @@ -410,11 +408,9 @@ struct PageHint { } impl PageHint { - fn update_current_page(&mut self, current: usize, max: Option) { + fn update_current_page(&mut self, current: usize, max: usize) { + self.page_num = max as u8; self.page_curr = (current as u8).clamp(0, self.page_num.saturating_sub(1)); - if let Some(max) = max { - self.page_num = max as u8; - } } fn update_max_page(&mut self, max: usize) { diff --git a/core/embed/rust/src/ui/model_mercury/component/frame.rs b/core/embed/rust/src/ui/model_mercury/component/frame.rs index b25de2c8cb..32719551a7 100644 --- a/core/embed/rust/src/ui/model_mercury/component/frame.rs +++ b/core/embed/rust/src/ui/model_mercury/component/frame.rs @@ -195,8 +195,8 @@ where } #[inline(never)] - pub fn with_footer_counter(mut self, instruction: TString<'static>, max_value: u8) -> Self { - self.footer = Some(Footer::with_page_counter(max_value, instruction)); + pub fn with_footer_counter(mut self, instruction: TString<'static>) -> Self { + self.footer = Some(Footer::with_page_counter(instruction)); self } diff --git a/core/embed/rust/src/ui/model_mercury/component/vertical_menu.rs b/core/embed/rust/src/ui/model_mercury/component/vertical_menu.rs index 6ccd648304..a4a9db7ebe 100644 --- a/core/embed/rust/src/ui/model_mercury/component/vertical_menu.rs +++ b/core/embed/rust/src/ui/model_mercury/component/vertical_menu.rs @@ -335,7 +335,7 @@ impl TString<'static>> PagedVerticalMenu { } impl TString<'static>> Paginate for PagedVerticalMenu { - fn page_count(&mut self) -> usize { + fn page_count(&self) -> usize { self.num_pages() } diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs index 6ba90cb413..f65e45fa74 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs @@ -7,7 +7,7 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, VecExt}, - Component, ComponentExt, Paginate, + Component, ComponentExt, EventCtx, Paginate, }, flow::{ base::{Decision, DecisionBuilder as _}, @@ -19,7 +19,8 @@ use crate::{ use super::super::{ component::{ - Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg, + Footer, Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, + VerticalMenuChoiceMsg, }, theme, }; @@ -171,15 +172,17 @@ pub fn new_confirm_action( ConfirmActionStrings::new(title, subtitle, None, prompt_screen.then_some(prompt_title)), hold, None, + false, ) } #[inline(never)] -fn new_confirm_action_uni( - content: T, +fn new_confirm_action_uni( + content: SwipeContent>, menu: ConfirmActionMenu, strings: ConfirmActionStrings, hold: bool, + page_counter: bool, ) -> Result { let (prompt_screen, prompt_pages, flow, page) = create_flow(strings.title, strings.prompt_screen, hold); @@ -191,6 +194,22 @@ fn new_confirm_action_uni( .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), None); + if page_counter { + fn footer_update_fn( + content: &SwipeContent>, + ctx: &mut EventCtx, + footer: &mut Footer, + ) { + let current_page = content.inner().current_page(); + let page_count = content.inner().page_count(); + footer.update_page_counter(ctx, current_page, page_count); + } + + content_intro = content_intro + .with_footer_counter(TR::instructions__swipe_up.into()) + .register_footer_update_fn(footer_update_fn::); + } + if let Some(subtitle) = strings.subtitle { content_intro = content_intro.with_subtitle(subtitle); } @@ -318,11 +337,13 @@ pub fn new_confirm_action_simple strings: ConfirmActionStrings, hold: bool, page_limit: Option, + page_counter: bool, ) -> Result { new_confirm_action_uni( SwipeContent::new(SwipePage::vertical(content).with_limit(page_limit)), menu, strings, hold, + page_counter, ) } diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_fido.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_fido.rs index 6c2bf97324..755b6b617a 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_fido.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_fido.rs @@ -100,7 +100,7 @@ fn footer_update_fn( ) { let current_page = content.inner().inner().current_page(); let total_pages = content.inner().inner().num_pages(); - footer.update_page_counter(ctx, current_page, Some(total_pages)); + footer.update_page_counter(ctx, current_page, total_pages); } impl ConfirmFido { diff --git a/core/embed/rust/src/ui/model_mercury/flow/continue_recovery.rs b/core/embed/rust/src/ui/model_mercury/flow/continue_recovery.rs index 654fc80f96..6f37a24806 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/continue_recovery.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/continue_recovery.rs @@ -151,7 +151,7 @@ fn footer_update_fn( // to get total pages instead of using Paginate because it borrows mutably let current_page = content.inner().inner().current_page(); let total_pages = content.inner().inner().inner().len() / 2; // 2 paragraphs per page - footer.update_page_counter(ctx, current_page, Some(total_pages)); + footer.update_page_counter(ctx, current_page, total_pages); } pub fn new_continue_recovery( diff --git a/core/embed/rust/src/ui/model_mercury/flow/show_share_words.rs b/core/embed/rust/src/ui/model_mercury/flow/show_share_words.rs index 76203de9c6..d3ef86ae7b 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/show_share_words.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/show_share_words.rs @@ -74,7 +74,7 @@ fn footer_updating_func( ) { let current_page = content.inner().current_page(); let total_pages = content.inner().num_pages(); - footer.update_page_counter(ctx, current_page, Some(total_pages)); + footer.update_page_counter(ctx, current_page, total_pages); } pub fn new_show_share_words( @@ -103,7 +103,6 @@ pub fn new_show_share_words( .one_button_request(ButtonRequestCode::ResetDevice.with_name("share_words")) .with_pages(move |_| nwords + 2); - let n_words = share_words_vec.len(); let content_words = Frame::left_aligned( title, InternallySwipableContent::new(ShareWords::new(share_words_vec, subtitle)), @@ -113,7 +112,7 @@ pub fn new_show_share_words( .with_vertical_pages() .with_subtitle(subtitle) .register_header_update_fn(header_updating_func) - .with_footer_counter(TR::instructions__swipe_up.into(), n_words as u8) + .with_footer_counter(TR::instructions__swipe_up.into()) .register_footer_update_fn(footer_updating_func) .map(|_| None); diff --git a/core/embed/rust/src/ui/model_mercury/flow/util.rs b/core/embed/rust/src/ui/model_mercury/flow/util.rs index 519b40f039..f7ca0556a8 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/util.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/util.rs @@ -47,6 +47,7 @@ pub struct ConfirmBlobParams { hold: bool, chunkify: bool, text_mono: bool, + page_counter: bool, page_limit: Option, swipe_up: bool, swipe_down: bool, @@ -78,6 +79,7 @@ impl ConfirmBlobParams { hold: false, chunkify: false, text_mono: true, + page_counter: false, page_limit: None, swipe_up: false, swipe_down: false, @@ -170,6 +172,11 @@ impl ConfirmBlobParams { self } + pub fn with_page_counter(mut self, page_counter: bool) -> Self { + self.page_counter = page_counter; + self + } + pub const fn with_page_limit(mut self, page_limit: Option) -> Self { self.page_limit = page_limit; self @@ -266,6 +273,7 @@ impl ConfirmBlobParams { ), self.hold, self.page_limit, + self.page_counter, ) } } diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index f1e9e3a443..003f1a8df8 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -250,6 +250,7 @@ extern "C" fn new_confirm_emphasized(n_args: usize, args: *const Obj, kwargs: *m ConfirmActionStrings::new(title, None, None, Some(title)), false, None, + false, ) .and_then(LayoutObj::new_root) .map(Into::into) @@ -289,6 +290,7 @@ extern "C" fn new_confirm_blob(n_args: usize, args: *const Obj, kwargs: *mut Map let info: bool = kwargs.get_or(Qstr::MP_QSTR_info, true)?; let hold: bool = kwargs.get_or(Qstr::MP_QSTR_hold, false)?; let chunkify: bool = kwargs.get_or(Qstr::MP_QSTR_chunkify, false)?; + let page_counter: bool = kwargs.get_or(Qstr::MP_QSTR_page_counter, false)?; let prompt_screen: bool = kwargs.get_or(Qstr::MP_QSTR_prompt_screen, true)?; let page_limit: Option = kwargs .get(Qstr::MP_QSTR_page_limit) @@ -314,6 +316,7 @@ extern "C" fn new_confirm_blob(n_args: usize, args: *const Obj, kwargs: *mut Map .with_extra(extra) .with_info_button(info) .with_chunkify(chunkify) + .with_page_counter(page_counter) .with_page_limit(page_limit) .with_prompt(prompt_screen) .with_hold(hold) @@ -427,6 +430,7 @@ extern "C" fn new_confirm_properties(n_args: usize, args: *const Obj, kwargs: *m ConfirmActionStrings::new(title, None, None, hold.then_some(title)), hold, None, + false, ) .and_then(LayoutObj::new_root) .map(Into::into) @@ -461,6 +465,7 @@ extern "C" fn new_confirm_homescreen(n_args: usize, args: *const Obj, kwargs: *m ), false, None, + false, ) .and_then(LayoutObj::new_root) .map(Into::into) @@ -767,6 +772,7 @@ extern "C" fn new_confirm_total(n_args: usize, args: *const Obj, kwargs: *mut Ma ConfirmActionStrings::new(title, None, None, Some(title)), true, None, + false, ) .and_then(LayoutObj::new_root) .map(Into::into) @@ -1087,6 +1093,7 @@ extern "C" fn new_confirm_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut ), true, None, + false, ) .and_then(LayoutObj::new_root) .map(Into::into) @@ -1570,6 +1577,7 @@ pub static mp_module_trezorui2: Module = obj_module! { /// info: bool = True, /// hold: bool = False, /// chunkify: bool = False, + /// page_counter: bool = False, /// prompt_screen: bool = False, /// page_limit: int | None = None, /// ) -> LayoutObj[UiResult]: diff --git a/core/embed/rust/src/ui/model_tr/component/flow_pages.rs b/core/embed/rust/src/ui/model_tr/component/flow_pages.rs index d4a4c726ba..ca1f31aa1d 100644 --- a/core/embed/rust/src/ui/model_tr/component/flow_pages.rs +++ b/core/embed/rust/src/ui/model_tr/component/flow_pages.rs @@ -199,7 +199,7 @@ impl Page { // Pagination impl Paginate for Page { - fn page_count(&mut self) -> usize { + fn page_count(&self) -> usize { self.formatted.page_count() } diff --git a/core/embed/rust/src/ui/model_tr/component/frame.rs b/core/embed/rust/src/ui/model_tr/component/frame.rs index 3ea0c8611d..b64afba30b 100644 --- a/core/embed/rust/src/ui/model_tr/component/frame.rs +++ b/core/embed/rust/src/ui/model_tr/component/frame.rs @@ -87,7 +87,7 @@ impl Paginate for Frame where T: Component + Paginate, { - fn page_count(&mut self) -> usize { + fn page_count(&self) -> usize { self.content.page_count() } diff --git a/core/embed/rust/src/ui/model_tr/component/scrollbar.rs b/core/embed/rust/src/ui/model_tr/component/scrollbar.rs index 04514382b2..c026aba42a 100644 --- a/core/embed/rust/src/ui/model_tr/component/scrollbar.rs +++ b/core/embed/rust/src/ui/model_tr/component/scrollbar.rs @@ -225,7 +225,7 @@ impl Component for ScrollBar { } impl Paginate for ScrollBar { - fn page_count(&mut self) -> usize { + fn page_count(&self) -> usize { self.page_count } diff --git a/core/embed/rust/src/ui/model_tr/component/share_words.rs b/core/embed/rust/src/ui/model_tr/component/share_words.rs index 4a603db85b..fe8d6ea6e2 100644 --- a/core/embed/rust/src/ui/model_tr/component/share_words.rs +++ b/core/embed/rust/src/ui/model_tr/component/share_words.rs @@ -150,8 +150,7 @@ impl<'a> Component for ShareWords<'a> { } impl<'a> Paginate for ShareWords<'a> { - fn page_count(&mut self) -> usize { - // Not defining the logic here, as we do not want it to be `&mut`. + fn page_count(&self) -> usize { self.total_page_count() } diff --git a/core/embed/rust/src/ui/model_tr/layout.rs b/core/embed/rust/src/ui/model_tr/layout.rs index 248eb5b418..ca5f82e7ac 100644 --- a/core/embed/rust/src/ui/model_tr/layout.rs +++ b/core/embed/rust/src/ui/model_tr/layout.rs @@ -1709,6 +1709,7 @@ pub static mp_module_trezorui2: Module = obj_module! { /// info: bool = True, /// hold: bool = False, /// chunkify: bool = False, + /// page_counter: bool = False, /// prompt_screen: bool = False, /// page_limit: int | None = None, /// ) -> LayoutObj[UiResult]: diff --git a/core/embed/rust/src/ui/model_tt/component/address_details.rs b/core/embed/rust/src/ui/model_tt/component/address_details.rs index 66c5433761..4b28a2c215 100644 --- a/core/embed/rust/src/ui/model_tt/component/address_details.rs +++ b/core/embed/rust/src/ui/model_tt/component/address_details.rs @@ -125,7 +125,7 @@ impl AddressDetails { } impl Paginate for AddressDetails { - fn page_count(&mut self) -> usize { + fn page_count(&self) -> usize { let total_xpub_pages: u8 = self.xpub_page_count.iter().copied().sum(); 2usize.saturating_add(total_xpub_pages.into()) } diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index f37952700f..f71906512e 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -1803,6 +1803,7 @@ pub static mp_module_trezorui2: Module = obj_module! { /// info: bool = True, /// hold: bool = False, /// chunkify: bool = False, + /// page_counter: bool = False, /// prompt_screen: bool = False, /// page_limit: int | None = None, /// ) -> LayoutObj[UiResult]: diff --git a/core/mocks/generated/trezorui2.pyi b/core/mocks/generated/trezorui2.pyi index e7fa414d73..61df2e7fe1 100644 --- a/core/mocks/generated/trezorui2.pyi +++ b/core/mocks/generated/trezorui2.pyi @@ -68,6 +68,7 @@ def confirm_blob( info: bool = True, hold: bool = False, chunkify: bool = False, + page_counter: bool = False, prompt_screen: bool = False, page_limit: int | None = None, ) -> LayoutObj[UiResult]: @@ -640,6 +641,7 @@ def confirm_blob( info: bool = True, hold: bool = False, chunkify: bool = False, + page_counter: bool = False, prompt_screen: bool = False, page_limit: int | None = None, ) -> LayoutObj[UiResult]: @@ -1211,6 +1213,7 @@ def confirm_blob( info: bool = True, hold: bool = False, chunkify: bool = False, + page_counter: bool = False, prompt_screen: bool = False, page_limit: int | None = None, ) -> LayoutObj[UiResult]: diff --git a/core/src/trezor/ui/layouts/mercury/__init__.py b/core/src/trezor/ui/layouts/mercury/__init__.py index 578d6243e4..24e1ec1e74 100644 --- a/core/src/trezor/ui/layouts/mercury/__init__.py +++ b/core/src/trezor/ui/layouts/mercury/__init__.py @@ -486,6 +486,7 @@ def confirm_blob( info=False, hold=False, chunkify=chunkify, + page_counter=True, prompt_screen=False, )