 
     private var isKeyboardShowing = false
 
-    private func setUnderBarViewPercentHidden(_ underBarViewPercentHidden: CGFloat, completion: @escaping () -> Void) {
+    private func setUnderBarViewPercentHidden(_ underBarViewPercentHidden: CGFloat, completion: (() -> Void)? = nil) {
         UIView.animate(withDuration: 0.3, animations: {
             self.navigationBar.setNavigationBarPercentHidden(0, underBarViewPercentHidden: underBarViewPercentHidden, extendedViewPercentHidden: 0, topSpacingPercentHidden: 0, animated: true) {
                 self.useNavigationBarVisibleHeightForScrollViewInsets = true

        }, completion: { _ in
            self.useNavigationBarVisibleHeightForScrollViewInsets = false
            self.navigationBar.isUnderBarViewHidingEnabled = true
            completion()
        })
    }
}


        additionalSafeAreaInsets = searchResultsCollectionViewController.additionalSafeAreaInsets
        scrollView = searchResultsCollectionViewController.collectionView
    }

    override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
        super.willTransition(to: newCollection, with: coordinator)
        if isKeyboardShowing {
            setUnderBarViewPercentHidden(navigationBar.underBarViewPercentHidden)
        }
    }

    private var selectedImageViewHeightConstraint: NSLayoutConstraint?
