mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 14:58:09 +00:00
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]
This commit is contained in:
parent
eef4319cda
commit
2203d9be1a
@ -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,
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user