Skip to content

hero push animation is unable to turn off #759

@DenisOvchar457

Description

@DenisOvchar457

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
//        }
      }
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions