diff --git a/core/.changelog.d/4023.fixed b/core/.changelog.d/4023.fixed new file mode 100644 index 000000000..87ceb7dfd --- /dev/null +++ b/core/.changelog.d/4023.fixed @@ -0,0 +1 @@ +[T3T1] Fixed title sometimes not fitting into result screen diff --git a/core/embed/rust/librust_qstr.h b/core/embed/rust/librust_qstr.h index b38c6e4ce..41a7ed006 100644 --- a/core/embed/rust/librust_qstr.h +++ b/core/embed/rust/librust_qstr.h @@ -771,6 +771,7 @@ static void _librust_qstrs(void) { MP_QSTR_words__sign; MP_QSTR_words__signer; MP_QSTR_words__title_check; + MP_QSTR_words__title_done; MP_QSTR_words__title_group; MP_QSTR_words__title_information; MP_QSTR_words__title_remember; diff --git a/core/embed/rust/src/translations/generated/translated_string.rs b/core/embed/rust/src/translations/generated/translated_string.rs index 6f56926ec..56a710899 100644 --- a/core/embed/rust/src/translations/generated/translated_string.rs +++ b/core/embed/rust/src/translations/generated/translated_string.rs @@ -1354,6 +1354,7 @@ pub enum TranslatedString { setting__apply = 953, // "Apply" brightness__changed_title = 954, // "Display brightness changed" brightness__change_title = 955, // "Change display brightness" + words__title_done = 956, // "Done" } impl TranslatedString { @@ -2702,6 +2703,7 @@ impl TranslatedString { Self::setting__apply => "Apply", Self::brightness__changed_title => "Display brightness changed", Self::brightness__change_title => "Change display brightness", + Self::words__title_done => "Done", } } @@ -4051,6 +4053,7 @@ impl TranslatedString { Qstr::MP_QSTR_setting__apply => Some(Self::setting__apply), Qstr::MP_QSTR_brightness__changed_title => Some(Self::brightness__changed_title), Qstr::MP_QSTR_brightness__change_title => Some(Self::brightness__change_title), + Qstr::MP_QSTR_words__title_done => Some(Self::words__title_done), _ => None, } } 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 2200c6a65..174d4f15f 100644 --- a/core/embed/rust/src/ui/model_mercury/component/frame.rs +++ b/core/embed/rust/src/ui/model_mercury/component/frame.rs @@ -1,3 +1,4 @@ +use super::{theme, ButtonMsg, ButtonStyleSheet, CancelInfoConfirmMsg, Footer, Header}; use crate::{ strutil::TString, ui::{ @@ -8,7 +9,7 @@ use crate::{ Event::Swipe, EventCtx, SwipeDetect, SwipeDirection, }, - display::Icon, + display::{Color, Icon}, event::SwipeEvent, geometry::{Alignment, Insets, Point, Rect}, lerp::Lerp, @@ -18,8 +19,6 @@ use crate::{ }, }; -use super::{theme, ButtonMsg, ButtonStyleSheet, CancelInfoConfirmMsg, Footer, Header}; - #[derive(Clone)] pub struct HorizontalSwipe { progress: i16, @@ -179,6 +178,11 @@ where self } + pub fn with_result_icon(mut self, icon: Icon, color: Color) -> Self { + self.header = self.header.with_result_icon(icon, color); + self + } + #[inline(never)] pub fn with_footer( mut self, diff --git a/core/embed/rust/src/ui/model_mercury/component/header.rs b/core/embed/rust/src/ui/model_mercury/component/header.rs index 9e6e7bfdb..af0e0ea14 100644 --- a/core/embed/rust/src/ui/model_mercury/component/header.rs +++ b/core/embed/rust/src/ui/model_mercury/component/header.rs @@ -1,18 +1,65 @@ use crate::{ strutil::TString, + time::{Duration, Stopwatch}, ui::{ component::{text::TextStyle, Component, Event, EventCtx, Label}, - display::Icon, - geometry::{Alignment, Insets, Rect}, + display::{Color, Icon}, + geometry::{Alignment, Alignment2D, Insets, Offset, Rect}, + lerp::Lerp, model_mercury::{ component::{Button, ButtonMsg, ButtonStyleSheet}, theme, theme::TITLE_HEIGHT, }, + shape, shape::Renderer, + util::animation_disabled, }, }; +const ANIMATION_TIME_MS: u32 = 1000; + +#[derive(Default, Clone)] +struct AttachAnimation { + pub timer: Stopwatch, +} + +impl AttachAnimation { + pub fn is_active(&self) -> bool { + if animation_disabled() { + return false; + } + + self.timer + .is_running_within(Duration::from_millis(ANIMATION_TIME_MS)) + } + + pub fn eval(&self) -> f32 { + if animation_disabled() { + return ANIMATION_TIME_MS as f32 / 1000.0; + } + self.timer.elapsed().to_millis() as f32 / 1000.0 + } + + pub fn get_title_offset(&self, t: f32) -> i16 { + let fnc = pareen::constant(0.0).seq_ease_in_out( + 0.8, + easer::functions::Cubic, + 0.2, + pareen::constant(1.0), + ); + i16::lerp(0, 25, fnc.eval(t)) + } + + pub fn start(&mut self) { + self.timer.start(); + } + + pub fn reset(&mut self) { + self.timer = Stopwatch::new_stopped(); + } +} + const BUTTON_EXPAND_BORDER: i16 = 32; #[derive(Clone)] pub struct Header { @@ -20,6 +67,10 @@ pub struct Header { title: Label<'static>, subtitle: Option>, button: Option