Hero icon indicating copy to clipboard operation
Hero copied to clipboard

hero push animation is unable to turn off

Open DenisOvchar457 opened this issue 1 year ago • 0 comments

Just in my case i modal present with hero from controller1 to UINavigationController with controller2. So for correct animation i should enable hero for navigationController . But that does not mean i want to make heroTransition delegate of my navigation Controller and does not mean. Its not clear. Usually u should enable hero just for dest view controller. isEnabled should only enable animation to controller as destination, but it should not change delegate of my navigationController to make it buggy. To control if hero delegates navigation or tabs u should add another field like hero.isHandlingNavigation . For now i have the only way to fix this strange behavior - just comment these lines

ofcourse navigation handling and enabling animation to navigation controller as dest should be controlled with different flags, these behaviours should not be always turned off/on together

  var isEnabled: Bool {
    get {
      return base.transitioningDelegate is HeroTransition
    }
    set {
      guard newValue != isEnabled else { return }
      if newValue {
        base.transitioningDelegate = Hero.shared
//        if let navi = base as? UINavigationController {
//          base.previousNavigationDelegate = navi.delegate
//          navi.delegate = Hero.shared
//        }
//        if let tab = base as? UITabBarController {
//          base.previousTabBarDelegate = tab.delegate
//          tab.delegate = Hero.shared
//        }
      } else {
        base.transitioningDelegate = nil
//        if let navi = base as? UINavigationController, navi.delegate is HeroTransition {
//          navi.delegate = base.previousNavigationDelegate
//        }
//        if let tab = base as? UITabBarController, tab.delegate is HeroTransition {
//          tab.delegate = base.previousTabBarDelegate
//        }
      }
    }
  }

DenisOvchar457 avatar Jun 06 '23 14:06 DenisOvchar457