Browse Source

no message

南鑫林 5 years ago
parent
commit
d0712ebf7b

+ 28 - 4
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -2633,6 +2633,31 @@
 			path = HTMLCell;
 			sourceTree = "<group>";
 		};
+		A76B786A22CE462E0047EC1B /* imageCell */ = {
+			isa = PBXGroup;
+			children = (
+				BD2FCBE322B244250006D974 /* RecommendDetailContentCell.swift */,
+			);
+			path = imageCell;
+			sourceTree = "<group>";
+		};
+		A76B786B22CE46750047EC1B /* ViewController */ = {
+			isa = PBXGroup;
+			children = (
+				BD1FC18522B09F9800D55081 /* CommunitySubCommentController.swift */,
+			);
+			path = ViewController;
+			sourceTree = "<group>";
+		};
+		A76B786C22CE467E0047EC1B /* View */ = {
+			isa = PBXGroup;
+			children = (
+				BD1FC18722B0A30300D55081 /* CommunityMajorCommentCell.swift */,
+				BD1FC18922B0A32100D55081 /* CommunityReplyCommentCell.swift */,
+			);
+			path = View;
+			sourceTree = "<group>";
+		};
 		A773D02D229FD5B7007A5751 /* MainView */ = {
 			isa = PBXGroup;
 			children = (
@@ -4628,9 +4653,8 @@
 		BD1FC18222B09F4700D55081 /* CommunitySubComment */ = {
 			isa = PBXGroup;
 			children = (
-				BD1FC18522B09F9800D55081 /* CommunitySubCommentController.swift */,
-				BD1FC18722B0A30300D55081 /* CommunityMajorCommentCell.swift */,
-				BD1FC18922B0A32100D55081 /* CommunityReplyCommentCell.swift */,
+				A76B786C22CE467E0047EC1B /* View */,
+				A76B786B22CE46750047EC1B /* ViewController */,
 			);
 			path = CommunitySubComment;
 			sourceTree = "<group>";
@@ -4708,13 +4732,13 @@
 		BD2FCBE022B21C600006D974 /* View */ = {
 			isa = PBXGroup;
 			children = (
+				A76B786A22CE462E0047EC1B /* imageCell */,
 				A76B786722CE04730047EC1B /* HTMLCell */,
 				BDAF83AE22B3B6150004BCC3 /* AllCommentCell */,
 				BDAF83A922B388F20004BCC3 /* RecommendDefaultBackCell.swift */,
 				BDAF83A722B343C50004BCC3 /* RecommendBottomCommentView.swift */,
 				A7C2567022CC895F00420828 /* CommunityPostDetailTableViewHeaderView.swift */,
 				A7C2567222CC8BB000420828 /* CommunityPostDetailFSPagerViewCell.swift */,
-				BD2FCBE322B244250006D974 /* RecommendDetailContentCell.swift */,
 				BD2FCBE522B2586C0006D974 /* CommunityTagCollectionCell.swift */,
 				BD2FCBE922B267280006D974 /* RecommendNoneCommentCell.swift */,
 				BDAF83A122B330540004BCC3 /* RecommendSimilarCell.swift */,

+ 3 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/AllCommentCell/RecommendMajorCommentCell.swift

@@ -195,7 +195,9 @@ extension RecommendMajorCommentCell: UITableViewDataSource, UITableViewDelegate
     }
     
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-        
+        let vc = CommunitySubCommentController()
+        vc.communityPostCommentModel = communityPostCommentModel
+        findViewController()?.navigationController?.pushViewController(vc, animated: true)
     }
     
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/RecommendDetailContentCell.swift → RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/imageCell/RecommendDetailContentCell.swift


+ 0 - 103
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunitySubComment/CommunitySubCommentController.swift

@@ -1,103 +0,0 @@
-//
-//  CommunitySubCommentController.swift
-//  RainbowPlanet
-//
-//  Created by Christopher on 2019/6/12.
-//  Copyright © 2019 RainbowPlanet. All rights reserved.
-//
-
-import UIKit
-
-class CommunitySubCommentController: BaseViewController {
-    
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        setupViews()
-        setupLayouts()
-    }
-    
-    override func viewWillAppear(_ animated: Bool) {
-        cmtKeyboard.isDisappear = false
-    }
-    
-    override func viewWillDisappear(_ animated: Bool) {
-        cmtKeyboard.isDisappear = true
-    }
-    
-    override func setupViews() {
-        navigationBar.title = "3条评论"
-        view.backgroundColor = kf7f8faColor
-        
-        view.addSubview(tableView)
-        view.addSubview(cmtKeyboard)
-    }
-    
-    override func setupLayouts() {
-        tableView.snp.makeConstraints { (make) in
-            make.top.equalToSuperview().offset(kNavBarTotalHeight)
-            make.left.right.bottom.equalTo(0)
-        }
-    }
-    
-    override func setupData() {
-        
-    }
-    
-    lazy var tableView: UITableView = {
-        let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
-        tableView.separatorStyle = .none
-        tableView.backgroundColor = kf7f8faColor
-        tableView.dataSource = self
-        tableView.delegate = self
-        tableView.estimatedRowHeight = 60
-        tableView.estimatedSectionFooterHeight = 0.000001
-        tableView.estimatedSectionHeaderHeight = 0.000001
-        return tableView
-    }()
-    
-    lazy var cmtKeyboard: LXKeyBoard = {
-        let cmtKeyboard = LXKeyBoard.init()
-        cmtKeyboard.backgroundColor = kffffffColor
-        cmtKeyboard.maxLine = 3
-        cmtKeyboard.font = kRegularFont14
-        cmtKeyboard.topOrBottomEdge = 10
-        cmtKeyboard.beginUpdateUI()
-        cmtKeyboard.sendBlock = {
-            [weak self] (text) in
-            print("----\(text)")
-        }
-        
-        return cmtKeyboard
-    }()
-}
-
-// MARK: - tableView dataSource && delegate
-extension CommunitySubCommentController: UITableViewDataSource, UITableViewDelegate {
-    
-    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return 3
-    }
-    
-    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        if indexPath.row == 0 {
-            let cell = CommunityMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
-            return cell
-        } else {
-            let cell = CommunityReplyCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
-            return cell
-        }
-    }
-    
-    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-        print("点击了----\(indexPath.row)")
-    }
-    
-    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
-        return UITableView.automaticDimension
-    }
-    
-    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
-        return 10
-    }
-    
-}

