diff --git a/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs b/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs index 81d463b5f4..1a520c08bb 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs @@ -20,10 +20,7 @@ use crate::{ }; use super::super::{ - component::{ - Footer, Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, - VerticalMenuChoiceMsg, - }, + component::{Footer, Frame, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg}, theme, }; @@ -314,11 +311,7 @@ fn new_confirm_action_uni( } let content = content - .map(move |msg| match msg { - FrameMsg::Button(FlowMsg::Info) => Some(FlowMsg::Info), - FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), - _ => None, - }) + .map_to_button_msg() .with_pages(move |intro_pages| intro_pages + prompt_pages); let flow = flow?.with_page(page, content)?; @@ -378,11 +371,10 @@ fn create_menu( .with_swipe(Direction::Right, SwipeSettings::immediate()); let content_menu = content_menu.map(move |msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => { + VerticalMenuChoiceMsg::Selected(i) => { let selected_item = menu_items[i]; Some(FlowMsg::Choice(selected_item)) } - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), }); if prompt_screen.is_some() { @@ -429,11 +421,7 @@ fn create_confirm( content_confirm = content_confirm.with_subtitle(subtitle); } - let content_confirm = content_confirm.map(move |msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(_) => Some(FlowMsg::Info), - _ => None, - }); + let content_confirm = content_confirm.map(super::util::map_to_confirm); flow.with_page( &ConfirmActionWithMenuAndConfirmation::Confirmation, diff --git a/core/embed/rust/src/ui/layout_delizia/flow/confirm_fido.rs b/core/embed/rust/src/ui/layout_delizia/flow/confirm_fido.rs index 5a6be5d9b6..000569fdca 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/confirm_fido.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/confirm_fido.rs @@ -8,7 +8,7 @@ use crate::{ paginated::PaginateFull as _, swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, Paragraphs}, - ComponentExt, EventCtx, + EventCtx, }, flow::{ base::{Decision, DecisionBuilder as _}, @@ -20,8 +20,7 @@ use crate::{ use super::super::{ component::{ - FidoCredential, Footer, Frame, FrameMsg, PagedVerticalMenu, PromptMsg, PromptScreen, - SwipeContent, VerticalMenu, VerticalMenuChoiceMsg, + FidoCredential, Footer, Frame, PagedVerticalMenu, PromptScreen, SwipeContent, VerticalMenu, }, theme, }; @@ -122,7 +121,7 @@ pub fn new_confirm_fido( .with_footer(TR::instructions__swipe_up.into(), None) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)); + .map_to_button_msg(); // Closure to lazy-load the information on given page index. // Done like this to allow arbitrarily many pages without @@ -153,10 +152,7 @@ pub fn new_confirm_fido( .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Right, SwipeSettings::immediate()) .with_vertical_pages() - .map(|msg| match msg { - FrameMsg::Button(_) => Some(FlowMsg::Info), - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - }); + .map(super::util::map_to_choice); let get_account = move || { let current = CRED_SELECTED.load(Ordering::Relaxed); @@ -175,21 +171,14 @@ pub fn new_confirm_fido( } else { content_details.with_cancel_button() } - .map(|msg| match msg { - FrameMsg::Button(bm) => Some(bm), - _ => None, - }); + .map_to_button_msg(); let content_tap = Frame::left_aligned(title, PromptScreen::new_tap_to_confirm()) .with_menu_button() .with_footer(TR::instructions__tap_to_confirm.into(), None) .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(_) => Some(FlowMsg::Info), - _ => None, - }); + .map(super::util::map_to_confirm); let content_menu = Frame::left_aligned( "".into(), @@ -197,10 +186,7 @@ pub fn new_confirm_fido( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); let initial_page = if single_cred() { &ConfirmFido::Details diff --git a/core/embed/rust/src/ui/layout_delizia/flow/confirm_firmware_update.rs b/core/embed/rust/src/ui/layout_delizia/flow/confirm_firmware_update.rs index 721d2a48ac..ce1cb0c1dc 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/confirm_firmware_update.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/confirm_firmware_update.rs @@ -6,7 +6,6 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, Paragraphs}, - ComponentExt, }, flow::{ base::{Decision, DecisionBuilder as _}, @@ -17,9 +16,7 @@ use crate::{ }; use super::super::{ - component::{ - Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg, - }, + component::{Frame, PromptScreen, SwipeContent, VerticalMenu}, theme, }; @@ -76,7 +73,7 @@ pub fn new_confirm_firmware_update( .with_footer(TR::instructions__swipe_up.into(), None) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| matches!(msg, FrameMsg::Button(FlowMsg::Info)).then_some(FlowMsg::Info)); + .map_to_button_msg(); let content_menu = Frame::left_aligned( TString::empty(), @@ -89,10 +86,7 @@ pub fn new_confirm_firmware_update( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); let paragraphs_fingerprint = Paragraphs::new(Paragraph::new(&theme::TEXT_MONO_GREY_LIGHT, fingerprint)); @@ -102,7 +96,7 @@ pub fn new_confirm_firmware_update( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::default()) - .map(|msg| matches!(msg, FrameMsg::Button(FlowMsg::Cancelled)).then_some(FlowMsg::Cancelled)); + .map_to_button_msg(); let content_confirm = Frame::left_aligned( TR::firmware_update__title.into(), @@ -112,11 +106,7 @@ pub fn new_confirm_firmware_update( .with_footer(TR::instructions__hold_to_confirm.into(), None) .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(_) => Some(FlowMsg::Info), - _ => None, - }); + .map(super::util::map_to_confirm); let res = SwipeFlow::new(&ConfirmFirmwareUpdate::Intro)? .with_page(&ConfirmFirmwareUpdate::Intro, content_intro)? diff --git a/core/embed/rust/src/ui/layout_delizia/flow/confirm_homescreen.rs b/core/embed/rust/src/ui/layout_delizia/flow/confirm_homescreen.rs index 044e4f6404..fb885242d3 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/confirm_homescreen.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/confirm_homescreen.rs @@ -13,9 +13,7 @@ use crate::{ }; use super::super::{ - component::{ - Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg, - }, + component::{Frame, PromptScreen, SwipeContent, VerticalMenu}, theme, }; @@ -68,12 +66,9 @@ pub fn new_confirm_homescreen( Some(TR::buttons__change.into()), ) .with_swipe(Direction::Up, SwipeSettings::default()) + .map_to_button_msg() // Homescreen + Tap to confirm - .with_pages(|_| 2) - .map(|msg| match msg { - FrameMsg::Button(_) => Some(FlowMsg::Info), - _ => None, - }); + .with_pages(|_| 2); let content_menu = Frame::left_aligned( TString::empty(), @@ -81,10 +76,7 @@ pub fn new_confirm_homescreen( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); let content_confirm = Frame::left_aligned( TR::homescreen__title_set.into(), @@ -94,11 +86,7 @@ pub fn new_confirm_homescreen( .with_footer(TR::instructions__tap_to_confirm.into(), None) .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(_) => Some(FlowMsg::Info), - _ => None, - }); + .map(super::util::map_to_confirm); let res = SwipeFlow::new(&ConfirmHomescreen::Homescreen)? .with_page(&ConfirmHomescreen::Homescreen, content_homescreen)? diff --git a/core/embed/rust/src/ui/layout_delizia/flow/confirm_output.rs b/core/embed/rust/src/ui/layout_delizia/flow/confirm_output.rs index 96354f7b79..e09870392c 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/confirm_output.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/confirm_output.rs @@ -212,11 +212,7 @@ fn get_cancel_page( .with_cancel_button() .with_footer(TR::instructions__tap_to_confirm.into(), None) .with_swipe(Direction::Right, SwipeSettings::default()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - _ => None, - }) + .map(super::util::map_to_confirm) } #[allow(clippy::too_many_arguments)] @@ -263,11 +259,10 @@ pub fn new_confirm_output( .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(move |msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => { + VerticalMenuChoiceMsg::Selected(i) => { let selected_item = main_menu_items[i]; Some(FlowMsg::Choice(selected_item)) } - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), }); // AccountInfo @@ -304,11 +299,7 @@ pub fn new_confirm_output( .with_footer(TR::instructions__hold_to_sign.into(), None) .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(_) => Some(FlowMsg::Info), - _ => None, - }); + .map(super::util::map_to_confirm); // FeeInfo let has_fee_info = !fee_items_params.is_empty(); @@ -337,11 +328,10 @@ pub fn new_confirm_output( .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(move |msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => { + VerticalMenuChoiceMsg::Selected(i) => { let selected_item = summary_menu_items[i]; Some(FlowMsg::Choice(selected_item)) } - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), }); // HoldMenu @@ -352,12 +342,7 @@ pub fn new_confirm_output( let content_hold_menu = Frame::left_aligned(TString::empty(), hold_menu) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(move |msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(_)) => { - Some(FlowMsg::Choice(MENU_ITEM_CANCEL)) - } - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); let mut flow = SwipeFlow::new(&ConfirmOutputWithSummary::Main)? .with_page(&ConfirmOutputWithSummary::Main, main_content)? diff --git a/core/embed/rust/src/ui/layout_delizia/flow/confirm_reset.rs b/core/embed/rust/src/ui/layout_delizia/flow/confirm_reset.rs index a107920d38..dc8c2ce7e0 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/confirm_reset.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/confirm_reset.rs @@ -7,7 +7,7 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort}, - ButtonRequestExt, ComponentExt, + ButtonRequestExt, }, flow::{ base::{Decision, DecisionBuilder as _}, @@ -18,9 +18,7 @@ use crate::{ }; use super::super::{ - component::{ - Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg, - }, + component::{Frame, PromptScreen, SwipeContent, VerticalMenu}, theme, }; @@ -118,7 +116,7 @@ pub fn new_confirm_reset(recovery: bool) -> Result { .with_footer(TR::instructions__swipe_up.into(), None) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)) + .map_to_button_msg() .one_button_request(br); let content_menu = Frame::left_aligned( @@ -127,10 +125,7 @@ pub fn new_confirm_reset(recovery: bool) -> Result { ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); let res = if recovery { SwipeFlow::new(&ConfirmResetRecover::Intro)? @@ -145,11 +140,7 @@ pub fn new_confirm_reset(recovery: bool) -> Result { .with_footer(TR::instructions__hold_to_confirm.into(), None) .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(_) => Some(FlowMsg::Info), - _ => None, - }) + .map(super::util::map_to_confirm) .one_button_request(ButtonRequestCode::ResetDevice.with_name("confirm_setup_device")); SwipeFlow::new(&ConfirmResetCreate::Intro)? diff --git a/core/embed/rust/src/ui/layout_delizia/flow/confirm_set_new_pin.rs b/core/embed/rust/src/ui/layout_delizia/flow/confirm_set_new_pin.rs index 60fc72acab..548df32301 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/confirm_set_new_pin.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/confirm_set_new_pin.rs @@ -6,7 +6,6 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs}, - ComponentExt, }, flow::{ base::{Decision, DecisionBuilder as _}, @@ -17,9 +16,7 @@ use crate::{ }; use super::super::{ - component::{ - Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg, - }, + component::{Frame, PromptScreen, SwipeContent, VerticalMenu}, theme, }; @@ -74,10 +71,7 @@ pub fn new_set_new_pin( .with_footer(TR::instructions__swipe_up.into(), None) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| match msg { - FrameMsg::Button(bm) => Some(bm), - _ => None, - }); + .map_to_button_msg(); let content_menu = Frame::left_aligned( "".into(), @@ -85,11 +79,7 @@ pub fn new_set_new_pin( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), - FrameMsg::Button(_) => None, - }); + .map(super::util::map_to_choice); let paragraphs_cancel_intro = ParagraphVecShort::from_iter([ Paragraph::new(&theme::TEXT_WARNING, TR::words__not_recommended), @@ -107,10 +97,7 @@ pub fn new_set_new_pin( ) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Button(bm) => Some(bm), - _ => None, - }); + .map_to_button_msg(); let content_cancel_confirm = Frame::left_aligned( TR::pin__cancel_setup.into(), @@ -120,11 +107,7 @@ pub fn new_set_new_pin( .with_footer(TR::instructions__tap_to_confirm.into(), None) .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), - _ => None, - }); + .map(super::util::map_to_confirm); let res = SwipeFlow::new(&SetNewPin::Intro)? .with_page(&SetNewPin::Intro, content_intro)? diff --git a/core/embed/rust/src/ui/layout_delizia/flow/confirm_summary.rs b/core/embed/rust/src/ui/layout_delizia/flow/confirm_summary.rs index 689b9cba74..10f9812fd8 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/confirm_summary.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/confirm_summary.rs @@ -17,10 +17,7 @@ use crate::{ use super::{ super::{ - component::{ - Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, - VerticalMenuChoiceMsg, - }, + component::{Frame, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg}, theme, }, util::ShowInfoParams, @@ -100,11 +97,7 @@ pub fn new_confirm_summary( .with_footer(TR::instructions__hold_to_sign.into(), None) .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(_) => Some(FlowMsg::Info), - _ => None, - }); + .map(super::util::map_to_confirm); // ExtraInfo let content_extra = extra_params @@ -141,11 +134,10 @@ pub fn new_confirm_summary( .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) .map(move |msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => { + VerticalMenuChoiceMsg::Selected(i) => { let selected_item = menu_items[i]; Some(FlowMsg::Choice(selected_item)) } - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), }); // CancelTap @@ -156,11 +148,7 @@ pub fn new_confirm_summary( .with_cancel_button() .with_footer(TR::instructions__tap_to_confirm.into(), None) .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - _ => None, - }); + .map(super::util::map_to_confirm); let mut res = SwipeFlow::new(&ConfirmSummary::Summary)? .with_page(&ConfirmSummary::Summary, content_summary)? diff --git a/core/embed/rust/src/ui/layout_delizia/flow/continue_recovery_homepage.rs b/core/embed/rust/src/ui/layout_delizia/flow/continue_recovery_homepage.rs index 889869da5e..392b7416a5 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/continue_recovery_homepage.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/continue_recovery_homepage.rs @@ -22,10 +22,7 @@ use crate::{ }; use super::super::{ - component::{ - Footer, Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, - VerticalMenuChoiceMsg, - }, + component::{Footer, Frame, PromptScreen, SwipeContent, VerticalMenu}, theme, }; @@ -198,7 +195,7 @@ pub fn new_continue_recovery_homepage( .with_footer(footer_instruction, footer_description) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)) + .map_to_button_msg() .repeated_button_request(ButtonRequest::new( ButtonRequestCode::RecoveryHomepage, "recovery".into(), @@ -219,10 +216,7 @@ pub fn new_continue_recovery_homepage( ) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), - _ => None, - }) + .map_to_button_msg() .repeated_button_request(ButtonRequest::new( ButtonRequestCode::ProtectCall, "abort_recovery".into(), @@ -236,11 +230,7 @@ pub fn new_continue_recovery_homepage( .with_footer(TR::instructions__tap_to_confirm.into(), None) .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), - _ => None, - }); + .map(super::util::map_to_confirm); let res = if show_instructions { let content_menu = Frame::left_aligned( @@ -249,10 +239,7 @@ pub fn new_continue_recovery_homepage( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); SwipeFlow::new(&ContinueRecoveryBeforeShares::Main)? .with_page(&ContinueRecoveryBeforeShares::Main, content_main)? @@ -264,10 +251,7 @@ pub fn new_continue_recovery_homepage( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); SwipeFlow::new(&ContinueRecoveryBetweenShares::Main)? .with_page(&ContinueRecoveryBetweenShares::Main, content_main)? @@ -292,10 +276,7 @@ pub fn new_continue_recovery_homepage( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); let (footer_instruction, footer_description) = ( TR::instructions__swipe_up.into(), @@ -317,7 +298,7 @@ pub fn new_continue_recovery_homepage( .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) .with_vertical_pages() - .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled)) + .map_to_button_msg() .repeated_button_request(ButtonRequest::new( ButtonRequestCode::Other, "show_shares".into(), diff --git a/core/embed/rust/src/ui/layout_delizia/flow/get_address.rs b/core/embed/rust/src/ui/layout_delizia/flow/get_address.rs index 260224c24c..5fff53d710 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/get_address.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/get_address.rs @@ -20,10 +20,7 @@ use crate::{ }; use super::super::{ - component::{ - AddressDetails, Frame, FrameMsg, PromptMsg, PromptScreen, StatusScreen, SwipeContent, - VerticalMenu, VerticalMenuChoiceMsg, - }, + component::{AddressDetails, Frame, PromptScreen, StatusScreen, SwipeContent, VerticalMenu}, theme, }; @@ -122,7 +119,7 @@ pub fn new_get_address( .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) .with_vertical_pages() - .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)) + .map_to_button_msg() .one_button_request(ButtonRequest::from_num(br_code, br_name)) // Count tap-to-confirm screen towards page count .with_pages(|address_pages| address_pages + 1); @@ -133,11 +130,7 @@ pub fn new_get_address( .with_footer(TR::instructions__tap_to_confirm.into(), None) .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(_) => Some(FlowMsg::Info), - _ => None, - }); + .map(super::util::map_to_confirm); let content_confirmed = Frame::left_aligned( TR::words__title_success.into(), @@ -160,10 +153,7 @@ pub fn new_get_address( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); // QrCode let content_qr = Frame::left_aligned( @@ -174,7 +164,7 @@ pub fn new_get_address( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled)); + .map_to_button_msg(); // AccountInfo let mut ad = AddressDetails::new(TR::address_details__account_info.into(), account, path)?; @@ -196,7 +186,7 @@ pub fn new_get_address( .with_footer(TR::instructions__swipe_up.into(), None) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled)); + .map_to_button_msg(); // CancelTap let content_cancel_tap = Frame::left_aligned( @@ -207,11 +197,7 @@ pub fn new_get_address( .with_footer(TR::instructions__tap_to_confirm.into(), None) .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), - _ => None, - }); + .map(super::util::map_to_confirm); let res = SwipeFlow::new(&GetAddress::Address)? .with_page(&GetAddress::Address, content_address)? diff --git a/core/embed/rust/src/ui/layout_delizia/flow/prompt_backup.rs b/core/embed/rust/src/ui/layout_delizia/flow/prompt_backup.rs index a8fa783782..d618e242bc 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/prompt_backup.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/prompt_backup.rs @@ -6,7 +6,6 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs}, - ComponentExt, }, flow::{ base::{Decision, DecisionBuilder as _}, @@ -17,9 +16,7 @@ use crate::{ }; use super::super::{ - component::{ - Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg, - }, + component::{Frame, PromptScreen, SwipeContent, VerticalMenu}, theme, }; @@ -73,10 +70,7 @@ pub fn new_prompt_backup() -> Result { .with_footer(TR::instructions__swipe_up.into(), None) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| match msg { - FrameMsg::Button(bm) => Some(bm), - _ => None, - }); + .map_to_button_msg(); let content_menu = Frame::left_aligned( "".into(), @@ -84,11 +78,7 @@ pub fn new_prompt_backup() -> Result { ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), - FrameMsg::Button(_) => None, - }); + .map(super::util::map_to_choice); let paragraphs_skip_intro = ParagraphVecShort::from_iter([ Paragraph::new(&theme::TEXT_WARNING, TR::words__not_recommended), @@ -109,10 +99,7 @@ pub fn new_prompt_backup() -> Result { ) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), - _ => None, - }); + .map_to_button_msg(); let content_skip_confirm = Frame::left_aligned( TR::backup__title_skip.into(), @@ -122,11 +109,7 @@ pub fn new_prompt_backup() -> Result { .with_footer(TR::instructions__tap_to_confirm.into(), None) .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), - _ => None, - }); + .map(super::util::map_to_confirm); let res = SwipeFlow::new(&PromptBackup::Intro)? .with_page(&PromptBackup::Intro, content_intro)? diff --git a/core/embed/rust/src/ui/layout_delizia/flow/request_number.rs b/core/embed/rust/src/ui/layout_delizia/flow/request_number.rs index 54160f838b..7a7496c8c9 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/request_number.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/request_number.rs @@ -3,7 +3,7 @@ use crate::{ strutil::TString, translations::TR, ui::{ - component::{swipe_detect::SwipeSettings, ComponentExt}, + component::swipe_detect::SwipeSettings, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, FlowMsg, SwipeFlow, @@ -16,8 +16,8 @@ use core::sync::atomic::{AtomicU16, Ordering}; use super::super::{ component::{ - Frame, FrameMsg, NumberInputDialog, NumberInputDialogMsg, SwipeContent, UpdatableMoreInfo, - VerticalMenu, VerticalMenuChoiceMsg, + Frame, NumberInputDialog, NumberInputDialogMsg, SwipeContent, UpdatableMoreInfo, + VerticalMenu, }, theme, }; @@ -82,12 +82,11 @@ pub fn new_request_number( .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| match msg { - FrameMsg::Button(_) => Some(FlowMsg::Info), - FrameMsg::Content(NumberInputDialogMsg::Changed(n)) => { + NumberInputDialogMsg::Changed(n) => { NUM_DISPLAYED.store(n as u16, Ordering::Relaxed); None } - FrameMsg::Content(NumberInputDialogMsg::Confirmed(n)) => { + NumberInputDialogMsg::Confirmed(n) => { NUM_DISPLAYED.store(n as u16, Ordering::Relaxed); Some(FlowMsg::Choice(n as usize)) } @@ -99,20 +98,13 @@ pub fn new_request_number( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), - FrameMsg::Button(_) => None, - }); + .map(super::util::map_to_choice); let updatable_info = UpdatableMoreInfo::new(info_closure); let content_info = Frame::left_aligned(TString::empty(), SwipeContent::new(updatable_info)) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), - _ => None, - }); + .map_to_button_msg(); let res = SwipeFlow::new(&RequestNumber::Number)? .with_page(&RequestNumber::Number, content_number_input)? diff --git a/core/embed/rust/src/ui/layout_delizia/flow/request_passphrase.rs b/core/embed/rust/src/ui/layout_delizia/flow/request_passphrase.rs index 99eb358bd5..3bc09805bc 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/request_passphrase.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/request_passphrase.rs @@ -12,9 +12,7 @@ use crate::{ }, }; -use super::super::component::{ - Frame, FrameMsg, PassphraseKeyboard, PassphraseKeyboardMsg, PromptMsg, PromptScreen, -}; +use super::super::component::{Frame, PassphraseKeyboard, PassphraseKeyboardMsg, PromptScreen}; #[derive(Copy, Clone, PartialEq, Eq)] pub enum RequestPassphrase { @@ -56,11 +54,7 @@ pub fn new_request_passphrase() -> Result { TR::passphrase__continue_with_empty_passphrase.into(), PromptScreen::new_yes_or_no(), ) - .map(|msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), - FrameMsg::Content(PromptMsg::Cancelled) => Some(FlowMsg::Cancelled), - _ => None, - }); + .map(super::util::map_to_prompt); let content_keypad = PassphraseKeyboard::new().map(|msg| match msg { PassphraseKeyboardMsg::Confirmed(s) => Some(FlowMsg::Text(s)), diff --git a/core/embed/rust/src/ui/layout_delizia/flow/set_brightness.rs b/core/embed/rust/src/ui/layout_delizia/flow/set_brightness.rs index 938a96d3a6..3ed9b02058 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/set_brightness.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/set_brightness.rs @@ -6,7 +6,7 @@ use crate::{ translations::TR, trezorhal::display, ui::{ - component::{base::ComponentExt, swipe_detect::SwipeSettings, FlowMsg}, + component::{swipe_detect::SwipeSettings, FlowMsg}, flow::{ base::{Decision, DecisionBuilder as _}, FlowController, SwipeFlow, @@ -18,8 +18,7 @@ use crate::{ use super::super::{ component::{ number_input_slider::{NumberInputSliderDialog, NumberInputSliderDialogMsg}, - Frame, FrameMsg, PromptMsg, PromptScreen, StatusScreen, SwipeContent, VerticalMenu, - VerticalMenuChoiceMsg, + Frame, PromptMsg, PromptScreen, StatusScreen, SwipeContent, VerticalMenu, }, theme, }; @@ -78,12 +77,11 @@ pub fn new_set_brightness(brightness: Option) -> Result { .with_menu_button() .with_swipe(Direction::Up, SwipeSettings::default()) .map(|msg| match msg { - FrameMsg::Content(NumberInputSliderDialogMsg::Changed(n)) => { + NumberInputSliderDialogMsg::Changed(n) => { display::backlight(n as _); BRIGHTNESS.store(n as u8, Ordering::Relaxed); None } - FrameMsg::Button(_) => Some(FlowMsg::Info), }); let content_menu = Frame::left_aligned( @@ -92,10 +90,7 @@ pub fn new_set_brightness(brightness: Option) -> Result { ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(move |msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); let content_confirm = Frame::left_aligned( TR::brightness__change_title.into(), @@ -106,11 +101,10 @@ pub fn new_set_brightness(brightness: Option) -> Result { .with_swipe(Direction::Down, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) .map(move |msg| match msg { - FrameMsg::Content(PromptMsg::Confirmed) => { + PromptMsg::Confirmed => { let _ = storage::set_brightness(BRIGHTNESS.load(Ordering::Relaxed)); Some(FlowMsg::Confirmed) } - FrameMsg::Button(_) => Some(FlowMsg::Info), _ => None, }); diff --git a/core/embed/rust/src/ui/layout_delizia/flow/show_danger.rs b/core/embed/rust/src/ui/layout_delizia/flow/show_danger.rs index 1af510a346..12b171e1d5 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/show_danger.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/show_danger.rs @@ -6,7 +6,6 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, ParagraphSource}, - ComponentExt, }, flow::{ base::{Decision, DecisionBuilder as _}, @@ -17,7 +16,7 @@ use crate::{ }; use super::super::{ - component::{Frame, FrameMsg, StatusScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg}, + component::{Frame, StatusScreen, SwipeContent, VerticalMenu}, theme, }; @@ -80,7 +79,7 @@ pub fn new_show_danger( .with_danger() .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Left, SwipeSettings::default()) - .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)); + .map_to_button_msg(); // .one_button_request(ButtonRequestCode::Warning, br_name); // Menu @@ -92,10 +91,7 @@ pub fn new_show_danger( ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); // Cancelled let content_cancelled = Frame::left_aligned( diff --git a/core/embed/rust/src/ui/layout_delizia/flow/show_share_words.rs b/core/embed/rust/src/ui/layout_delizia/flow/show_share_words.rs index 5fcd0b395d..f08f55241a 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/show_share_words.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/show_share_words.rs @@ -20,8 +20,7 @@ use heapless::Vec; use super::super::{ component::{ - Footer, Frame, FrameMsg, Header, InternallySwipableContent, PromptScreen, ShareWords, - SwipeContent, + Footer, Frame, Header, InternallySwipableContent, PromptScreen, ShareWords, SwipeContent, }, theme, }; @@ -99,7 +98,7 @@ pub fn new_show_share_words( .with_subtitle(TR::words__instructions.into()) .with_footer(TR::instructions__swipe_up.into(), text_footer) .with_swipe(Direction::Up, SwipeSettings::default()) - .map(|msg| matches!(msg, FrameMsg::Content(_)).then_some(FlowMsg::Confirmed)) + .map_to_button_msg() .one_button_request(ButtonRequestCode::ResetDevice.with_name("share_words")) .with_pages(move |_| nwords + 2); @@ -114,7 +113,7 @@ pub fn new_show_share_words( .register_header_update_fn(header_updating_func) .with_footer_counter(TR::instructions__swipe_up.into()) .register_footer_update_fn(footer_updating_func) - .map(|_| None); + .map_to_button_msg(); let content_confirm = Frame::left_aligned( text_confirm, diff --git a/core/embed/rust/src/ui/layout_delizia/flow/show_tutorial.rs b/core/embed/rust/src/ui/layout_delizia/flow/show_tutorial.rs index 0196dfe424..7c20cd8ca8 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/show_tutorial.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/show_tutorial.rs @@ -5,7 +5,6 @@ use crate::{ component::{ swipe_detect::SwipeSettings, text::paragraphs::{Paragraph, Paragraphs}, - ComponentExt, }, flow::{ base::{Decision, DecisionBuilder as _}, @@ -16,9 +15,7 @@ use crate::{ }; use super::super::{ - component::{ - Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg, - }, + component::{Frame, PromptScreen, SwipeContent, VerticalMenu}, theme, }; @@ -79,9 +76,7 @@ pub fn new_show_tutorial() -> Result { SwipeContent::new(PromptScreen::new_tap_to_start()), ) .with_footer(TR::instructions__tap_to_start.into(), None) - .map(|msg| { - matches!(msg, FrameMsg::Content(PromptMsg::Confirmed)).then_some(FlowMsg::Confirmed) - }); + .map(super::util::map_to_confirm); let content_step_begin = Frame::left_aligned( TR::tutorial__title_lets_begin.into(), @@ -95,7 +90,7 @@ pub fn new_show_tutorial() -> Result { Some(TR::tutorial__get_started.into()), ) .with_swipe(Direction::Up, SwipeSettings::default()) - .map(|_| None); + .map_to_button_msg(); let content_step_navigation = Frame::left_aligned( TR::tutorial__title_easy_navigation.into(), @@ -110,7 +105,7 @@ pub fn new_show_tutorial() -> Result { ) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Down, SwipeSettings::default()) - .map(|_| None); + .map_to_button_msg(); let content_step_menu = Frame::left_aligned( TR::tutorial__title_handy_menu.into(), @@ -127,16 +122,14 @@ pub fn new_show_tutorial() -> Result { ) .with_swipe(Direction::Up, SwipeSettings::default()) .with_swipe(Direction::Down, SwipeSettings::default()) - .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info)); + .map_to_button_msg(); let content_step_hold = Frame::left_aligned( TR::tutorial__title_hold.into(), SwipeContent::new(PromptScreen::new_hold_to_confirm()), ) .with_footer(TR::instructions__hold_to_exit_tutorial.into(), None) - .map(|msg| { - matches!(msg, FrameMsg::Content(PromptMsg::Confirmed)).then_some(FlowMsg::Confirmed) - }); + .map(super::util::map_to_confirm); let content_step_done = Frame::left_aligned( TR::tutorial__title_well_done.into(), @@ -147,7 +140,7 @@ pub fn new_show_tutorial() -> Result { ) .with_footer(TR::instructions__swipe_up.into(), None) .with_swipe(Direction::Up, SwipeSettings::default()) - .map(|_| None); + .map_to_button_msg(); let content_menu = Frame::left_aligned( "".into(), @@ -159,10 +152,7 @@ pub fn new_show_tutorial() -> Result { .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) .with_swipe(Direction::Left, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + .map(super::util::map_to_choice); let content_did_you_know = Frame::left_aligned( "".into(), @@ -173,16 +163,14 @@ pub fn new_show_tutorial() -> Result { ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Cancelled)); + .map_to_button_msg(); let content_hold_to_exit = Frame::left_aligned( TR::tutorial__title_hold.into(), SwipeContent::new(PromptScreen::new_hold_to_confirm_danger()), ) .with_footer(TR::instructions__hold_to_exit_tutorial.into(), None) - .map(|msg| { - matches!(msg, FrameMsg::Content(PromptMsg::Confirmed)).then_some(FlowMsg::Confirmed) - }); + .map(super::util::map_to_confirm); let res = SwipeFlow::new(&ShowTutorial::StepWelcome)? .with_page(&ShowTutorial::StepWelcome, content_step_welcome)? diff --git a/core/embed/rust/src/ui/layout_delizia/flow/util.rs b/core/embed/rust/src/ui/layout_delizia/flow/util.rs index ccbc7b12ae..3726ea4384 100644 --- a/core/embed/rust/src/ui/layout_delizia/flow/util.rs +++ b/core/embed/rust/src/ui/layout_delizia/flow/util.rs @@ -6,13 +6,12 @@ use crate::{ translations::TR, ui::{ component::{ - base::ComponentExt, swipe_detect::SwipeSettings, text::{ paragraphs::{Paragraph, ParagraphSource, ParagraphVecLong, VecExt}, TextStyle, }, - Component, + Component, MsgMap, PaginateFull, }, flow::{FlowMsg, Swipable, SwipeFlow, SwipePage}, geometry::Direction, @@ -23,7 +22,7 @@ use heapless::Vec; use super::{ super::{ - component::{Frame, FrameMsg, SwipeContent}, + component::{Frame, FrameMsg, PromptMsg, SwipeContent, VerticalMenuChoiceMsg}, flow, theme, }, ConfirmActionExtra, ConfirmActionMenuStrings, ConfirmActionStrings, @@ -253,7 +252,7 @@ impl ConfirmValue { frame = frame.with_vertical_pages(); - Ok(frame.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info))) + Ok(frame.map_to_button_msg()) } pub fn into_flow(self) -> Result { @@ -442,12 +441,26 @@ impl ShowInfoParams { frame = frame.with_vertical_pages(); - Ok(frame.map(move |msg| { - matches!(msg, FrameMsg::Button(_)).then_some(if self.cancel_button { - FlowMsg::Cancelled - } else { - FlowMsg::Info - }) - })) + Ok(frame.map_to_button_msg()) + } +} + +pub fn map_to_confirm(msg: PromptMsg) -> Option { + match msg { + PromptMsg::Confirmed => Some(FlowMsg::Confirmed), + _ => None, + } +} + +pub fn map_to_prompt(msg: PromptMsg) -> Option { + match msg { + PromptMsg::Confirmed => Some(FlowMsg::Confirmed), + PromptMsg::Cancelled => Some(FlowMsg::Cancelled), + } +} + +pub fn map_to_choice(msg: VerticalMenuChoiceMsg) -> Option { + match msg { + VerticalMenuChoiceMsg::Selected(i) => Some(FlowMsg::Choice(i)), } }