From 2203d9be1ad530af559cd1f7269f1350d0177d3c Mon Sep 17 00:00:00 2001 From: obrusvit Date: Tue, 30 Jul 2024 12:57:36 +0200 Subject: [PATCH] feat(core/ui): introduce FlowMsg::Text option This commit allows flows to work with ShortString which can be converted to micropython as str. [no changelog] --- core/embed/rust/src/ui/flow/base.rs | 10 +++++++--- core/embed/rust/src/ui/flow/swipe.rs | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/embed/rust/src/ui/flow/base.rs b/core/embed/rust/src/ui/flow/base.rs index 2e4657b44..2da6a7348 100644 --- a/core/embed/rust/src/ui/flow/base.rs +++ b/core/embed/rust/src/ui/flow/base.rs @@ -1,4 +1,7 @@ -use crate::ui::component::{base::AttachType, swipe_detect::SwipeConfig, SwipeDirection}; +use crate::{ + strutil::ShortString, + ui::component::{base::AttachType, swipe_detect::SwipeConfig, SwipeDirection}, +}; pub trait Swipable { fn get_swipe_config(&self) -> SwipeConfig; @@ -11,16 +14,17 @@ pub trait Swipable { /// /// Also currently the type for message emitted by Flow::event to /// micropython. They don't need to be the same. -#[derive(Copy, Clone)] +#[derive(Clone)] pub enum FlowMsg { Confirmed, Cancelled, Info, Choice(usize), + Text(ShortString), } /// Composable event handler result. -#[derive(Copy, Clone)] +#[derive(Clone)] pub enum Decision { /// Do nothing, continue with processing next handler. Nothing, diff --git a/core/embed/rust/src/ui/flow/swipe.rs b/core/embed/rust/src/ui/flow/swipe.rs index b2a233fe9..d30598562 100644 --- a/core/embed/rust/src/ui/flow/swipe.rs +++ b/core/embed/rust/src/ui/flow/swipe.rs @@ -363,6 +363,11 @@ impl ObjComponent for SwipeFlow { Some(FlowMsg::Choice(i)) => { Ok((crate::ui::layout::result::CONFIRMED.as_obj(), i.try_into()?).try_into()?) } + Some(FlowMsg::Text(s)) => Ok(( + crate::ui::layout::result::CONFIRMED.as_obj(), + s.as_str().try_into()?, + ) + .try_into()?), } } fn obj_paint(&mut self) {