+ 34 - 16
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunitySubComment/CommunityMajorCommentCell.swift

@@ -7,9 +7,11 @@
 //  主评论のCell
 
 import UIKit
-
+import RxSwift
 class CommunityMajorCommentCell: UITableViewCell {
     
+    let disposeBag = DisposeBag()
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> CommunityMajorCommentCell {
         let ID = "CommunityMajorCommentCell"
         tableView.register(CommunityMajorCommentCell.self, forCellReuseIdentifier: ID)
@@ -39,47 +41,51 @@ class CommunityMajorCommentCell: UITableViewCell {
         self.selectionStyle = .none
         backgroundColor = kffffffColor
         
-        addSubview(iconImageView)
+        addSubview(iconButton)
         addSubview(titleLabel)
         addSubview(contentLabel)
         addSubview(timeLabel)
     }
     
     private func setupLayouts() {
-        iconImageView.snp.makeConstraints { (make) in
+        iconButton.snp.makeConstraints { (make) in
             make.top.equalTo(20)
             make.left.equalTo(14)
             make.size.equalTo(24)
         }
         titleLabel.snp.makeConstraints { (make) in
-            make.left.equalTo(iconImageView.snp_right).offset(10)
+            make.left.equalTo(iconButton.snp_right).offset(10)
             make.right.equalToSuperview().offset(-26)
-            make.centerY.equalTo(iconImageView)
+            make.centerY.equalTo(iconButton)
             make.height.equalTo(17)
         }
+        
         contentLabel.snp.makeConstraints { (make) in
-            make.top.equalTo(titleLabel.snp_bottom).offset(12)
-            make.left.equalTo(titleLabel.snp_left)
-            make.right.equalToSuperview().offset(-26)
+            make.top.equalTo(iconButton.snp_bottom).offset(6)
+            make.left.equalTo(48)
+            make.right.equalToSuperview().offset(-14)
         }
         timeLabel.snp.makeConstraints { (make) in
             make.top.equalTo(contentLabel.snp_bottom).offset(8)
             make.left.equalTo(titleLabel.snp_left)
             make.right.equalTo(contentLabel.snp_right)
             make.height.equalTo(15)
-            make.bottom.equalToSuperview().offset(-20)
         }
     }
     
-    lazy var iconImageView : UIImageView = {
-        let iconImageView = UIImageView()
-        iconImageView.image = kImage(name: "page05")
-        return iconImageView
+    private lazy var iconButton : UIButton = {
+        let iconButton = UIButton(type: UIButton.ButtonType.custom)
+        iconButton.setImage(kImage(name: "default_avatar"), for: UIControl.State.normal)
+        iconButton.cornerRadius = 12
+        iconButton.masksToBounds = true
+        iconButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+            
+        }).disposed(by: disposeBag)
+        return iconButton
     }()
     
     private lazy var titleLabel: UILabel = {
         let titleLabel = UILabel()
-        titleLabel.text = "张吃饭"
         titleLabel.textColor = k999999Color
         titleLabel.font = kRegularFont14
         titleLabel.textAlignment = .left
@@ -88,7 +94,6 @@ class CommunityMajorCommentCell: UITableViewCell {
     
     private lazy var contentLabel: UILabel = {
         let contentLabel = UILabel()
-        contentLabel.text = "点击单条评时弹出选择操作框(目前仅支持回复),点击操作框后进行相应的操作"
         contentLabel.textColor = k333333Color
         contentLabel.font = kRegularFont14
         contentLabel.textAlignment = .left
@@ -98,11 +103,24 @@ class CommunityMajorCommentCell: UITableViewCell {
     
     private lazy var timeLabel: UILabel = {
         let timeLabel = UILabel()
-        timeLabel.text = "6个小时前"
         timeLabel.textColor = kbbbbbbColor
         timeLabel.font = kRegularFont12
         timeLabel.textAlignment = .left
         return timeLabel
     }()
     
+    var communityPostCommentModel : CommunityPostCommentModel? {
+        didSet {
+            iconButton.kf.setImage(with: kURLImage(name: communityPostCommentModel?.avatar ?? ""), for: UIControl.State.normal, placeholder: kImage(name: "default_avatar"))
+            titleLabel.text = communityPostCommentModel?.username
+            contentLabel.text = communityPostCommentModel?.content
+            timeLabel.text = communityPostCommentModel?.createdAt
+            let contentLabelHeight = communityPostCommentModel?.content?.heightForComment(font: kRegularFont14!, width: kScreenWidth - 14 - 48)
+            let subViewHeight = 24.0 + (contentLabelHeight ?? 0) + 15.0
+            let spacHeight = 20 + 6.0 + 8.0 + 20.0
+            communityPostCommentModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
+        }
+    }
+    
+    
 }

+ 49 - 18
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunitySubComment/CommunityReplyCommentCell.swift

@@ -7,9 +7,12 @@
 //  二级评论--评论回复のCell
 
 import UIKit
+import RxSwift
 
 class CommunityReplyCommentCell: UITableViewCell {
     
+    let disposeBag = DisposeBag()
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> CommunityReplyCommentCell {
         let ID = "CommunityReplyCommentCell"
         tableView.register(CommunityReplyCommentCell.self, forCellReuseIdentifier: ID)
@@ -37,58 +40,62 @@ class CommunityReplyCommentCell: UITableViewCell {
     //MRAK: - 设置View
     private func setupViews() {
         self.selectionStyle = .none
+        
         backgroundColor = kf7f8faColor
         
-        addSubview(iconImageView)
+        addSubview(iconButton)
         addSubview(titleLabel)
         addSubview(contentLabel)
         addSubview(timeLabel)
     }
     
     private func setupLayouts() {
-        iconImageView.snp.makeConstraints { (make) in
-            make.top.equalTo(10)
+        iconButton.snp.makeConstraints { (make) in
+            make.top.equalTo(0)
             make.left.equalTo(24)
             make.size.equalTo(24)
         }
         titleLabel.snp.makeConstraints { (make) in
-            make.left.equalTo(iconImageView.snp_right).offset(10)
-            make.right.equalToSuperview().offset(-26)
-            make.centerY.equalTo(iconImageView)
+            make.left.equalTo(iconButton.snp_right).offset(10)
+            make.right.equalToSuperview().offset(-10)
+            make.centerY.equalTo(iconButton)
             make.height.equalTo(17)
         }
         contentLabel.snp.makeConstraints { (make) in
             make.top.equalTo(titleLabel.snp_bottom).offset(12)
             make.left.equalTo(titleLabel.snp_left)
-            make.right.equalToSuperview().offset(-26)
+            make.right.equalToSuperview().offset(-10)
+            make.width.equalTo(kScreenWidth-62-54)
         }
         timeLabel.snp.makeConstraints { (make) in
             make.top.equalTo(contentLabel.snp_bottom).offset(8)
             make.left.equalTo(titleLabel.snp_left)
             make.right.equalTo(contentLabel.snp_right)
             make.height.equalTo(15)
-            make.bottom.equalToSuperview()
         }
     }
     
-    lazy var iconImageView : UIImageView = {
-        let iconImageView = UIImageView()
-        iconImageView.image = kImage(name: "page05")
-        return iconImageView
+    private lazy var iconButton : UIButton = {
+        let iconButton = UIButton(type: UIButton.ButtonType.custom)
+        iconButton.setImage(kImage(name: "default_avatar"), for: UIControl.State.normal)
+        iconButton.cornerRadius = 12
+        iconButton.masksToBounds = true
+        iconButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+            
+        }).disposed(by: disposeBag)
+        return iconButton
     }()
     
     private lazy var titleLabel: UILabel = {
         let titleLabel = UILabel()
-        titleLabel.text = "Monster"
         titleLabel.textColor = k999999Color
         titleLabel.font = kRegularFont14
         titleLabel.textAlignment = .left
         return titleLabel
     }()
     
-    private lazy var contentLabel: UILabel = {
-        let contentLabel = UILabel()
-        contentLabel.text = "我也觉得好看"
+    private lazy var contentLabel: FMLinkLabel = {
+        let contentLabel = FMLinkLabel()
         contentLabel.textColor = k333333Color
         contentLabel.font = kRegularFont14
         contentLabel.textAlignment = .left
@@ -96,13 +103,37 @@ class CommunityReplyCommentCell: UITableViewCell {
         return contentLabel
     }()
     
-    private lazy var timeLabel: UILabel = {
+    lazy var timeLabel: UILabel = {
         let timeLabel = UILabel()
-        timeLabel.text = "6个小时前"
         timeLabel.textColor = kbbbbbbColor
         timeLabel.font = kRegularFont12
         timeLabel.textAlignment = .left
         return timeLabel
     }()
     
+    var communityPostReplyModel: CommunityPostReplyModel? {
+        didSet {
+            iconButton.kf.setImage(with: kURLImage(name: communityPostReplyModel?.avatar ?? ""), for: UIControl.State.normal, placeholder: kImage(name: "default_avatar"))
+            
+            titleLabel.text = communityPostReplyModel?.username
+            
+            let replyUsername = "回复 @\(communityPostReplyModel?.replyUsername ?? ""):"
+            let content = "\(communityPostReplyModel?.content ?? "")"
+            if communityPostReplyModel?.replyUsername != "" && communityPostReplyModel?.replyUsername != nil  {
+                contentLabel.text =  replyUsername + content
+                contentLabel.addClickText("@\(communityPostReplyModel?.replyUsername ?? "")", attributeds: [NSAttributedString.Key.font:kMediumFont14 as Any], transmitBody: nil) {
+                    (data) in
+                }
+            }else {
+                contentLabel.text = content
+            }
+            
+            timeLabel.text = communityPostReplyModel?.createdAt
+            let contentLabelHeight = contentLabel.text?.heightForComment(font: kRegularFont14!, width: kScreenWidth - 58 - 14)
+            let subViewHeight = 24.0 + (contentLabelHeight ?? 0) + 15.0
+            let spacHeight = 10.0 + 8.0 + 8.0
+            communityPostReplyModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
+        }
+    }
+    
 }

+ 176 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunitySubComment/ViewController/CommunitySubCommentController.swift

@@ -0,0 +1,176 @@
+//
+//  CommunitySubCommentController.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/12.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class CommunitySubCommentController: BaseViewController {
+    
+    var communityPostCommentModel : CommunityPostCommentModel?
+    var communityPostReplyModels = Array<CommunityPostReplyModel>()
+    
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        setupViews()
+        setupLayouts()
+        setupData()
+    }
+    
+    override func viewWillAppear(_ animated: Bool) {
+        cmtKeyboard.isDisappear = false
+    }
+    
+    override func viewWillDisappear(_ animated: Bool) {
+        cmtKeyboard.isDisappear = true
+    }
+    
+    override func setupViews() {
+        navigationBar.title = "3条评论"
+        view.backgroundColor = kf7f8faColor
+        
+        view.addSubview(tableView)
+        view.addSubview(cmtKeyboard)
+    }
+    
+    override func setupLayouts() {
+        tableView.snp.makeConstraints { (make) in
+            make.top.equalToSuperview().offset(kNavBarTotalHeight)
+            make.left.right.bottom.equalTo(0)
+        }
+    }
+    
+    lazy var tableView: UITableView = {
+        let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
+        tableView.separatorStyle = .none
+        tableView.backgroundColor = kf7f8faColor
+        tableView.dataSource = self
+        tableView.delegate = self
+        tableView.estimatedRowHeight = 0
+        tableView.estimatedSectionFooterHeight = 0
+        tableView.estimatedSectionHeaderHeight = 0
+        return tableView
+    }()
+    
+    lazy var cmtKeyboard: LXKeyBoard = {
+        let cmtKeyboard = LXKeyBoard.init()
+        cmtKeyboard.backgroundColor = kffffffColor
+        cmtKeyboard.maxLine = 3
+        cmtKeyboard.font = kRegularFont14
+        cmtKeyboard.topOrBottomEdge = 10
+        cmtKeyboard.beginUpdateUI()
+        cmtKeyboard.sendBlock = {
+            [weak self] (text) in
+            print("----\(text)")
+        }
+        
+        return cmtKeyboard
+    }()
+    
+    override func setupData() {
+        tableView.addHeaderWithHeader(withBeginRefresh: true, animation: false) { [weak self] (page) in
+            self?.communityPostReplyApi(page: page)
+        }
+        tableView.addFooterWithWithHeader(withAutomaticallyRefresh: false) {
+            [weak self] (page) in
+            self?.communityPostReplyApi(page: page)
+        }
+    }
+}
+
+extension CommunitySubCommentController {
+    
+    /// 获取子评论
+    ///
+    /// - Parameter page: 分页
+    func communityPostReplyApi(page:Int) {
+        SwiftMoyaNetWorkServiceCommunity.shared().communityPostReplyApi(postId: communityPostCommentModel?.id ?? 0, page: page) { [weak self] (communityPostReplysModel) -> (Void) in
+            let communityPostReplysModel = communityPostReplysModel as? CommunityPostReplysModel
+            if communityPostReplysModel?.pagination?.currentPage ?? 1  <= communityPostReplysModel?.pagination?.totalPages ?? 1 {
+                if communityPostReplysModel?.pagination?.currentPage == 1{
+                    self?.communityPostReplyModels.removeAll()
+                }
+                self?.communityPostReplyModels = (self?.communityPostReplyModels)! + (communityPostReplysModel?.data!)!
+                self?.tableView.reloadData()
+                if  self?.communityPostReplyModels.count ?? 0 >= communityPostReplysModel?.pagination?.total ?? 0 {
+                    self?.tableView.endFooterNoMoreData()
+                }
+            }else {
+                self?.tableView.endFooterNoMoreData()
+            }
+        }
+    }
+}
+
+// MARK: - tableView dataSource && delegate
+extension CommunitySubCommentController: UITableViewDataSource, UITableViewDelegate {
+    
+    func numberOfSections(in tableView: UITableView) -> Int {
+        return 2
+    }
+    
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        switch section {
+        case 0:
+            if communityPostCommentModel != nil {
+                return 1
+            }else {
+                return 0
+            }
+        default:
+            return communityPostReplyModels.isEmpty ? 0 : communityPostReplyModels.count
+        }
+    }
+    
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        
+        switch indexPath.section {
+        case 0:
+            let cell = CommunityMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.communityPostCommentModel = communityPostCommentModel
+            return cell
+        default:
+            let cell = CommunityReplyCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.communityPostReplyModel = communityPostReplyModels[indexPath.row]
+            return cell
+        }
+        
+    }
+    
+    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+       
+    }
+    
+    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        switch indexPath.section {
+        case 0:
+            return communityPostCommentModel?.height ?? 0
+        default:
+            return communityPostReplyModels[indexPath.row].height ?? 0
+        }
+    }
+    
+    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
+        return 10
+    }
+    
+    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
+        return UIView()
+        
+    }
+    
+    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
+        return 0.000001
+        
+    }
+    
+    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
+        return UIView()
+    }
+    
+}
+
+

