1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-04 02:46:47 +01: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:
martyfuhry 2023-04-04 18:23:47 -04:00 committed by GitHub
parent 4cb74f0fe4
commit ad680b6a35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
useEffect(
() {
// Wait for transition to complete, then re-enable // Wait for transition to complete, then re-enable
ModalRoute.of(context)?.animation?.addListener(() { if (transitionDuration == null) {
// If we've already enabled, we are done // No route transition found, maybe we opened this up first
if (enableHeroAnimations.value) { enableHeroAnimations.value = true;
return; } else {
} // Unfortunately, using the transition animation itself didn't
final animation = ModalRoute.of(context)?.animation; // seem to work reliably. So instead, wait until the duration of the
if (animation != null) { // animation has elapsed to re-enable the hero animations
// When the animation is complete, re-enable hero animations Future.delayed(transitionDuration)
enableHeroAnimations.value = animation.isCompleted; .then((_) {
} enableHeroAnimations.value = true;
}); });
}
return null;
},
[],
);
Future<bool> onWillPop() async { Future<bool> onWillPop() async {
enableHeroAnimations.value = false; enableHeroAnimations.value = false;