1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-21 13:58:08 +00:00

fix: TypeError from SwipeUpScreen

This allows cancellable homescreen.

This commit also adds cancel to recovery homescreen.
This commit is contained in:
obrusvit 2024-06-05 19:04:20 +02:00 committed by matejcik
parent e30de62adc
commit 7b291725e2
3 changed files with 17 additions and 2 deletions

View File

@ -113,6 +113,10 @@ impl<T: Component> SwipeContent<T> {
..self ..self
} }
} }
pub fn inner(&self) -> &T {
&self.inner
}
} }
impl<T: Component> Component for SwipeContent<T> { impl<T: Component> Component for SwipeContent<T> {

View File

@ -30,6 +30,10 @@ where
swipe: SwipeDetect::new(), swipe: SwipeDetect::new(),
} }
} }
pub fn inner(&self) -> &T {
&self.content
}
} }
impl<T: Swipable + Component> Component for SwipeUpScreen<T> { impl<T: Swipable + Component> Component for SwipeUpScreen<T> {

View File

@ -181,10 +181,16 @@ impl ComponentMsgObj for PromptScreen {
} }
} }
impl<T: Component + Swipable> ComponentMsgObj for SwipeUpScreen<T> { impl<T: Component + ComponentMsgObj> ComponentMsgObj for SwipeContent<T> {
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
self.inner().msg_try_into_obj(msg)
}
}
impl<T: Component + ComponentMsgObj + Swipable> ComponentMsgObj for SwipeUpScreen<T> {
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> { fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
match msg { match msg {
SwipeUpScreenMsg::Content(_) => Err(Error::TypeError), SwipeUpScreenMsg::Content(c) => self.inner().msg_try_into_obj(c),
SwipeUpScreenMsg::Swiped => Ok(CONFIRMED.as_obj()), SwipeUpScreenMsg::Swiped => Ok(CONFIRMED.as_obj()),
} }
} }
@ -1083,6 +1089,7 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
let obj = LayoutObj::new(SwipeUpScreen::new( let obj = LayoutObj::new(SwipeUpScreen::new(
Frame::left_aligned(notification, SwipeContent::new(paragraphs)) Frame::left_aligned(notification, SwipeContent::new(paragraphs))
.with_cancel_button()
.with_footer(TR::instructions__swipe_up.into(), None) .with_footer(TR::instructions__swipe_up.into(), None)
.with_subtitle(TR::words__instructions.into()) .with_subtitle(TR::words__instructions.into())
.with_swipe(SwipeDirection::Up, SwipeSettings::default()), .with_swipe(SwipeDirection::Up, SwipeSettings::default()),