     private let scrollView: UIScrollView
     private var originalContentInset: UIEdgeInsets = .zero
     private weak var viewController: UIViewController?
+    private var keyboardIsShowing = false
 
     init(scrollView: UIScrollView, viewController: UIViewController) {
         self.scrollView = scrollView

    }

    @objc func onKeyboardWillHide(notification: NSNotification) {
        guard let duration = notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as? TimeInterval
            else { return }
        UIView.animate(withDuration: duration, delay: 0, options: [.beginFromCurrentState], animations: {
            self.scrollView.contentInset = self.originalContentInset
            self.scrollView.scrollIndicatorInsets = self.originalContentInset

    // MARK: Notifications

    @objc func onKeyboardWillShow(notification: NSNotification) {
        guard !keyboardIsShowing,
            let frame = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? CGRect,
            let duration = notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as? TimeInterval,
            let viewController = self.viewController
            else { return }

        keyboardIsShowing = true

        var inset = scrollView.contentInset
        originalContentInset = inset