+ 1 - 1
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceCommunity/SwiftMoyaServiceCommunityApi.swift

@@ -79,7 +79,7 @@ public let kCommunityPostCommentApi = "/community/post/comment"
 
 // MARK: - 回复列表
 /// 回复列表
-public let kCommunityPostReplyApi = "community/post/reply"
+public let kCommunityPostReplyApi = "/community/post/reply"
 
 
 

+ 49 - 52
RainbowPlanet/RainbowPlanet/Tools/CommentKeyboard/LXKeyBoard.m

@@ -54,6 +54,7 @@
         self.font = Font(14);
         self.maxLine = 3;
         
+        
     }
     return self;
 }
@@ -78,7 +79,7 @@
 
 -(void)beginUpdateUI{
     //初始化高度 textView的lineHeight + 2 * 上下间距
-    CGFloat orignTextH  = 28 + 2 * self.topOrBottomEdge;
+    CGFloat orignTextH  = 28 + 2 * self.topOrBottomEdge + 34;
     
     self.frame = CGRectMake(0, Device_Height - orignTextH, Device_Width, orignTextH);
     
@@ -96,39 +97,39 @@
         }
     }];
 }
--(void)textViewDidChange:(UITextView *)textView{
-    
-    CGFloat contentSizeH = self.textView.contentSize.height;
-    CGFloat lineH = self.textView.font.lineHeight;
-    
-    CGFloat maxHeight = ceil(lineH * self.maxLine + textView.textContainerInset.top + textView.textContainerInset.bottom);
-    if (contentSizeH <= maxHeight) {
-        self.textView.lx_height = contentSizeH;
-    }else{
-        self.textView.lx_height = maxHeight;
-    }
-    
-    [textView scrollRangeToVisible:NSMakeRange(textView.selectedRange.location, 1)];
-    
-    
-    CGFloat totalH = ceil(self.textView.lx_height) + 2 * self.topOrBottomEdge;
-    self.frame = CGRectMake(0, keyboardY - totalH, self.lx_width, totalH);
-    
-    
-    if (self.lx_height-38 < 10) {
-        self.sendBtn.lx_y = 10;
-    } else {
-        self.sendBtn.lx_y = self.lx_height-38;
-    }
-    
-    
-    if (textView.text.length > 0) {
-        _sendBtn.backgroundColor = [UIColor hexStringToColor:@"62cc74"];
-    } else {
-        _sendBtn.backgroundColor = [UIColor hexStringToColor:@"d8d8d8"];
-    }
-    
-}
+//-(void)textViewDidChange:(UITextView *)textView{
+//
+//    CGFloat contentSizeH = self.textView.contentSize.height;
+//    CGFloat lineH = self.textView.font.lineHeight;
+//
+//    CGFloat maxHeight = ceil(lineH * self.maxLine + textView.textContainerInset.top + textView.textContainerInset.bottom);
+//    if (contentSizeH <= maxHeight) {
+//        self.textView.lx_height = contentSizeH;
+//    }else{
+//        self.textView.lx_height = maxHeight;
+//    }
+//
+//    [textView scrollRangeToVisible:NSMakeRange(textView.selectedRange.location, 1)];
+//
+//
+//    CGFloat totalH = ceil(self.textView.lx_height) + 2 * self.topOrBottomEdge;
+//    self.frame = CGRectMake(0, keyboardY - totalH, self.lx_width, totalH);
+//
+//
+//    if (self.lx_height-38 < 10) {
+//        self.sendBtn.lx_y = 10;
+//    } else {
+//        self.sendBtn.lx_y = self.lx_height-38;
+//    }
+//
+//
+//    if (textView.text.length > 0) {
+//        _sendBtn.backgroundColor = [UIColor hexStringToColor:@"62cc74"];
+//    } else {
+//        _sendBtn.backgroundColor = [UIColor hexStringToColor:@"d8d8d8"];
+//    }
+//
+//}
 -(void)keyboardWillChangeFrame:(NSNotification *)notification{
     
     NSDictionary *userInfo = notification.userInfo;
@@ -140,13 +141,7 @@
     //        NSLog(@"%@",NSStringFromCGRect(keyboardF));
     keyboardY = keyboardF.origin.y;
     
-    if (!_isDisappear) {
-        
-        [self dealKeyBoardWithKeyboardF:keyboardY duration:duration];
-        
-    }
-    
-    
+    [self dealKeyBoardWithKeyboardF:keyboardY duration:duration];
 }
 
 -(void)keyboardDidChangeFrame:(NSNotification *)notification{
@@ -160,9 +155,7 @@
     
     keyboardY = keyboardF.origin.y;
     //    // 工具条的Y值 == 键盘的Y值 - 工具条的高度
-    if (_isDisappear) {
-        [self dealKeyBoardWithKeyboardF:keyboardY duration:duration];
-    }
+    [self dealKeyBoardWithKeyboardF:keyboardY duration:duration];
     
 }
 #pragma mark---处理高度---
