1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-19 05:58:09 +00:00

refactor(core/ui/mercury): delete CancelInfoConfirm

[no changelog]
This commit is contained in:
Martin Milata 2024-07-30 01:19:41 +02:00
parent 6ec9937ead
commit 2572705d1f
18 changed files with 95 additions and 108 deletions

View File

@ -3,7 +3,7 @@ use core::mem;
use heapless::Vec; use heapless::Vec;
use crate::{ use crate::{
strutil::TString, strutil::{ShortString, TString},
time::Duration, time::Duration,
ui::{ ui::{
button_request::{ButtonRequest, ButtonRequestCode}, button_request::{ButtonRequest, ButtonRequestCode},
@ -578,3 +578,34 @@ impl EventCtx {
self.transition_out self.transition_out
} }
} }
/// Component::Msg for component parts of a swipe flow. Converting results of
/// different screens to a shared type makes things easier to work with.
///
/// Also currently the type for message emitted by Flow::event to
/// micropython. They don't need to be the same.
#[derive(Clone)]
pub enum FlowMsg {
Confirmed,
Cancelled,
Info,
Choice(usize),
Text(ShortString),
}
#[cfg(feature = "micropython")]
impl TryFrom<FlowMsg> for crate::micropython::obj::Obj {
type Error = crate::error::Error;
fn try_from(val: FlowMsg) -> Result<crate::micropython::obj::Obj, Self::Error> {
match val {
FlowMsg::Confirmed => Ok(crate::ui::layout::result::CONFIRMED.as_obj()),
FlowMsg::Cancelled => Ok(crate::ui::layout::result::CANCELLED.as_obj()),
FlowMsg::Info => Ok(crate::ui::layout::result::INFO.as_obj()),
FlowMsg::Choice(i) => {
Ok((crate::ui::layout::result::CONFIRMED.as_obj(), i.try_into()?).try_into()?)
}
FlowMsg::Text(_s) => panic!(),
}
}
}

View File

@ -27,7 +27,7 @@ pub mod text;
pub mod timeout; pub mod timeout;
pub use bar::Bar; pub use bar::Bar;
pub use base::{Child, Component, ComponentExt, Event, EventCtx, Never, TimerToken}; pub use base::{Child, Component, ComponentExt, Event, EventCtx, FlowMsg, Never, TimerToken};
pub use border::Border; pub use border::Border;
pub use button_request::{ButtonRequestExt, SendButtonRequest}; pub use button_request::{ButtonRequestExt, SendButtonRequest};
#[cfg(all(feature = "jpeg", feature = "ui_image_buffer", feature = "micropython"))] #[cfg(all(feature = "jpeg", feature = "ui_image_buffer", feature = "micropython"))]

View File

@ -1,7 +1,6 @@
use crate::{ use crate::ui::component::{base::AttachType, swipe_detect::SwipeConfig, SwipeDirection};
strutil::ShortString,
ui::component::{base::AttachType, swipe_detect::SwipeConfig, SwipeDirection}, pub use crate::ui::component::FlowMsg;
};
pub trait Swipable { pub trait Swipable {
fn get_swipe_config(&self) -> SwipeConfig; fn get_swipe_config(&self) -> SwipeConfig;
@ -9,20 +8,6 @@ pub trait Swipable {
fn get_internal_page_count(&self) -> usize; fn get_internal_page_count(&self) -> usize;
} }
/// Component::Msg for component parts of a flow. Converting results of
/// different screens to a shared type makes things easier to work with.
///
/// Also currently the type for message emitted by Flow::event to
/// micropython. They don't need to be the same.
#[derive(Clone)]
pub enum FlowMsg {
Confirmed,
Cancelled,
Info,
Choice(usize),
Text(ShortString),
}
/// Composable event handler result. /// Composable event handler result.
#[derive(Clone)] #[derive(Clone)]
pub enum Decision { pub enum Decision {

View File

@ -2,6 +2,7 @@ pub mod base;
pub mod page; pub mod page;
mod swipe; mod swipe;
pub use base::{FlowMsg, FlowState, Swipable}; pub use crate::ui::component::FlowMsg;
pub use base::{FlowState, Swipable};
pub use page::SwipePage; pub use page::SwipePage;
pub use swipe::SwipeFlow; pub use swipe::SwipeFlow;

View File

@ -9,11 +9,11 @@ use crate::{
component::{ component::{
base::{AttachType, AttachType::Swipe}, base::{AttachType, AttachType::Swipe},
swipe_detect::SwipeSettings, swipe_detect::SwipeSettings,
Component, Event, EventCtx, SwipeDetect, SwipeDetectMsg, SwipeDirection, Component, Event, EventCtx, FlowMsg, SwipeDetect, SwipeDetectMsg, SwipeDirection,
}, },
display::Color, display::Color,
event::{SwipeEvent, TouchEvent}, event::{SwipeEvent, TouchEvent},
flow::{base::Decision, FlowMsg, FlowState}, flow::{base::Decision, FlowState},
geometry::Rect, geometry::Rect,
layout::obj::ObjComponent, layout::obj::ObjComponent,
shape::{render_on_display, ConcreteRenderer, Renderer, ScopedRenderer}, shape::{render_on_display, ConcreteRenderer, Renderer, ScopedRenderer},
@ -370,6 +370,7 @@ impl ObjComponent for SwipeFlow {
.try_into()?), .try_into()?),
} }
} }
fn obj_paint(&mut self) { fn obj_paint(&mut self) {
render_on_display(None, Some(Color::black()), |target| { render_on_display(None, Some(Color::black()), |target| {
self.render_state(self.state.index(), target); self.render_state(self.state.index(), target);

View File

@ -451,13 +451,6 @@ pub struct ButtonStyle {
pub background_color: Color, pub background_color: Color,
} }
#[derive(Clone, Copy)]
pub enum CancelInfoConfirmMsg {
Cancelled,
Info,
Confirmed,
}
#[derive(PartialEq, Eq, Clone)] #[derive(PartialEq, Eq, Clone)]
pub struct IconText { pub struct IconText {
text: TString<'static>, text: TString<'static>,

View File

@ -1,21 +1,20 @@
use super::{theme, ButtonStyleSheet, CancelInfoConfirmMsg, Footer, Header}; use super::{theme, ButtonStyleSheet, Footer, Header};
use crate::{ use crate::{
strutil::TString, strutil::TString,
ui::{ ui::{
component::{ component::{
swipe_detect::{SwipeConfig, SwipeSettings}, swipe_detect::{SwipeConfig, SwipeSettings},
text::TextStyle, text::TextStyle,
Component, Event, Component,
Event::Swipe, Event::{self, Swipe},
EventCtx, SwipeDetect, SwipeDirection, EventCtx, FlowMsg, SwipeDetect, SwipeDirection,
}, },
display::{Color, Icon}, display::{Color, Icon},
event::SwipeEvent, event::SwipeEvent,
geometry::{Alignment, Insets, Point, Rect}, geometry::{Alignment, Insets, Point, Rect},
lerp::Lerp, lerp::Lerp,
model_mercury::theme::TITLE_HEIGHT, model_mercury::theme::TITLE_HEIGHT,
shape, shape::{self, Renderer},
shape::Renderer,
}, },
}; };
@ -94,7 +93,7 @@ pub struct Frame<T> {
pub enum FrameMsg<T> { pub enum FrameMsg<T> {
Content(T), Content(T),
Button(CancelInfoConfirmMsg), Button(FlowMsg),
} }
impl<T> Frame<T> impl<T> Frame<T>
@ -142,26 +141,26 @@ where
} }
#[inline(never)] #[inline(never)]
fn with_button(mut self, icon: Icon, msg: CancelInfoConfirmMsg, enabled: bool) -> Self { fn with_button(mut self, icon: Icon, msg: FlowMsg, enabled: bool) -> Self {
self.header = self.header.with_button(icon, enabled, msg); self.header = self.header.with_button(icon, enabled, msg);
self self
} }
pub fn with_cancel_button(self) -> Self { pub fn with_cancel_button(self) -> Self {
self.with_button(theme::ICON_CLOSE, CancelInfoConfirmMsg::Cancelled, true) self.with_button(theme::ICON_CLOSE, FlowMsg::Cancelled, true)
} }
pub fn with_menu_button(self) -> Self { pub fn with_menu_button(self) -> Self {
self.with_button(theme::ICON_MENU, CancelInfoConfirmMsg::Info, true) self.with_button(theme::ICON_MENU, FlowMsg::Info, true)
} }
pub fn with_warning_low_icon(self) -> Self { pub fn with_warning_low_icon(self) -> Self {
self.with_button(theme::ICON_WARNING, CancelInfoConfirmMsg::Info, false) self.with_button(theme::ICON_WARNING, FlowMsg::Info, false)
.button_styled(theme::button_warning_low()) .button_styled(theme::button_warning_low())
} }
pub fn with_danger_icon(self) -> Self { pub fn with_danger_icon(self) -> Self {
self.with_button(theme::ICON_WARNING, CancelInfoConfirmMsg::Info, false) self.with_button(theme::ICON_WARNING, FlowMsg::Info, false)
.button_styled(theme::button_danger()) .button_styled(theme::button_danger())
} }
@ -319,7 +318,7 @@ fn frame_event(
footer: &mut Option<Footer>, footer: &mut Option<Footer>,
ctx: &mut EventCtx, ctx: &mut EventCtx,
event: Event, event: Event,
) -> Option<CancelInfoConfirmMsg> { ) -> Option<FlowMsg> {
horizontal_swipe.event(event, swipe_config); horizontal_swipe.event(event, swipe_config);
footer.event(ctx, event); footer.event(ctx, event);

View File

@ -2,17 +2,15 @@ use crate::{
strutil::TString, strutil::TString,
time::{Duration, Stopwatch}, time::{Duration, Stopwatch},
ui::{ ui::{
component::{text::TextStyle, Component, Event, EventCtx, Label}, component::{text::TextStyle, Component, Event, EventCtx, FlowMsg, Label},
display::{Color, Icon}, display::{Color, Icon},
geometry::{Alignment, Alignment2D, Insets, Offset, Rect}, geometry::{Alignment, Alignment2D, Insets, Offset, Rect},
lerp::Lerp, lerp::Lerp,
model_mercury::{ model_mercury::{
component::{Button, ButtonMsg, ButtonStyleSheet, CancelInfoConfirmMsg}, component::{Button, ButtonMsg, ButtonStyleSheet},
theme, theme::{self, TITLE_HEIGHT},
theme::TITLE_HEIGHT,
}, },
shape, shape::{self, Renderer},
shape::Renderer,
util::animation_disabled, util::animation_disabled,
}, },
}; };
@ -71,7 +69,7 @@ pub struct Header {
icon: Option<Icon>, icon: Option<Icon>,
color: Option<Color>, color: Option<Color>,
title_style: TextStyle, title_style: TextStyle,
button_msg: CancelInfoConfirmMsg, button_msg: FlowMsg,
} }
impl Header { impl Header {
@ -85,7 +83,7 @@ impl Header {
icon: None, icon: None,
color: None, color: None,
title_style: theme::label_title_main(), title_style: theme::label_title_main(),
button_msg: CancelInfoConfirmMsg::Cancelled, button_msg: FlowMsg::Cancelled,
} }
} }
#[inline(never)] #[inline(never)]
@ -134,7 +132,7 @@ impl Header {
} }
#[inline(never)] #[inline(never)]
pub fn with_button(mut self, icon: Icon, enabled: bool, msg: CancelInfoConfirmMsg) -> Self { pub fn with_button(mut self, icon: Icon, enabled: bool, msg: FlowMsg) -> Self {
let touch_area = Insets::uniform(BUTTON_EXPAND_BORDER); let touch_area = Insets::uniform(BUTTON_EXPAND_BORDER);
self.button = Some( self.button = Some(
Button::with_icon(icon) Button::with_icon(icon)
@ -166,7 +164,7 @@ impl Header {
} }
impl Component for Header { impl Component for Header {
type Msg = CancelInfoConfirmMsg; type Msg = FlowMsg;
fn place(&mut self, bounds: Rect) -> Rect { fn place(&mut self, bounds: Rect) -> Rect {
let header_area = if let Some(b) = &mut self.button { let header_area = if let Some(b) = &mut self.button {
@ -208,7 +206,7 @@ impl Component for Header {
} }
if let Some(ButtonMsg::Clicked) = self.button.event(ctx, event) { if let Some(ButtonMsg::Clicked) = self.button.event(ctx, event) {
return Some(self.button_msg); return Some(self.button_msg.clone());
}; };
None None

View File

@ -45,9 +45,7 @@ mod welcome_screen;
pub use address_details::AddressDetails; pub use address_details::AddressDetails;
#[cfg(feature = "ui_overlay")] #[cfg(feature = "ui_overlay")]
pub use binary_selection::{BinarySelection, BinarySelectionMsg}; pub use binary_selection::{BinarySelection, BinarySelectionMsg};
pub use button::{ pub use button::{Button, ButtonContent, ButtonMsg, ButtonStyle, ButtonStyleSheet, IconText};
Button, ButtonContent, ButtonMsg, ButtonStyle, ButtonStyleSheet, CancelInfoConfirmMsg, IconText,
};
#[cfg(feature = "translations")] #[cfg(feature = "translations")]
pub use coinjoin_progress::CoinJoinProgress; pub use coinjoin_progress::CoinJoinProgress;
pub use error::ErrorScreen; pub use error::ErrorScreen;

View File

@ -171,8 +171,9 @@ impl ConfirmFido {
.with_swipe(SwipeDirection::Down, SwipeSettings::default()) .with_swipe(SwipeDirection::Down, SwipeSettings::default())
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Content(()) => Some(FlowMsg::Confirmed), FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
FrameMsg::Button(_) => Some(FlowMsg::Info), FrameMsg::Button(_) => Some(FlowMsg::Info),
_ => None,
}); });
let content_menu = Frame::left_aligned( let content_menu = Frame::left_aligned(

View File

@ -19,8 +19,7 @@ use crate::{
use super::super::{ use super::super::{
component::{ component::{
CancelInfoConfirmMsg, Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
VerticalMenuChoiceMsg,
}, },
theme, theme,
}; };
@ -88,9 +87,7 @@ impl ConfirmFirmwareUpdate {
.with_footer(TR::instructions__swipe_up.into(), None) .with_footer(TR::instructions__swipe_up.into(), None)
.with_swipe(SwipeDirection::Up, SwipeSettings::default()) .with_swipe(SwipeDirection::Up, SwipeSettings::default())
.with_swipe(SwipeDirection::Left, SwipeSettings::default()) .with_swipe(SwipeDirection::Left, SwipeSettings::default())
.map(|msg| { .map(|msg| matches!(msg, FrameMsg::Button(FlowMsg::Info)).then_some(FlowMsg::Info));
matches!(msg, FrameMsg::Button(CancelInfoConfirmMsg::Info)).then_some(FlowMsg::Info)
});
let content_menu = Frame::left_aligned( let content_menu = Frame::left_aligned(
TString::empty(), TString::empty(),
@ -117,8 +114,7 @@ impl ConfirmFirmwareUpdate {
.with_cancel_button() .with_cancel_button()
.with_swipe(SwipeDirection::Right, SwipeSettings::default()) .with_swipe(SwipeDirection::Right, SwipeSettings::default())
.map(|msg| { .map(|msg| {
matches!(msg, FrameMsg::Button(CancelInfoConfirmMsg::Cancelled)) matches!(msg, FrameMsg::Button(FlowMsg::Cancelled)).then_some(FlowMsg::Cancelled)
.then_some(FlowMsg::Cancelled)
}); });
let content_confirm = Frame::left_aligned( let content_confirm = Frame::left_aligned(

View File

@ -19,10 +19,7 @@ use crate::{
}; };
use super::super::{ use super::super::{
component::{ component::{Frame, FrameMsg, PromptMsg, PromptScreen, VerticalMenu, VerticalMenuChoiceMsg},
CancelInfoConfirmMsg, Frame, FrameMsg, PromptMsg, PromptScreen, VerticalMenu,
VerticalMenuChoiceMsg,
},
theme, theme,
}; };
@ -83,8 +80,9 @@ impl SetNewPin {
.with_footer(TR::instructions__swipe_up.into(), None) .with_footer(TR::instructions__swipe_up.into(), None)
.with_swipe(SwipeDirection::Up, SwipeSettings::default()) .with_swipe(SwipeDirection::Up, SwipeSettings::default())
.with_swipe(SwipeDirection::Left, SwipeSettings::default()) .with_swipe(SwipeDirection::Left, SwipeSettings::default())
.map(|msg| { .map(|msg| match msg {
matches!(msg, FrameMsg::Button(CancelInfoConfirmMsg::Info)).then_some(FlowMsg::Info) FrameMsg::Button(bm) => Some(bm),
_ => None,
}); });
let content_menu = Frame::left_aligned( let content_menu = Frame::left_aligned(
@ -95,7 +93,7 @@ impl SetNewPin {
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
FrameMsg::Button(CancelInfoConfirmMsg::Cancelled) => Some(FlowMsg::Cancelled), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
FrameMsg::Button(_) => None, FrameMsg::Button(_) => None,
}); });
@ -116,7 +114,7 @@ impl SetNewPin {
.with_swipe(SwipeDirection::Up, SwipeSettings::default()) .with_swipe(SwipeDirection::Up, SwipeSettings::default())
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Button(CancelInfoConfirmMsg::Cancelled) => Some(FlowMsg::Cancelled), FrameMsg::Button(bm) => Some(bm),
_ => None, _ => None,
}); });
@ -130,7 +128,7 @@ impl SetNewPin {
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
FrameMsg::Button(CancelInfoConfirmMsg::Cancelled) => Some(FlowMsg::Cancelled), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
_ => None, _ => None,
}); });

View File

@ -21,8 +21,7 @@ use crate::{
use super::super::{ use super::super::{
component::{ component::{
CancelInfoConfirmMsg, Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
VerticalMenuChoiceMsg,
}, },
theme, theme,
}; };
@ -184,7 +183,7 @@ impl ContinueRecoveryBeforeShares {
.with_swipe(SwipeDirection::Up, SwipeSettings::default()) .with_swipe(SwipeDirection::Up, SwipeSettings::default())
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Button(CancelInfoConfirmMsg::Cancelled) => Some(FlowMsg::Cancelled), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
_ => None, _ => None,
}) })
.repeated_button_request(ButtonRequest::new( .repeated_button_request(ButtonRequest::new(
@ -202,7 +201,7 @@ impl ContinueRecoveryBeforeShares {
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
FrameMsg::Button(CancelInfoConfirmMsg::Cancelled) => Some(FlowMsg::Cancelled), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
_ => None, _ => None,
}); });

View File

@ -20,8 +20,8 @@ use crate::{
use super::super::{ use super::super::{
component::{ component::{
AddressDetails, CancelInfoConfirmMsg, Frame, FrameMsg, PromptMsg, PromptScreen, AddressDetails, Frame, FrameMsg, PromptMsg, PromptScreen, StatusScreen, SwipeContent,
StatusScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg, VerticalMenu, VerticalMenuChoiceMsg,
}, },
theme, theme,
}; };
@ -217,7 +217,7 @@ impl GetAddress {
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
FrameMsg::Button(CancelInfoConfirmMsg::Cancelled) => Some(FlowMsg::Cancelled), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
_ => None, _ => None,
}); });

View File

@ -19,8 +19,7 @@ use crate::{
use super::super::{ use super::super::{
component::{ component::{
CancelInfoConfirmMsg, Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, Frame, FrameMsg, PromptMsg, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
VerticalMenuChoiceMsg,
}, },
theme, theme,
}; };
@ -83,8 +82,9 @@ impl PromptBackup {
.with_footer(TR::instructions__swipe_up.into(), None) .with_footer(TR::instructions__swipe_up.into(), None)
.with_swipe(SwipeDirection::Up, SwipeSettings::default()) .with_swipe(SwipeDirection::Up, SwipeSettings::default())
.with_swipe(SwipeDirection::Left, SwipeSettings::default()) .with_swipe(SwipeDirection::Left, SwipeSettings::default())
.map(|msg| { .map(|msg| match msg {
matches!(msg, FrameMsg::Button(CancelInfoConfirmMsg::Info)).then_some(FlowMsg::Info) FrameMsg::Button(bm) => Some(bm),
_ => None,
}); });
let content_menu = Frame::left_aligned( let content_menu = Frame::left_aligned(
@ -95,7 +95,7 @@ impl PromptBackup {
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
FrameMsg::Button(CancelInfoConfirmMsg::Cancelled) => Some(FlowMsg::Cancelled), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
FrameMsg::Button(_) => None, FrameMsg::Button(_) => None,
}); });
@ -119,7 +119,7 @@ impl PromptBackup {
.with_swipe(SwipeDirection::Up, SwipeSettings::default()) .with_swipe(SwipeDirection::Up, SwipeSettings::default())
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Button(CancelInfoConfirmMsg::Cancelled) => Some(FlowMsg::Cancelled), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
_ => None, _ => None,
}); });
@ -133,7 +133,7 @@ impl PromptBackup {
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed), FrameMsg::Content(PromptMsg::Confirmed) => Some(FlowMsg::Confirmed),
FrameMsg::Button(CancelInfoConfirmMsg::Cancelled) => Some(FlowMsg::Cancelled), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
_ => None, _ => None,
}); });

View File

@ -18,8 +18,8 @@ use core::sync::atomic::{AtomicU16, Ordering};
use super::super::{ use super::super::{
component::{ component::{
CancelInfoConfirmMsg, Frame, FrameMsg, NumberInputDialog, NumberInputDialogMsg, Frame, FrameMsg, NumberInputDialog, NumberInputDialogMsg, SwipeContent, UpdatableMoreInfo,
SwipeContent, UpdatableMoreInfo, VerticalMenu, VerticalMenuChoiceMsg, VerticalMenu, VerticalMenuChoiceMsg,
}, },
theme, theme,
}; };
@ -114,7 +114,7 @@ impl RequestNumber {
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
FrameMsg::Button(CancelInfoConfirmMsg::Cancelled) => Some(FlowMsg::Cancelled), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
FrameMsg::Button(_) => None, FrameMsg::Button(_) => None,
}); });
@ -123,7 +123,7 @@ impl RequestNumber {
.with_cancel_button() .with_cancel_button()
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
.map(|msg| match msg { .map(|msg| match msg {
FrameMsg::Button(CancelInfoConfirmMsg::Cancelled) => Some(FlowMsg::Cancelled), FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled),
_ => None, _ => None,
}); });

