From 4d6af487f4b3e481afab15996a637190fdc28f6f Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Wed, 5 Jun 2024 00:27:48 +0200 Subject: [PATCH] fix(core/ui): T3T1: remove ButtonPage, Dialog, IconDialog [no changelog] --- core/embed/rust/src/ui/flow/page.rs | 4 +- .../src/ui/model_mercury/component/dialog.rs | 230 ----- .../src/ui/model_mercury/component/mod.rs | 9 - .../src/ui/model_mercury/component/page.rs | 852 ------------------ .../ui/model_mercury/component/simple_page.rs | 204 ----- .../ui/model_mercury/flow/confirm_action.rs | 2 +- .../embed/rust/src/ui/model_mercury/layout.rs | 476 +++------- .../src/ui/model_mercury/res/circle48.toif | Bin 264 -> 0 bytes .../src/ui/model_mercury/res/fg-check48.toif | Bin 84 -> 0 bytes .../rust/src/ui/model_mercury/theme/mod.rs | 15 - .../device_tests/bitcoin/test_signmessage.py | 1 + tests/device_tests/ethereum/test_signtx.py | 1 + tests/ui_tests/fixtures.json | 169 ++-- 13 files changed, 189 insertions(+), 1774 deletions(-) delete mode 100644 core/embed/rust/src/ui/model_mercury/component/dialog.rs delete mode 100644 core/embed/rust/src/ui/model_mercury/component/page.rs delete mode 100644 core/embed/rust/src/ui/model_mercury/component/simple_page.rs delete mode 100644 core/embed/rust/src/ui/model_mercury/res/circle48.toif delete mode 100644 core/embed/rust/src/ui/model_mercury/res/fg-check48.toif diff --git a/core/embed/rust/src/ui/flow/page.rs b/core/embed/rust/src/ui/flow/page.rs index f3be3a044b..247a0399b5 100644 --- a/core/embed/rust/src/ui/flow/page.rs +++ b/core/embed/rust/src/ui/flow/page.rs @@ -15,7 +15,7 @@ pub struct SwipePage { current: usize, } -impl SwipePage { +impl SwipePage { pub fn vertical(inner: T) -> Self { Self { inner, @@ -37,7 +37,7 @@ impl SwipePage { } } -impl Component for SwipePage { +impl Component for SwipePage { type Msg = T::Msg; fn place(&mut self, bounds: Rect) -> Rect { diff --git a/core/embed/rust/src/ui/model_mercury/component/dialog.rs b/core/embed/rust/src/ui/model_mercury/component/dialog.rs deleted file mode 100644 index 26e0221f5a..0000000000 --- a/core/embed/rust/src/ui/model_mercury/component/dialog.rs +++ /dev/null @@ -1,230 +0,0 @@ -use crate::{ - strutil::TString, - ui::{ - component::{ - image::BlendedImage, - text::{ - paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs, VecExt}, - TextStyle, - }, - Child, Component, Event, EventCtx, Never, - }, - geometry::{Insets, LinearPlacement, Rect}, - shape::Renderer, - }, -}; - -use super::theme; - -pub enum DialogMsg { - Content(T), - Controls(U), -} - -pub struct Dialog { - content: Child, - controls: Child, -} - -impl Dialog -where - T: Component, - U: Component, -{ - pub fn new(content: T, controls: U) -> Self { - Self { - content: Child::new(content), - controls: Child::new(controls), - } - } - - pub fn inner(&self) -> &T { - self.content.inner() - } -} - -impl Component for Dialog -where - T: Component, - U: Component, -{ - type Msg = DialogMsg; - - fn place(&mut self, bounds: Rect) -> Rect { - let controls_area = self.controls.place(bounds); - let content_area = bounds - .inset(Insets::bottom(controls_area.height())) - .inset(Insets::bottom(theme::BUTTON_SPACING)) - .inset(Insets::left(theme::CONTENT_BORDER)); - self.content.place(content_area); - bounds - } - - fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option { - self.content - .event(ctx, event) - .map(Self::Msg::Content) - .or_else(|| self.controls.event(ctx, event).map(Self::Msg::Controls)) - } - - fn paint(&mut self) { - self.content.paint(); - self.controls.paint(); - } - - fn render<'s>(&'s self, target: &mut impl Renderer<'s>) { - self.content.render(target); - self.controls.render(target); - } - - #[cfg(feature = "ui_bounds")] - fn bounds(&self, sink: &mut dyn FnMut(Rect)) { - self.content.bounds(sink); - self.controls.bounds(sink); - } -} - -#[cfg(feature = "ui_debug")] -impl crate::trace::Trace for Dialog -where - T: crate::trace::Trace, - U: crate::trace::Trace, -{ - fn trace(&self, t: &mut dyn crate::trace::Tracer) { - t.component("Dialog"); - t.child("content", &self.content); - t.child("controls", &self.controls); - } -} - -pub struct IconDialog { - image: Child, - paragraphs: Paragraphs>, - controls: Child, -} - -impl IconDialog -where - U: Component, -{ - pub fn new(icon: BlendedImage, title: impl Into>, controls: U) -> Self { - Self { - image: Child::new(icon), - paragraphs: Paragraphs::new(ParagraphVecShort::from_iter([Paragraph::new( - &theme::TEXT_DEMIBOLD, - title, - ) - .centered()])) - .with_placement( - LinearPlacement::vertical() - .align_at_center() - .with_spacing(Self::VALUE_SPACE), - ), - controls: Child::new(controls), - } - } - - pub fn with_paragraph(mut self, para: Paragraph<'static>) -> Self { - if !para.content().is_empty() { - self.paragraphs.inner_mut().add(para); - } - self - } - - pub fn with_text(self, style: &'static TextStyle, text: impl Into>) -> Self { - self.with_paragraph(Paragraph::new(style, text).centered()) - } - - pub fn with_description(self, description: impl Into>) -> Self { - self.with_text(&theme::TEXT_NORMAL_GREY_EXTRA_LIGHT, description) - } - - pub fn with_value(self, value: impl Into>) -> Self { - self.with_text(&theme::TEXT_MONO, value) - } - - pub fn new_shares(lines: [impl Into>; 4], controls: U) -> Self { - let [l0, l1, l2, l3] = lines; - Self { - image: Child::new(BlendedImage::new( - theme::IMAGE_BG_CIRCLE, - theme::IMAGE_FG_SUCCESS, - theme::SUCCESS_COLOR, - theme::FG, - theme::BG, - )), - paragraphs: ParagraphVecShort::from_iter([ - Paragraph::new(&theme::TEXT_NORMAL_GREY_EXTRA_LIGHT, l0).centered(), - Paragraph::new(&theme::TEXT_DEMIBOLD, l1).centered(), - Paragraph::new(&theme::TEXT_NORMAL_GREY_EXTRA_LIGHT, l2).centered(), - Paragraph::new(&theme::TEXT_DEMIBOLD, l3).centered(), - ]) - .into_paragraphs() - .with_placement(LinearPlacement::vertical().align_at_center()), - controls: Child::new(controls), - } - } - - pub const ICON_AREA_PADDING: i16 = 2; - pub const ICON_AREA_HEIGHT: i16 = 60; - pub const VALUE_SPACE: i16 = 5; -} - -impl Component for IconDialog -where - U: Component, -{ - type Msg = DialogMsg; - - fn place(&mut self, bounds: Rect) -> Rect { - let bounds = bounds - .inset(theme::borders()) - .inset(Insets::top(Self::ICON_AREA_PADDING)); - - let controls_area = self.controls.place(bounds); - let content_area = bounds.inset(Insets::bottom(controls_area.height())); - - let (image_area, content_area) = content_area.split_top(Self::ICON_AREA_HEIGHT); - - self.image.place(image_area); - self.paragraphs.place(content_area); - bounds - } - - fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option { - self.paragraphs.event(ctx, event); - self.controls.event(ctx, event).map(Self::Msg::Controls) - } - - fn paint(&mut self) { - self.image.paint(); - self.paragraphs.paint(); - self.controls.paint(); - } - - fn render<'s>(&'s self, target: &mut impl Renderer<'s>) { - self.image.render(target); - self.paragraphs.render(target); - self.controls.render(target); - } - - #[cfg(feature = "ui_bounds")] - fn bounds(&self, sink: &mut dyn FnMut(Rect)) { - self.image.bounds(sink); - self.paragraphs.bounds(sink); - self.controls.bounds(sink); - } -} - -#[cfg(feature = "ui_debug")] -impl crate::trace::Trace for IconDialog -where - U: crate::trace::Trace, -{ - fn trace(&self, t: &mut dyn crate::trace::Tracer) { - t.component("IconDialog"); - t.child("image", &self.image); - t.child("content", &self.paragraphs); - t.child("controls", &self.controls); - } -} diff --git a/core/embed/rust/src/ui/model_mercury/component/mod.rs b/core/embed/rust/src/ui/model_mercury/component/mod.rs index a1e7acc4d6..760367fa02 100644 --- a/core/embed/rust/src/ui/model_mercury/component/mod.rs +++ b/core/embed/rust/src/ui/model_mercury/component/mod.rs @@ -4,7 +4,6 @@ pub mod bl_confirm; mod button; #[cfg(feature = "translations")] mod coinjoin_progress; -mod dialog; mod fido; mod footer; mod vertical_menu; @@ -12,7 +11,6 @@ mod vertical_menu; mod fido_icons; mod error; mod frame; - #[cfg(feature = "translations")] mod hold_to_confirm; #[cfg(feature = "translations")] @@ -23,8 +21,6 @@ mod loader; #[cfg(feature = "translations")] mod number_input; pub mod number_input_slider; -#[cfg(feature = "translations")] -mod page; mod progress; #[cfg(feature = "translations")] mod prompt_screen; @@ -34,7 +30,6 @@ mod scroll; mod set_brightness; #[cfg(feature = "translations")] mod share_words; -mod simple_page; mod status_screen; mod swipe_content; #[cfg(feature = "translations")] @@ -51,7 +46,6 @@ pub use button::{ }; #[cfg(feature = "translations")] pub use coinjoin_progress::CoinJoinProgress; -pub use dialog::{Dialog, DialogMsg, IconDialog}; pub use error::ErrorScreen; pub use fido::{FidoConfirm, FidoMsg}; pub use footer::Footer; @@ -74,8 +68,6 @@ pub use loader::{Loader, LoaderMsg, LoaderStyle, LoaderStyleSheet}; pub use number_input::{NumberInputDialog, NumberInputDialogMsg}; #[cfg(feature = "translations")] pub use number_input_slider::NumberInputSliderDialog; -#[cfg(feature = "translations")] -pub use page::ButtonPage; pub use progress::Progress; #[cfg(feature = "translations")] pub use prompt_screen::PromptScreen; @@ -85,7 +77,6 @@ pub use scroll::ScrollBar; pub use set_brightness::SetBrightnessDialog; #[cfg(feature = "translations")] pub use share_words::ShareWords; -pub use simple_page::SimplePage; pub use status_screen::StatusScreen; pub use swipe_content::SwipeContent; #[cfg(feature = "translations")] diff --git a/core/embed/rust/src/ui/model_mercury/component/page.rs b/core/embed/rust/src/ui/model_mercury/component/page.rs deleted file mode 100644 index 4ab4b07178..0000000000 --- a/core/embed/rust/src/ui/model_mercury/component/page.rs +++ /dev/null @@ -1,852 +0,0 @@ -use crate::{ - error::Error, - strutil::TString, - time::Instant, - translations::TR, - ui::{ - component::{ - paginated::PageMsg, Component, ComponentExt, Event, EventCtx, Pad, Paginate, Swipe, - SwipeDirection, - }, - constant, - display::{self, Color}, - geometry::{Insets, Rect}, - shape::Renderer, - util::animation_disabled, - }, -}; - -use super::{ - theme, Button, ButtonContent, ButtonMsg, ButtonStyleSheet, Loader, LoaderMsg, ScrollBar, -}; - -use core::cell::Cell; - -/// Allows pagination of inner component. Shows scroll bar, confirm & cancel -/// buttons. Optionally handles hold-to-confirm with loader. -pub struct ButtonPage { - /// Inner component. - content: T, - /// Cleared when page changes. - pad: Pad, - /// Swipe controller. - swipe: Swipe, - scrollbar: ScrollBar, - /// Hold-to-confirm mode whenever this is `Some(loader)`. - loader: Option, - button_cancel: Option