@@ -173,19 +166,23 @@
             // 工具条的Y值 == 键盘的Y值 - 工具条的高度
             
             if (keyboardY > Device_Height) {
-                self.lx_y = Device_Height- self.lx_height;
+                self.lx_y = Device_Height - self.lx_height;
             }else
             {
                 self.lx_y = keyboardY - self.lx_height;
             }
         }];
     }else{
-        if (keyboardY > Device_Height) {
-            self.lx_y = Device_Height- self.lx_height;
-        }else
-        {
-            self.lx_y = keyboardY - self.lx_height;
-        }
+        [UIView animateWithDuration:duration animations:^{
+            // 工具条的Y值 == 键盘的Y值 - 工具条的高度
+            
+            if (keyboardY > Device_Height) {
+                self.lx_y = Device_Height- self.lx_height;
+            }else
+            {
+                self.lx_y = keyboardY - self.lx_height;
+            }
+        }];
     }
     
     
@@ -223,7 +220,7 @@
         _textView =[[LXTextView alloc]initWithFrame:CGRectMake(14, self.topOrBottomEdge, self.lx_width-89-14, 28)];
         _textView.backgroundColor = [UIColor hexStringToColor:@"fafafa"];
         _textView.font = self.font;
-        _textView.delegate = self;
+//        _textView.delegate = self;
         _textView.layoutManager.allowsNonContiguousLayout = NO;
         _textView.enablesReturnKeyAutomatically = YES;
         _textView.scrollsToTop = NO;