         messageToolbarBottomConstraint.constant = 0
         moreMessageTypesViewHeightConstraint.constant = moreMessageTypesViewHeightConstraintConstant
 
-        updateUIWithKeyboardChange = true
+        //updateUIWithKeyboardChange = true
+
+        keyboardMan.animateWhenKeyboardAppear = { [weak self] keyboardHeight, keyboardHeightIncrement in
+
+            print("appear \(keyboardHeight), \(keyboardHeightIncrement)\n")
+
+            if let strongSelf = self {
+
+                //if strongSelf.messageToolbar.previousState == .MoreMessages {
+                if strongSelf.messageToolbarBottomConstraint.constant > 0 {
+
+                    // 注意第一次要减去
+                    if keyboardHeightIncrement > strongSelf.moreMessageTypesViewHeightConstraintConstant {
+                        strongSelf.conversationCollectionView.contentOffset.y += keyboardHeightIncrement - strongSelf.moreMessageTypesViewHeightConstraintConstant
+                    } else {
+                        strongSelf.conversationCollectionView.contentOffset.y += keyboardHeightIncrement
+                    }
+
+                    strongSelf.conversationCollectionView.contentInset.bottom = keyboardHeight + strongSelf.messageToolbar.frame.height
+
+                    strongSelf.messageToolbarBottomConstraint.constant = keyboardHeight
+                    strongSelf.view.layoutIfNeeded()
+
+                } else {
+
+                    strongSelf.conversationCollectionView.contentOffset.y += keyboardHeightIncrement
+                    strongSelf.conversationCollectionView.contentInset.bottom = keyboardHeight + strongSelf.messageToolbar.frame.height
+
+                    strongSelf.messageToolbarBottomConstraint.constant = keyboardHeight
+                    strongSelf.view.layoutIfNeeded()
+                }
+            }
+        }
+
+        keyboardMan.animateWhenKeyboardDisappear = { [weak self] keyboardHeight in
+
+            print("disappear \(keyboardHeight)\n")
+
+            if let strongSelf = self {
+
+                if strongSelf.messageToolbar.state == .MoreMessages {
+                    strongSelf.conversationCollectionView.contentOffset.y -= keyboardHeight - strongSelf.moreMessageTypesViewHeightConstraintConstant
+                    strongSelf.conversationCollectionView.contentInset.bottom = strongSelf.messageToolbar.frame.height + strongSelf.moreMessageTypesViewHeightConstraintConstant
+
+                    strongSelf.messageToolbarBottomConstraint.constant = strongSelf.moreMessageTypesViewHeightConstraintConstant
+                    strongSelf.view.layoutIfNeeded()
+
+                } else {
+                    strongSelf.conversationCollectionView.contentOffset.y -= keyboardHeight
+                    strongSelf.conversationCollectionView.contentInset.bottom = strongSelf.messageToolbar.frame.height
+
+                    strongSelf.messageToolbarBottomConstraint.constant = 0
+                    strongSelf.view.layoutIfNeeded()
+                }
+            }
+        }
 
         lastTimeMessagesCount = messages.count
 


    lazy var messageImagePreferredWidth: CGFloat = {
        return YepConfig.ChatCell.mediaPreferredWidth
        //return ceil(self.collectionViewWidth * 0.6)
        }()
    lazy var messageImagePreferredHeight: CGFloat = {
        return YepConfig.ChatCell.mediaPreferredHeight
        //return ceil(self.collectionViewWidth * 0.65)
        }()

    let messageImagePreferredAspectRatio: CGFloat = 4.0 / 3.0

import MobileCoreServices
import MapKit
import Proposer
import KeyboardMan

struct MessageNotification {
    static let MessageStateChanged = "MessageStateChangedNotification"
