From 7dd41dfeb74ff0f570a3884ce9e968c00303a867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ioan=20Biz=C4=83u?= Date: Mon, 10 Feb 2025 17:44:03 +0100 Subject: [PATCH] chore(core): middle button to confirm on TS3 --- .../src/ui/layout_caesar/component/page.rs | 39 +++++++++++-------- .../rust/src/ui/layout_caesar/ui_firmware.rs | 23 ++++------- core/src/apps/ethereum/layout.py | 1 - 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/core/embed/rust/src/ui/layout_caesar/component/page.rs b/core/embed/rust/src/ui/layout_caesar/component/page.rs index 464a89547f4..af75ba94d6c 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/page.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/page.rs @@ -23,6 +23,7 @@ where pad: Pad, cancel_btn_details: Option, confirm_btn_details: Option, + middle_confirm: bool, back_btn_details: Option, next_btn_details: Option, buttons: Child, @@ -40,6 +41,7 @@ where pad: Pad::with_background(background).with_clear(), cancel_btn_details: Some(ButtonDetails::cancel_icon()), confirm_btn_details: Some(ButtonDetails::text(TR::buttons__confirm.into())), + middle_confirm: false, back_btn_details: Some(ButtonDetails::up_arrow_icon()), next_btn_details: Some(ButtonDetails::down_arrow_icon_wide()), // Setting empty layout for now, we do not yet know the page count. @@ -59,6 +61,14 @@ where self } + pub fn with_middle_confirm(mut self, middle_confirm: bool) -> Self { + self.middle_confirm = middle_confirm; + self.confirm_btn_details = + self.confirm_btn_details + .map(|btn| if middle_confirm { btn.with_arms() } else { btn }); + self + } + pub fn with_back_btn(mut self, btn_details: Option) -> Self { self.back_btn_details = btn_details; self @@ -114,25 +124,17 @@ where } fn get_button_layout(&self, has_prev: bool, has_next: bool) -> ButtonLayout { - let btn_left = self.get_left_button_details(!has_prev); - let btn_right = self.get_right_button_details(has_next); - ButtonLayout::new(btn_left, None, btn_right) - } - - fn get_left_button_details(&self, is_first: bool) -> Option { - if is_first { + let btn_left = if !has_prev { self.cancel_btn_details.clone() } else { self.back_btn_details.clone() - } - } - - fn get_right_button_details(&self, has_next_page: bool) -> Option { - if has_next_page { - self.next_btn_details.clone() - } else { - self.confirm_btn_details.clone() - } + }; + let (btn_middle, btn_right) = match (has_next, self.middle_confirm) { + (true, _) => (None, self.next_btn_details.clone()), + (false, true) => (self.confirm_btn_details.clone(), None), + (false, false) => (None, self.confirm_btn_details.clone()), + }; + ButtonLayout::new(btn_left, btn_middle, btn_right) } } @@ -186,6 +188,10 @@ where return None; } } + ButtonPos::Middle => { + // Clicked CONFIRM. Send result. + return Some(PageMsg::Confirmed); + } ButtonPos::Right => { if self.has_next_page() { // Clicked NEXT. Scroll down. @@ -196,7 +202,6 @@ where return Some(PageMsg::Confirmed); } } - _ => {} } } diff --git a/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs index d6f8393e242..d42e538a80a 100644 --- a/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs @@ -77,7 +77,7 @@ impl FirmwareUI for UICaesar { content_in_button_page( title, paragraphs, - verb.unwrap_or(TString::empty()), + verb.unwrap_or(TR::buttons__confirm.into()), verb_cancel, hold, ) @@ -210,7 +210,7 @@ impl FirmwareUI for UICaesar { content_in_button_page( TR::coinjoin__title.into(), paragraphs, - TR::buttons__hold_to_confirm.into(), + TR::buttons__confirm.into(), None, true, ) @@ -405,7 +405,7 @@ impl FirmwareUI for UICaesar { paragraphs.into_paragraphs(), button, Some("<".into()), - false, + true, ) } @@ -444,16 +444,11 @@ impl FirmwareUI for UICaesar { paragraphs.add(Paragraph::new(style, value)); } } - let button_text = if hold { - TR::buttons__hold_to_confirm.into() - } else { - TR::buttons__confirm.into() - }; content_in_button_page( title, paragraphs.into_paragraphs(), - button_text, + TR::buttons__confirm.into(), Some("".into()), hold, ) @@ -1296,20 +1291,16 @@ fn content_in_button_page( // Left button - icon, text or nothing. let cancel_btn = verb_cancel.map(ButtonDetails::from_text_possible_icon); - // Right button - text or nothing. - // Optional HoldToConfirm - let mut confirm_btn = if !verb.is_empty() { + let confirm_btn = if !verb.is_empty() { Some(ButtonDetails::text(verb)) } else { None }; - if hold { - confirm_btn = confirm_btn.map(|btn| btn.with_default_duration()); - } let content = ButtonPage::new(content, theme::BG) .with_cancel_btn(cancel_btn) - .with_confirm_btn(confirm_btn); + .with_confirm_btn(confirm_btn) + .with_middle_confirm(hold); let mut frame = ScrollableFrame::new(content); if !title.is_empty() { diff --git a/core/src/apps/ethereum/layout.py b/core/src/apps/ethereum/layout.py index f4e97651fd6..5004f3339d7 100644 --- a/core/src/apps/ethereum/layout.py +++ b/core/src/apps/ethereum/layout.py @@ -195,7 +195,6 @@ async def confirm_typed_data_final() -> None: "confirm_typed_data_final", TR.ethereum__title_confirm_typed_data, TR.ethereum__sign_eip712, - verb=TR.buttons__hold_to_confirm, hold=True, )