     addChildViewController(controller)
     view.insertSubview(controller.view, belowSubview: tabbyBar)
 
-    applyNewConstraints(controller.view)
+    applyNewConstraints(controller)
   }
 }

    })
  }

  func applyNewConstraints(_ subview: UIView) {
    var constant: CGFloat = 0

    if barVisible {


    heightConstant = constant

    view.constraint(controller.view, attributes: .leading, .trailing, .top)

    let constraint = NSLayoutConstraint(
      item: controller.view, attribute: .height,
      relatedBy: .equal, toItem: view,
      attribute: .height, multiplier: 1,
      constant: constant)

    view.addConstraints([constraint])
    heightConstraint = constraint
  }

  // MARK: - Constraints

  func setupConstraints() {
    view.constraint(tabbyBar, attributes: .leading, .trailing, .bottom)
    view.addConstraint(shownConstraint)
  }
}

extension TabbyController {

  public func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
    var needsLayout = false
    let controller = items[index].controller

    if viewController.hidesBottomBarWhenPushed {
      if view.constraints.contains(shownConstraint) {
        heightConstraint?.constant = 0
        view.removeConstraint(shownConstraint)
        view.addConstraint(hiddenConstraint)
        tabbyBar.indicator.alpha = 0.0
        needsLayout = true
      }
    } else {
      if view.constraints.contains(hiddenConstraint) {
        view.removeConstraint(hiddenConstraint)
        view.addConstraint(shownConstraint)
        heightConstraint?.constant = Constant.Dimension.height
        tabbyBar.indicator.alpha = showIndicator ? 1 : 0
        needsLayout = true
      }
    }

    if needsLayout {
      UIView.animate(withDuration: 0.3) {
        self.view.layoutIfNeeded()
      }
    }
  }
}
