mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
fix(mobile): Fixed hero animation re-enabling on immich asset grid (#2169)
* fixed hero animation re-enabling on immich asset grid * comments
This commit is contained in:
parent
4cb74f0fe4
commit
ad680b6a35
1 changed files with 20 additions and 12 deletions
|
@ -38,19 +38,27 @@ class ImmichAssetGrid extends HookConsumerWidget {
|
||||||
|
|
||||||
// Needs to suppress hero animations when navigating to this widget
|
// Needs to suppress hero animations when navigating to this widget
|
||||||
final enableHeroAnimations = useState(false);
|
final enableHeroAnimations = useState(false);
|
||||||
|
final transitionDuration = ModalRoute.of(context)?.transitionDuration;
|
||||||
|
|
||||||
// Wait for transition to complete, then re-enable
|
useEffect(
|
||||||
ModalRoute.of(context)?.animation?.addListener(() {
|
() {
|
||||||
// If we've already enabled, we are done
|
// Wait for transition to complete, then re-enable
|
||||||
if (enableHeroAnimations.value) {
|
if (transitionDuration == null) {
|
||||||
return;
|
// No route transition found, maybe we opened this up first
|
||||||
}
|
enableHeroAnimations.value = true;
|
||||||
final animation = ModalRoute.of(context)?.animation;
|
} else {
|
||||||
if (animation != null) {
|
// Unfortunately, using the transition animation itself didn't
|
||||||
// When the animation is complete, re-enable hero animations
|
// seem to work reliably. So instead, wait until the duration of the
|
||||||
enableHeroAnimations.value = animation.isCompleted;
|
// animation has elapsed to re-enable the hero animations
|
||||||
}
|
Future.delayed(transitionDuration)
|
||||||
});
|
.then((_) {
|
||||||
|
enableHeroAnimations.value = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
Future<bool> onWillPop() async {
|
Future<bool> onWillPop() async {
|
||||||
enableHeroAnimations.value = false;
|
enableHeroAnimations.value = false;
|
||||||
|
|
Loading…
Reference in a new issue