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 b3505298b60..12357637407 100644 --- a/core/embed/rust/src/ui/model_mercury/component/footer.rs +++ b/core/embed/rust/src/ui/model_mercury/component/footer.rs @@ -12,8 +12,6 @@ use crate::{ }, }; -use heapless::String; - /// Component showing a task instruction, e.g. "Swipe up", and an optional /// content consisting of one of these: /// - a task description e.g. "Confirm transaction", or @@ -94,6 +92,8 @@ impl<'a> Footer<'a> { if let Some(ref mut content) = self.content { if let Some(counter) = content.as_page_counter_mut() { counter.update_current_page(n); + self.swipe_allow_down = counter.is_first_page(); + self.swipe_allow_up = counter.is_last_page(); ctx.request_paint(); } else { #[cfg(feature = "ui_debug")] @@ -122,14 +122,6 @@ impl<'a> Footer<'a> { ..self } } - - pub fn set_swipe_up(&mut self, allow: bool) { - self.swipe_allow_up = allow; - } - - pub fn set_swipe_down(&mut self, allow: bool) { - self.swipe_allow_down = allow; - } } impl<'a> Component for Footer<'a> { @@ -292,9 +284,9 @@ impl<'a> FooterContent<'a> { #[derive(Clone)] struct PageCounter { area: Rect, + font: Font, page_curr: u8, page_max: u8, - font: Font, } impl PageCounter { @@ -308,7 +300,15 @@ impl PageCounter { } fn update_current_page(&mut self, new_value: u8) { - self.page_curr = new_value; + self.page_curr = new_value.clamp(1, self.page_max); + } + + fn is_first_page(&self) -> bool { + self.page_curr == 1 + } + + fn is_last_page(&self) -> bool { + self.page_curr == self.page_max } } diff --git a/core/embed/rust/src/ui/model_mercury/component/share_words.rs b/core/embed/rust/src/ui/model_mercury/component/share_words.rs index 4f1ae43abe4..a47f7b8d2a0 100644 --- a/core/embed/rust/src/ui/model_mercury/component/share_words.rs +++ b/core/embed/rust/src/ui/model_mercury/component/share_words.rs @@ -200,20 +200,16 @@ impl<'a> Component for ShareWordsInner<'a> { match event { Event::Attach(_) => { self.progress = 0; - self.footer.set_swipe_up(self.is_final_page()); - self.footer.set_swipe_down(self.is_first_page()); } Event::Swipe(SwipeEvent::End(dir)) => match dir { SwipeDirection::Up if !self.is_final_page() => { self.progress = 0; self.page_index = (self.page_index + 1).min(self.share_words.len() as i16 - 1); - self.footer.set_swipe_up(self.is_final_page()); ctx.request_paint(); } SwipeDirection::Down if !self.is_first_page() => { self.progress = 0; self.page_index = self.page_index.saturating_sub(1); - self.footer.set_swipe_down(self.is_first_page()); ctx.request_paint(); } _ => {} @@ -235,8 +231,6 @@ impl<'a> Component for ShareWordsInner<'a> { _ => {} } - self.footer.event(ctx, event); - None } @@ -303,11 +297,11 @@ impl<'a> Component for ShareWordsInner<'a> { impl InternallySwipable for ShareWords<'_> { fn current_page(&self) -> usize { - self.page_index as usize + self.frame.inner().page_index as usize } fn num_pages(&self) -> usize { - self.share_words.len() + self.frame.inner().share_words.len() } } 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 9e360a0fbb5..92094500830 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 @@ -10,10 +10,9 @@ use crate::{ text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt}, ButtonRequestExt, ComponentExt, SwipeDirection, }, - constant::screen, flow::{base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeFlow}, layout::obj::LayoutObj, - model_mercury::component::{Footer, InternallySwipableContent, SwipeContent}, + model_mercury::component::SwipeContent, }, }; use heapless::Vec;