From f2bdd6e189db101d06938dd390074d7d4ccb6bb7 Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Thu, 11 Jul 2024 16:14:55 +0200 Subject: [PATCH] fix(core/mercury): change status screen - display message in center after animation Because some messages didn't fit the title --- core/.changelog.d/4023.fixed | 1 + core/embed/rust/librust_qstr.h | 1 + .../generated/translated_string.rs | 3 + .../src/ui/model_mercury/component/frame.rs | 10 +- .../src/ui/model_mercury/component/header.rs | 120 +- .../model_mercury/component/status_screen.rs | 105 +- .../src/ui/model_mercury/flow/get_address.rs | 5 +- .../ui/model_mercury/flow/set_brightness.rs | 7 +- .../ui/model_mercury/flow/warning_hi_prio.rs | 11 +- .../embed/rust/src/ui/model_mercury/layout.rs | 13 +- core/mocks/trezortranslate_keys.pyi | 1 + core/translations/en.json | 1 + core/translations/order.json | 3 +- core/translations/signatures.json | 6 +- tests/ui_tests/fixtures.json | 1530 ++++++++--------- 15 files changed, 1005 insertions(+), 812 deletions(-) create mode 100644 core/.changelog.d/4023.fixed 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