Browse Source

修复了评论间距的问题

南鑫林 5 years ago
parent
commit
8805488f0d

+ 34 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/View/Cell/CardContent/CommentList/CardContentCommentListContentTableViewCell.swift

@@ -164,6 +164,25 @@ class CardContentCommentListContentTableViewCell: UITableViewCell {
             }else {
                 likeButton.isSelected = false
             }
+            likeCountLabel.snp_remakeConstraints { (make) in
+                make.top.equalTo(0)
+                make.right.equalTo(-14)
+            }
+            likeButton.snp_remakeConstraints { (make) in
+                make.right.equalTo(likeCountLabel.snp.left).offset(-5)
+                make.centerY.equalTo(likeCountLabel)
+                make.size.equalTo(16)
+            }
+            
+            let likeCountWidth =  likeCount.widthForComment(font: kRegularFont14!, height: 25.5)
+            
+            commentLabel.snp_remakeConstraints { (make) in
+                make.top.equalToSuperview()
+                make.left.equalTo(14)
+                make.width.equalTo(kScreenWidth-28-10-16-5-likeCountWidth)
+               
+            }
+
         }
     }
     
@@ -187,6 +206,21 @@ class CardContentCommentListContentTableViewCell: UITableViewCell {
             }else {
                 likeButton.isSelected = false
             }
+            likeCountLabel.snp_remakeConstraints { (make) in
+                make.top.equalTo(0)
+                make.right.equalTo(-14)
+            }
+            likeButton.snp_remakeConstraints { (make) in
+                make.right.equalTo(likeCountLabel.snp.left).offset(-5)
+                make.centerY.equalTo(likeCountLabel)
+                make.size.equalTo(16)
+            }
+            let likeCountWidth =  likeCount.widthForComment(font: kRegularFont14!, height: 25.5)
+            commentLabel.snp_remakeConstraints { (make) in
+                make.top.equalToSuperview()
+                make.left.equalTo(14)
+                make.width.equalTo(kScreenWidth-28-10-16-5-likeCountWidth)
+            }
         }
     }
     

+ 58 - 25
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/AllCommentCell/RecommendSubCommentTableViewCell.swift

@@ -80,7 +80,6 @@ class RecommendSubCommentTableViewCell: UITableViewCell {
             make.left.equalTo(titleLabel.snp_left)
             make.right.equalTo(contentLabel.snp_right)
             make.height.equalTo(15)
-            make.bottom.equalToSuperview()
         }
         
         likeCountLabel.snp.makeConstraints { (make) in
@@ -152,34 +151,68 @@ class RecommendSubCommentTableViewCell: UITableViewCell {
     }()
     
     @objc func likeAction() {
-        VirusViewModel.shared.commentlikeVirueRecordApi(button: likeButton,
-                                                        label: likeCountLabel,
-                                                        isCommentLike: communityPostReplyModel?.isLike,
-                                                        postId: communityPostDetailModel?.id,
-                                                        postAuthorUid: "\(communityPostDetailModel?.uid ?? 0)",
-            title: communityPostDetailModel?.title,
-            content: communityPostDetailModel?.content,
-            postCover: communityPostDetailModel?.img,
-            actionId: "\(communityPostDetailModel?.id ?? 0)",
-            postType: communityPostDetailModel?.type,
-            commentContent: communityPostReplyModel?.content,
-            commentId: communityPostReplyModel?.id,
-            commentUId: communityPostReplyModel?.uid,
-            commentLikeCount: communityPostReplyModel?.likeCount) {
-                [weak self] (isCommentLike) in
-                self?.communityPostReplyModel?.isLike = isCommentLike
-                if isCommentLike == 1 {
-                    self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) + 1
-                }
-                if isCommentLike == 0 {
-                    self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) - 1
-                }
+
+        if communityPostDetailModel != nil {
+            VirusViewModel.shared.commentlikeVirueRecordApi(button: likeButton,
+                                                            label: likeCountLabel,
+                                                            isCommentLike: communityPostReplyModel?.isLike,
+                                                            postId: communityPostDetailModel?.id,
+                                                            postAuthorUid: "\(communityPostDetailModel?.uid ?? 0)",
+                title: communityPostDetailModel?.title,
+                content: communityPostDetailModel?.content,
+                postCover: communityPostDetailModel?.img,
+                actionId: "\(communityPostDetailModel?.id ?? 0)",
+                postType: communityPostDetailModel?.type,
+                commentContent: communityPostReplyModel?.content,
+                commentId: communityPostReplyModel?.id,
+                commentUId: communityPostReplyModel?.uid,
+                commentLikeCount: communityPostReplyModel?.likeCount) {
+                    [weak self] (isCommentLike) in
+                    self?.communityPostReplyModel?.isLike = isCommentLike
+                    if isCommentLike == 1 {
+                        self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) + 1
+                    }
+                    if isCommentLike == 0 {
+                        self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) - 1
+                    }
+            }
+        }
+        
+        if communityVideoItemModel != nil {
+            VirusViewModel.shared.commentlikeVirueRecordApi(button: likeButton,
+                                                            label: likeCountLabel,
+                                                            isCommentLike: communityPostReplyModel?.isLike,
+                                                            postId: communityVideoItemModel?.id,
+                                                            postAuthorUid: "\(communityVideoItemModel?.uid ?? 0)",
+                title: communityVideoItemModel?.title,
+                content: communityVideoItemModel?.content,
+                postCover: communityVideoItemModel?.img,
+                actionId: "\(communityVideoItemModel?.id ?? 0)",
+                postType: communityVideoItemModel?.type,
+                commentContent: communityPostReplyModel?.content,
+                commentId: communityPostReplyModel?.id,
+                commentUId: communityPostReplyModel?.uid,
+                commentLikeCount: communityPostReplyModel?.likeCount) {
+                    [weak self] (isCommentLike) in
+                    self?.communityPostReplyModel?.isLike = isCommentLike
+                    if isCommentLike == 1 {
+                        self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) + 1
+                    }
+                    if isCommentLike == 0 {
+                        self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) - 1
+                    }
+            }
         }