View File

@ -7,9 +7,9 @@ use crate::{
translations::TR, translations::TR,
trezorhal::display, trezorhal::display,
ui::{ ui::{
component::{base::ComponentExt, swipe_detect::SwipeSettings, SwipeDirection}, component::{base::ComponentExt, swipe_detect::SwipeSettings, FlowMsg, SwipeDirection},
flow::{ flow::{
base::{DecisionBuilder as _, FlowMsg, StateChange}, base::{DecisionBuilder as _, StateChange},
FlowState, SwipeFlow, FlowState, SwipeFlow,
}, },
layout::obj::LayoutObj, layout::obj::LayoutObj,

View File

@ -2,8 +2,7 @@ use core::{cmp::Ordering, convert::TryInto};
use super::{ use super::{
component::{ component::{
AddressDetails, Bip39Input, Button, CancelConfirmMsg, CancelInfoConfirmMsg, AddressDetails, Bip39Input, CoinJoinProgress, Frame, FrameMsg, Homescreen, HomescreenMsg,
CoinJoinProgress, FidoConfirm, FidoMsg, Frame, FrameMsg, Homescreen, HomescreenMsg,
Lockscreen, MnemonicInput, MnemonicKeyboard, MnemonicKeyboardMsg, PinKeyboard, Lockscreen, MnemonicInput, MnemonicKeyboard, MnemonicKeyboardMsg, PinKeyboard,
PinKeyboardMsg, Progress, PromptScreen, SelectWordCount, SelectWordCountMsg, Slip39Input, PinKeyboardMsg, Progress, PromptScreen, SelectWordCount, SelectWordCountMsg, Slip39Input,
StatusScreen, SwipeUpScreen, SwipeUpScreenMsg, VerticalMenu, VerticalMenuChoiceMsg, StatusScreen, SwipeUpScreen, SwipeUpScreenMsg, VerticalMenu, VerticalMenuChoiceMsg,
@ -56,18 +55,6 @@ use crate::{
}, },
}; };
impl TryFrom<CancelInfoConfirmMsg> for Obj {
type Error = Error;
fn try_from(value: CancelInfoConfirmMsg) -> Result<Self, Self::Error> {
match value {
CancelInfoConfirmMsg::Cancelled => Ok(CANCELLED.as_obj()),
CancelInfoConfirmMsg::Info => Ok(INFO.as_obj()),
CancelInfoConfirmMsg::Confirmed => Ok(CONFIRMED.as_obj()),
}
}
}
impl TryFrom<SelectWordCountMsg> for Obj { impl TryFrom<SelectWordCountMsg> for Obj {
type Error = Error; type Error = Error;