From d48bae459833a4857da6e63529d1a2280703e79d Mon Sep 17 00:00:00 2001 From: grdddj Date: Fri, 21 Jul 2023 11:06:44 +0200 Subject: [PATCH] chore(core/rust): delete unused NotificationFrame [no changelog] --- .../rust/src/ui/model_tt/component/frame.rs | 88 +------------------ .../rust/src/ui/model_tt/component/mod.rs | 2 +- core/embed/rust/src/ui/model_tt/layout.rs | 16 +--- 3 files changed, 5 insertions(+), 101 deletions(-) diff --git a/core/embed/rust/src/ui/model_tt/component/frame.rs b/core/embed/rust/src/ui/model_tt/component/frame.rs index c641f6efef..ebd5aae12e 100644 --- a/core/embed/rust/src/ui/model_tt/component/frame.rs +++ b/core/embed/rust/src/ui/model_tt/component/frame.rs @@ -3,7 +3,7 @@ use crate::ui::{ component::{ base::ComponentExt, label::Label, text::TextStyle, Child, Component, Event, EventCtx, }, - display::{self, Color, Font, Icon}, + display::Icon, geometry::{Alignment, Insets, Offset, Rect}, model_tt::component::{Button, ButtonMsg, CancelInfoConfirmMsg}, }; @@ -196,89 +196,3 @@ where } } } - -pub struct NotificationFrame { - area: Rect, - title: U, - content: Child, -} - -impl NotificationFrame -where - T: Component, - U: AsRef, -{ - const HEIGHT: i16 = 36; - const COLOR: Color = theme::YELLOW; - const BORDER: i16 = 6; - - pub fn new(title: U, content: T) -> Self { - Self { - title, - area: Rect::zero(), - content: Child::new(content), - } - } - - pub fn inner(&self) -> &T { - self.content.inner() - } - - pub fn paint_notification(area: Rect, title: &str, color: Color) { - let (area, _) = area - .inset(Insets::uniform(Self::BORDER)) - .split_top(Self::HEIGHT); - let font = Font::BOLD; - display::rect_fill_rounded(area, color, theme::BG, 2); - display::text_center( - area.center() + Offset::y((font.text_max_height() - font.text_baseline()) / 2), - title, - font, - theme::FG, - color, - ); - } -} - -impl Component for NotificationFrame -where - T: Component, - U: AsRef, -{ - type Msg = T::Msg; - - fn place(&mut self, bounds: Rect) -> Rect { - let content_area = bounds.inset(theme::borders_notification()); - self.area = bounds; - self.content.place(content_area); - bounds - } - - fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option { - self.content.event(ctx, event) - } - - fn paint(&mut self) { - Self::paint_notification(self.area, self.title.as_ref(), Self::COLOR); - self.content.paint(); - } - - #[cfg(feature = "ui_bounds")] - fn bounds(&self, sink: &mut dyn FnMut(Rect)) { - sink(self.area); - self.content.bounds(sink); - } -} - -#[cfg(feature = "ui_debug")] -impl crate::trace::Trace for NotificationFrame -where - T: crate::trace::Trace, - U: AsRef, -{ - fn trace(&self, t: &mut dyn crate::trace::Tracer) { - t.component("NotificationFrame"); - t.string("title", self.title.as_ref()); - t.child("content", &self.content); - } -} diff --git a/core/embed/rust/src/ui/model_tt/component/mod.rs b/core/embed/rust/src/ui/model_tt/component/mod.rs index cccd165a12..21894eface 100644 --- a/core/embed/rust/src/ui/model_tt/component/mod.rs +++ b/core/embed/rust/src/ui/model_tt/component/mod.rs @@ -30,7 +30,7 @@ pub use coinjoin_progress::CoinJoinProgress; pub use dialog::{Dialog, DialogMsg, IconDialog}; pub use error::ErrorScreen; pub use fido::{FidoConfirm, FidoMsg}; -pub use frame::{Frame, FrameMsg, NotificationFrame}; +pub use frame::{Frame, FrameMsg}; pub use hold_to_confirm::{HoldToConfirm, HoldToConfirmMsg}; #[cfg(feature = "dma2d")] pub use homescreen::{Homescreen, HomescreenMsg, Lockscreen}; diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index 0610285248..e4b038f699 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -51,9 +51,9 @@ use super::{ CancelInfoConfirmMsg, CoinJoinProgress, Dialog, DialogMsg, FidoConfirm, FidoMsg, Frame, FrameMsg, HoldToConfirm, HoldToConfirmMsg, Homescreen, HomescreenMsg, HorizontalPage, IconDialog, Lockscreen, MnemonicInput, MnemonicKeyboard, MnemonicKeyboardMsg, - NotificationFrame, NumberInputDialog, NumberInputDialogMsg, PassphraseKeyboard, - PassphraseKeyboardMsg, PinKeyboard, PinKeyboardMsg, Progress, SelectWordCount, - SelectWordCountMsg, SelectWordMsg, Slip39Input, SwipeHoldPage, SwipePage, WelcomeScreen, + NumberInputDialog, NumberInputDialogMsg, PassphraseKeyboard, PassphraseKeyboardMsg, + PinKeyboard, PinKeyboardMsg, Progress, SelectWordCount, SelectWordCountMsg, SelectWordMsg, + Slip39Input, SwipeHoldPage, SwipePage, WelcomeScreen, }, constant, theme, }; @@ -208,16 +208,6 @@ where } } -impl ComponentMsgObj for NotificationFrame -where - T: ComponentMsgObj, - U: AsRef, -{ - fn msg_try_into_obj(&self, msg: Self::Msg) -> Result { - self.inner().msg_try_into_obj(msg) - } -} - impl ComponentMsgObj for SwipePage where T: Component + Paginate,