소스 검색

视频详情评论列表展示

Chris 5 년 전
부모
커밋
956b4bf15a
1개의 변경된 파일21개의 추가작업 그리고 17개의 파일을 삭제
  1. 21 17
      RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityAllCommentView.swift

+ 21 - 17
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityAllCommentView.swift

@@ -132,7 +132,6 @@ class CommunityAllCommentView: FWPopupView {
         tableView.estimatedRowHeight = 0.000001
         tableView.estimatedSectionFooterHeight = 0.000001
         tableView.estimatedSectionHeaderHeight = 0.000001
-        tableView.isScrollEnabled = false
         return tableView
     }()
     
@@ -141,15 +140,18 @@ class CommunityAllCommentView: FWPopupView {
 extension CommunityAllCommentView : UITableViewDelegate, UITableViewDataSource {
     
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return 3
+        return communityPostCommentModels.isEmpty ? 1 : communityPostCommentModels.count
     }
     
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        if indexPath.row == 0 {
-            let cell = CommunityMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
-            return cell
+        if communityPostCommentModels.isEmpty {
+            return UITableViewCell()
         } else {
-            let cell = CommunityReplyCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
+            let cell = RecommendMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.communityPostCommentModel = communityPostCommentModels[indexPath.row]
+            cell.frame = tableView.bounds
+            cell.layoutIfNeeded()
+            cell.reloadData()
             return cell
         }
     }
@@ -159,7 +161,11 @@ extension CommunityAllCommentView : UITableViewDelegate, UITableViewDataSource {
     }
     
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
-        return UITableView.automaticDimension
+        if communityPostCommentModels.isEmpty {
+            return 0
+        }else {
+            return communityPostCommentModels[indexPath.row].height ?? 0
+        }
     }
     
     func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
@@ -186,12 +192,18 @@ extension CommunityAllCommentView {
     ///   - postId: 内容id
     ///   - page: 分页
     func communityPostCommentApi(page:Int) {
+        
         SwiftMoyaNetWorkServiceCommunity.shared().communityPostCommentApi(postId: postId ?? 0, page: page) {
             [weak self] (communityPostCommentsModel) -> (Void) in
-            
             let commentsMdl = communityPostCommentsModel as? CommunityPostCommentsModel
             self?.communityPostCommentsModel = commentsMdl
             
+            if self?.communityPostCommentsModel?.pagination?.currentPage == 1{
+                self?.communityPostCommentModels.removeAll()
+            }
+            self?.communityPostCommentModels = (self?.communityPostCommentModels)! + (self?.communityPostCommentsModel?.data!)!
+            self?.tableView.reloadData()
+            
             let totalComments: Int = commentsMdl?.pagination?.total ?? 0
             self?.titleLabel.text = "全部评论 \(totalComments)"
             if totalComments == 0 {
@@ -201,15 +213,7 @@ extension CommunityAllCommentView {
                 self?.tableView.isHidden = false
                 self?.noCommentsLabel.isHidden = true
             }
-            
-            
-            
-//            if self?.communityPostCommentsModel?.pagination?.currentPage == 1{
-//                self?.communityPostCommentModels.removeAll()
-//            }
-//            self?.communityPostCommentModels = (self?.communityPostCommentModels)! + (self?.communityPostCommentsModel?.data!)!
-//            self?.tableView.reloadData()
-            
         }
+        
     }
 }