 import UIKit
 
 
-public class CommentPopupWindow: UIViewController {
+public class CommentPopupWindow: UIViewController, UITextViewDelegate {
 
     // MARK: - Property
     var model: CourseModel = CourseModel() {

    }
    
    
    // MARK: - Event Response
    @objc private func pressed(sender: UIButton!) {
        self.closeAlert(sender.tag)

            make.right.equalTo(self.window.snp_right)
            make.height.equalTo(44)
        }
        
        // Animate
        if animated {
            self.window.setNeedsUpdateConstraints()
            UIView.animateWithDuration(0.35) { [weak self] () -> Void in
                self?.avatarView.alpha = 1
                self?.teacherNameLabel.alpha = 1
                self?.subjectLabel.alpha = 1
                self?.floatRating.alpha = 1
                self?.window.layoutIfNeeded()
            }
        }
    }
    
    ///  设置UI为编辑模式
    private func changeToEditingMode() {
        
        // Autolayout
        window.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.view.snp_top).offset(36)
            make.centerX.equalTo(self.view.snp_centerX)
            make.width.equalTo(MalaLayout_CommentPopupWindowWidth)
            make.height.equalTo(MalaLayout_CommentPopupWindowHeight)
        }
        textView.snp_updateConstraints(closure: { (make) -> Void in
            make.top.equalTo(titleLine.snp_bottom).offset(MalaLayout_Margin_12)
            make.left.equalTo(self.window.snp_left).offset(MalaLayout_Margin_18)
            make.right.equalTo(self.window.snp_right).offset(-MalaLayout_Margin_18)
            make.bottom.equalTo(buttonSeparatorLine.snp_top).offset(-MalaLayout_Margin_12)
        })
        avatarView.snp_updateConstraints { (make) -> Void in
            make.centerX.equalTo(self.window.snp_centerX)
            make.top.equalTo(titleLine.snp_bottom)
            make.width.equalTo(0)
            make.height.equalTo(0)
        }
        teacherNameLabel.snp_updateConstraints { (make) -> Void in
            make.right.equalTo(avatarView.snp_centerX).offset(-MalaLayout_Margin_5)
            make.top.equalTo(avatarView.snp_bottom).offset(MalaLayout_Margin_10)
            make.height.equalTo(0)
        }
        subjectLabel.snp_updateConstraints { (make) -> Void in
            make.left.equalTo(avatarView.snp_centerX).offset(MalaLayout_Margin_5)
            make.top.equalTo(avatarView.snp_bottom).offset(MalaLayout_Margin_10)
            make.height.equalTo(0)
        }
        floatRating.snp_updateConstraints { (make) -> Void in
            make.top.equalTo(subjectLabel.snp_bottom)
            make.centerX.equalTo(avatarView.snp_centerX)
            make.height.equalTo(0)
            make.width.equalTo(0)
        }
        
        // Animate
        self.window.setNeedsUpdateConstraints()
        UIView.animateWithDuration(0.35) { [weak self] () -> Void in
            self?.avatarView.alpha = 0
            self?.teacherNameLabel.alpha = 0
            self?.subjectLabel.alpha = 0
            self?.floatRating.alpha = 0
            self?.window.layoutIfNeeded()
        }
    }
    
    ///  删除所有约束
    private func removeAllConstraints() {
        window.snp_removeConstraints()
        titleView.snp_removeConstraints()
        closeButton.snp_removeConstraints()
        titleLine.snp_removeConstraints()
        avatarView.snp_removeConstraints()
        teacherNameLabel.snp_removeConstraints()
        subjectLabel.snp_removeConstraints()
        floatRating.snp_removeConstraints()
        textView.snp_removeConstraints()
        buttonSeparatorLine.snp_removeConstraints()
        commitButton.snp_removeConstraints()
    }
    
    private func animateAlert() {
