         }
     }
 
+    //private func getRect(from)
+
     private func getBottomInsetChangeForKeboardChanged(beginKeyboardRect: CGRect, endKeyboardRect: CGRect) -> CGFloat {
         var keyboardHeightDifference: CGFloat
         let endKbHeight = endKeyboardRect.height


        let convertedBeginKeyboardRect = view.convert(beginKeyboardRect, to: view.window)
        let convertedEndKeyboardRect = view.convert(endKeyboardRect, from: view.window)
        let convertedFirstResponderView = view.convert(currentFirstResponderView.frame, from: currentFirstResponderView.superview)

        var insetDifference: CGFloat
        switch type {

        case .Show:
            saveCurrentContentInset()
            insetDifference = getBottomInsetChangeForKeyboardShown(keyboardRect: endKeyboardRect)
        case .Change:
            handlingKeyboardChange = true
            insetDifference = getBottomInsetChangeForKeboardChanged(beginKeyboardRect: beginKeyboardRect, endKeyboardRect: endKeyboardRect)
        }

        let newContentOffset = getNewContentOffset(textFieldRect: convertedFirstResponderView, keyboardRect: endKeyboardRect)

        performAnimation(withDuration: duration.doubleValue, andOptions: UIViewAnimationOptions(rawValue: animationCurve.uintValue), insetDifference: insetDifference, newContentOffset: newContentOffset, completion: { [weak self] in

            self?.lastKeyboardHeightAfterChange = endKeyboardRect.height

            switch type {
            case .Show:
                self?.keyboardIsShown = true
            case .Change:
                self?.handlingKeyboardChange = false
            }
        })


    private var handlingKeyboardChange = false
    private var keyboardIsShown = false
    private var waitingForTextViewSelection = false
    private var initialContentInset: UIEdgeInsets? = nil

    //In some cases KbEndFrame is the same as KBbeginFrame despite beign different (for example user taps on search bar and bar with predictions disappears)
