mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-30 10:08:18 +00:00
fix: TypeError from SwipeUpScreen
This allows cancellable homescreen. This commit also adds cancel to recovery homescreen.
This commit is contained in:
parent
e30de62adc
commit
7b291725e2
@ -113,6 +113,10 @@ impl<T: Component> SwipeContent<T> {
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inner(&self) -> &T {
|
||||
&self.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Component> Component for SwipeContent<T> {
|
||||
|
@ -30,6 +30,10 @@ where
|
||||
swipe: SwipeDetect::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inner(&self) -> &T {
|
||||
&self.content
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Swipable + Component> Component for SwipeUpScreen<T> {
|
||||
|
@ -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> {
|
||||
match msg {
|
||||
SwipeUpScreenMsg::Content(_) => Err(Error::TypeError),
|
||||
SwipeUpScreenMsg::Content(c) => self.inner().msg_try_into_obj(c),
|
||||
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(
|
||||
Frame::left_aligned(notification, SwipeContent::new(paragraphs))
|
||||
.with_cancel_button()
|
||||
.with_footer(TR::instructions__swipe_up.into(), None)
|
||||
.with_subtitle(TR::words__instructions.into())
|
||||
.with_swipe(SwipeDirection::Up, SwipeSettings::default()),
|
||||
|
Loading…
Reference in New Issue
Block a user