mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +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:
		@@ -38,19 +38,27 @@ class ImmichAssetGrid extends HookConsumerWidget {
 | 
			
		||||
 | 
			
		||||
    // Needs to suppress hero animations when navigating to this widget
 | 
			
		||||
    final enableHeroAnimations = useState(false);
 | 
			
		||||
    final transitionDuration = ModalRoute.of(context)?.transitionDuration;
 | 
			
		||||
 | 
			
		||||
    // Wait for transition to complete, then re-enable
 | 
			
		||||
    ModalRoute.of(context)?.animation?.addListener(() {
 | 
			
		||||
      // If we've already enabled, we are done
 | 
			
		||||
      if (enableHeroAnimations.value) {
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      final animation = ModalRoute.of(context)?.animation;
 | 
			
		||||
      if (animation != null) {
 | 
			
		||||
        // When the animation is complete, re-enable hero animations
 | 
			
		||||
        enableHeroAnimations.value = animation.isCompleted;
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
    useEffect(
 | 
			
		||||
      () {
 | 
			
		||||
        // Wait for transition to complete, then re-enable
 | 
			
		||||
        if (transitionDuration == null) {
 | 
			
		||||
          // No route transition found, maybe we opened this up first
 | 
			
		||||
          enableHeroAnimations.value = true;
 | 
			
		||||
        } else {
 | 
			
		||||
          // Unfortunately, using the transition animation itself didn't
 | 
			
		||||
          // seem to work reliably. So instead, wait until the duration of the
 | 
			
		||||
          // animation has elapsed to re-enable the hero animations
 | 
			
		||||
          Future.delayed(transitionDuration)
 | 
			
		||||
              .then((_) {
 | 
			
		||||
                enableHeroAnimations.value = true;
 | 
			
		||||
              });
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
      },
 | 
			
		||||
      [],
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    Future<bool> onWillPop() async {
 | 
			
		||||
      enableHeroAnimations.value = false;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user