1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 17:38:39 +00:00

fix(core/ui): respect animation_disabled() on T3T1

This commit is contained in:
Martin Milata 2024-05-03 00:42:51 +02:00
parent 687d773547
commit 6ddf1c849a
2 changed files with 17 additions and 4 deletions

View File

@ -7,6 +7,7 @@ use crate::{
flow::base::Swipable, flow::base::Swipable,
geometry::{Axis, Offset, Rect}, geometry::{Axis, Offset, Rect},
shape::Renderer, shape::Renderer,
util,
}, },
}; };
@ -124,6 +125,15 @@ impl<T: Component + Paginate + Clone> Swipable for SwipePage<T> {
} }
_ => {} _ => {}
}; };
self.current = match direction {
SwipeDirection::Left | SwipeDirection::Up => (self.current + 1).min(self.pages - 1),
SwipeDirection::Right | SwipeDirection::Down => self.current.saturating_sub(1),
};
if util::animation_disabled() {
self.inner.change_page(self.current);
ctx.request_paint();
return true;
}
self.transition = Some(Transition { self.transition = Some(Transition {
cloned: unwrap!(Gc::new(self.inner.clone())), cloned: unwrap!(Gc::new(self.inner.clone())),
animation: Animation::new( animation: Animation::new(
@ -134,10 +144,6 @@ impl<T: Component + Paginate + Clone> Swipable for SwipePage<T> {
), ),
direction, direction,
}); });
self.current = match direction {
SwipeDirection::Left | SwipeDirection::Up => (self.current + 1).min(self.pages - 1),
SwipeDirection::Right | SwipeDirection::Down => self.current.saturating_sub(1),
};
self.inner.change_page(self.current); self.inner.change_page(self.current);
ctx.request_anim_frame(); ctx.request_anim_frame();
ctx.request_paint(); ctx.request_paint();

View File

@ -7,6 +7,7 @@ use crate::{
flow::{base::Decision, FlowMsg, FlowState, FlowStore}, flow::{base::Decision, FlowMsg, FlowState, FlowStore},
geometry::{Offset, Rect}, geometry::{Offset, Rect},
shape::Renderer, shape::Renderer,
util,
}, },
}; };
@ -63,6 +64,12 @@ impl<Q: FlowState, S: FlowStore> SwipeFlow<Q, S> {
self.transition = Transition::Internal; self.transition = Transition::Internal;
return; return;
} }
if util::animation_disabled() {
self.state = state;
self.store.event(state.index(), ctx, Event::Attach);
ctx.request_paint();
return;
}
self.transition = Transition::External { self.transition = Transition::External {
prev_state: self.state, prev_state: self.state,
animation: Animation::new( animation: Animation::new(