+        
     }
     
     /// 帖子Id
     var communityPostDetailModel : CommunityPostDetailModel?
     
+    var communityVideoItemModel : CommunityVideoItemModel?
+    
+    
+    
     var communityPostReplyModel: CommunityPostReplyModel? {
         didSet {
             iconButton.kf.setImage(with: kURLImage(name: communityPostReplyModel?.avatar ?? ""), for: UIControl.State.normal, placeholder: kImage(name: "default_avatar"))
@@ -215,10 +248,10 @@ class RecommendSubCommentTableViewCell: UITableViewCell {
                 likeCountLabel.isHidden = false
                 likeButton.isHidden = false
             }
-            
+            contentLabel.sizeToFit()
             let contentLabelHeight = contentLabel.text?.heightForComment(font: kRegularFont14!, width: kScreenWidth - 24 - 92)
             let subViewHeight = 17.0 + (contentLabelHeight ?? 0) + 15.0
-            let spacHeight = 10.0 + 8.0 + 8.0
+            let spacHeight = 10.0 + 12 + 8.0
             communityPostReplyModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
         }
     }

+ 3 - 3
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunitySubComment/View/CommunityMajorCommentCell.swift

@@ -51,7 +51,7 @@ class CommunityMajorCommentCell: UITableViewCell {
     
     private func setupLayouts() {
         iconButton.snp.makeConstraints { (make) in
-            make.top.equalTo(0)
+            make.top.equalTo(15)
             make.left.equalTo(14)
             make.size.equalTo(38)
         }
@@ -87,7 +87,7 @@ class CommunityMajorCommentCell: UITableViewCell {
     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.cornerRadius = 19
         iconButton.masksToBounds = true
         iconButton.rx.tap.subscribe(onNext: { [weak self] (data) in
             
@@ -223,7 +223,7 @@ class CommunityMajorCommentCell: UITableViewCell {
             }
             let contentLabelHeight = communityPostCommentModel?.content?.heightForComment(font: kRegularFont14!, width: kScreenWidth - 14 - 48)
             let subViewHeight = 17.0 + (contentLabelHeight ?? 0) + 15.0
-            let spacHeight = 20 + 8.0 + 8.0 + 20.0
+            let spacHeight = 15 + 8.0 + 8.0 + 15
             communityPostCommentModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
         }
     }

+ 1 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoMajorCommentCell.swift

@@ -266,6 +266,7 @@ extension CommunityVideoMajorCommentCell: UITableViewDataSource, UITableViewDele
         let reply = communityPostCommentModel?.reply?.prefix(2)
         let cell = RecommendSubCommentTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
         cell.communityPostReplyModel = reply?[indexPath.row]
+        cell.communityVideoItemModel = communityVideoItemModel
         return cell
         
     }